[Bug #838] Fix bug
If the interval allocated didn't overlap with the task's bounds an exception was caused. Now this is avoided. FEA: ItEr70S04BugFixing
This commit is contained in:
parent
93765d7460
commit
4bbd1ed59a
2 changed files with 29 additions and 5 deletions
|
|
@ -874,11 +874,17 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
|
||||
public IntervalInsideTask(LocalDate startInclusive,
|
||||
LocalDate endExclusive) {
|
||||
this.start = IntraDayDate.max(IntraDayDate
|
||||
.startOfDay(startInclusive), getTask()
|
||||
.getFirstDayNotConsolidated());
|
||||
this.end = IntraDayDate.min(task.getIntraDayEndDate(),
|
||||
IntraDayDate.startOfDay(endExclusive));
|
||||
Validate.isTrue(startInclusive.compareTo(endExclusive) <= 0);
|
||||
|
||||
IntraDayDate taskStart = getTask().getFirstDayNotConsolidated();
|
||||
IntraDayDate taskEnd = task.getIntraDayEndDate();
|
||||
|
||||
this.start = IntraDayDate.min(IntraDayDate.max(IntraDayDate
|
||||
.startOfDay(startInclusive), taskStart), taskEnd);
|
||||
|
||||
this.end = IntraDayDate.max(
|
||||
IntraDayDate.min(taskEnd,
|
||||
IntraDayDate.startOfDay(endExclusive)), taskStart);
|
||||
}
|
||||
|
||||
public IntraDayDate getStart() {
|
||||
|
|
|
|||
|
|
@ -327,6 +327,24 @@ public class SpecificResourceAllocationTest {
|
|||
haveHours(4, 4, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ifTheProvidedIntervalIsAfterTheTaskDoesntAllocateAnything() {
|
||||
LocalDate start = new LocalDate(2000, 2, 4);
|
||||
givenSpecificResourceAllocation(start, 4);
|
||||
specificResourceAllocation.onInterval(start.plusDays(5),
|
||||
start.plusDays(6)).allocateHours(12);
|
||||
assertTrue(specificResourceAllocation.getAssignments().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ifTheProvidedIntervalIsBeforeTheTaskDoesntAllocateAnything() {
|
||||
LocalDate start = new LocalDate(2000, 2, 4);
|
||||
givenSpecificResourceAllocation(start, 4);
|
||||
specificResourceAllocation.onInterval(start.minusDays(5),
|
||||
start.minusDays(2)).allocateHours(12);
|
||||
assertTrue(specificResourceAllocation.getAssignments().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void thePartOfTheIntervalUsedIsTheOneOverlappingWithTheTask() {
|
||||
LocalDate start = new LocalDate(2000, 2, 4);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue