[Bug #1091] Be more lenient if the end date is before start date

Do nothing instead of throwing an exception.
This commit is contained in:
Óscar González Fernández 2011-06-09 12:28:33 +02:00
parent e2a4fff81c
commit 834dbeb39b
2 changed files with 7 additions and 3 deletions

View file

@ -771,7 +771,8 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
private AllocateResourcesPerDayOnInterval(
IntraDayDate startInclusive, IntraDayDate endExclusive) {
this.startInclusive = startInclusive;
this.endExclusive = endExclusive;
this.endExclusive = IntraDayDate.max(startInclusive,
endExclusive);
}
@Override

View file

@ -456,8 +456,8 @@ public class GenericResourceAllocationTest {
assertThat(orderedAssignmentsFor, haveHours(hoursPerDay, hoursPerDay));
}
@Test(expected = IllegalArgumentException.class)
public void whenAllocatingUntilSomeEndDateTheEndDateMustNotBeBeforeTaskStart() {
@Test
public void whenAllocatingUntilSomeEndDateBeforeTheStartNothingIsDone() {
LocalDate start = new LocalDate(2006, 10, 5);
givenTaskWithStartAndEnd(toInterval(start, Period.days(4)));
givenGenericResourceAllocationForTask(task);
@ -467,6 +467,9 @@ public class GenericResourceAllocationTest {
genericResourceAllocation.forResources(Arrays.asList(worker1))
.resourcesPerDayUntil(start.minusDays(1))
.allocate(resourcesPerDay);
assertTrue(genericResourceAllocation.getOrderedAssignmentsFor(worker1)
.isEmpty());
}
@Test(expected = IllegalArgumentException.class)