ItEr37S12CUAdministracionCategoriaCosteItEr36S14: added a negative time interval restriction to ResourcesCostCategoryAssignment
This commit is contained in:
parent
be8709f7f1
commit
9366c61447
2 changed files with 19 additions and 0 deletions
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.navalplanner.business.costcategories.entities;
|
||||
|
||||
import org.hibernate.validator.AssertTrue;
|
||||
import org.hibernate.validator.NotNull;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.common.BaseEntity;
|
||||
|
|
@ -88,4 +89,12 @@ public class ResourcesCostCategoryAssignment extends BaseEntity {
|
|||
resource.addResourcesCostCategoryAssignment(this);
|
||||
}
|
||||
}
|
||||
|
||||
@AssertTrue(message="The end date cannot be before the init date")
|
||||
public boolean checkPositiveTimeInterval() {
|
||||
if (endDate == null) {
|
||||
return true;
|
||||
}
|
||||
return (endDate.isAfter(initDate) || initDate.equals(endDate));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.joda.time.LocalDate;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.costcategories.daos.ICostCategoryDAO;
|
||||
import org.navalplanner.business.costcategories.daos.IResourcesCostCategoryAssignmentDAO;
|
||||
import org.navalplanner.business.costcategories.entities.CostCategory;
|
||||
|
|
@ -131,4 +132,13 @@ public class ResourcesCostCategoryAssignmentDAOTest {
|
|||
assignment.setResource(null);
|
||||
assertFalse(resource.getResourcesCostCategoryAssignments().contains(assignment));
|
||||
}
|
||||
|
||||
@Test(expected=ValidationException.class)
|
||||
public void testPositiveTimeInterval() {
|
||||
ResourcesCostCategoryAssignment assignment = createValidResourcesCostCategoryAssignment();
|
||||
assignment.setInitDate(new LocalDate(2000,12,31));
|
||||
assignment.setEndDate(new LocalDate(2000,12,1));
|
||||
|
||||
resourcesCostCategoryAssignmentDAO.save(assignment);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue