ItEr29S06CUAsignacionGrupoRecursosAPlanificacionItEr28S06: Can allocate hours on interval using previous resources

This commit is contained in:
Óscar González Fernández 2009-10-08 23:19:05 +02:00
parent b41f3abd24
commit f3e582a32d
3 changed files with 29 additions and 1 deletions

View file

@ -257,4 +257,8 @@ public class GenericResourceAllocation extends
return new ArrayList<Resource>(resources);
}
public IAllocatable withPreviousAssociatedResources() {
return forResources(getAssociatedResources());
}
}

View file

@ -113,7 +113,7 @@ public class ShareDivision {
remainderIncrease = remainderIncrease - bucket.getIncreaseDone();
assert remainderIncrease >= 0;
}
assert remainderIncrease == 0 : "all is assigned";
assert remainderIncrease == 0 || shares.isEmpty() : "all is assigned";
return ShareDivision.create(fromWrappers(wrapped));
}

View file

@ -359,4 +359,28 @@ public class GenericResourceAllocationTest {
return new HashSet<Resource>(associatedResources);
}
@Test
public void canAllocateHoursOnIntervalUsingPreviousResources() {
final int workableHoursDay = 8;
givenBaseCalendarWithoutExceptions(workableHoursDay);
LocalDate start = new LocalDate(2006, 10, 5);
final int days = 4;
givenTaskWithStartAndEnd(toInterval(start, Period.days(days)));
givenGenericResourceAllocationForTask(task);
givenWorkersWithLoads(3, 12, 1);
genericResourceAllocation.forResources(workers).allocate(
ResourcesPerDay.amount(1));
final int hoursOnSubinterval = 3;
int daysSubinterval = 2;
genericResourceAllocation.withPreviousAssociatedResources().onInterval(
start,
start.plusDays(daysSubinterval)).allocateHours(
hoursOnSubinterval);
assertThat(genericResourceAllocation.getAssignedHours(),
equalTo(hoursOnSubinterval + (days - daysSubinterval)
* workableHoursDay));
}
}