Add additional tests to ensure that the resources per day specified are kept
FEA: ItEr62OTS04PlanificacionHaciaAtras
This commit is contained in:
parent
ca22a8d172
commit
7c7b942c85
1 changed files with 38 additions and 7 deletions
|
|
@ -177,23 +177,26 @@ public class SpecificResourceAllocationTest {
|
|||
replay(this.worker);
|
||||
}
|
||||
|
||||
private void givenTask(LocalDate start, LocalDate end) {
|
||||
private void givenTask(IntraDayDate start, IntraDayDate end) {
|
||||
task = createNiceMock(Task.class);
|
||||
expect(task.getCalendar()).andReturn(baseCalendar).anyTimes();
|
||||
expect(task.getStartDate()).andReturn(
|
||||
start.toDateTimeAtStartOfDay().toDate()).anyTimes();
|
||||
expect(task.getIntraDayStartDate()).andReturn(
|
||||
IntraDayDate.startOfDay(start)).anyTimes();
|
||||
expect(task.getIntraDayStartDate()).andReturn(start).anyTimes();
|
||||
expect(task.getEndDate()).andReturn(
|
||||
end.toDateTimeAtStartOfDay().toDate()).anyTimes();
|
||||
expect(task.getIntraDayEndDate()).andReturn(
|
||||
IntraDayDate.startOfDay(end)).anyTimes();
|
||||
expect(task.getFirstDayNotConsolidated()).andReturn(
|
||||
IntraDayDate.startOfDay(start)).anyTimes();
|
||||
expect(task.getIntraDayEndDate()).andReturn(end).anyTimes();
|
||||
expect(task.getFirstDayNotConsolidated()).andReturn(start).anyTimes();
|
||||
replay(task);
|
||||
}
|
||||
|
||||
private void givenSpecificResourceAllocation(LocalDate start, LocalDate end) {
|
||||
givenSpecificResourceAllocation(IntraDayDate.startOfDay(start),
|
||||
IntraDayDate.startOfDay(end));
|
||||
}
|
||||
|
||||
private void givenSpecificResourceAllocation(IntraDayDate start,
|
||||
IntraDayDate end) {
|
||||
givenWorker();
|
||||
givenTask(start, end);
|
||||
specificResourceAllocation = SpecificResourceAllocation.create(task);
|
||||
|
|
@ -375,7 +378,35 @@ public class SpecificResourceAllocationTest {
|
|||
.getAmount().compareTo(original.getAmount()) > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("serial")
|
||||
public void theResourcesPerDayAreTheOnesSpecifiedEvenIfInTheLastDayNoAllocationCanBeDone() {
|
||||
final LocalDate start = new LocalDate(2000, 2, 4);
|
||||
givenResourceCalendar(8, new HashMap<LocalDate, Integer>() {
|
||||
{
|
||||
put(start.plusDays(3), 0);
|
||||
}
|
||||
});
|
||||
givenSpecificResourceAllocation(start, 4);
|
||||
specificResourceAllocation.until(start.plusDays(4)).allocate(
|
||||
ResourcesPerDay.amount(1));
|
||||
assertThat(specificResourceAllocation.getResourcesPerDay(),
|
||||
equalTo(ResourcesPerDay.amount(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theResourcesPerDayAreTheOnesSpecifiedEvenIfTheStartIsInTheMiddleOfTheDay() {
|
||||
final IntraDayDate start = IntraDayDate.create(
|
||||
new LocalDate(2000, 2, 4), hours(4));
|
||||
givenResourceCalendarAlwaysReturning(8);
|
||||
IntraDayDate end = IntraDayDate.startOfDay(start.getDate().plusDays(4));
|
||||
givenSpecificResourceAllocation(start, end);
|
||||
specificResourceAllocation.until(end.asExclusiveEnd()).allocate(
|
||||
ResourcesPerDay.amount(1));
|
||||
assertThat(specificResourceAllocation.getResourcesPerDay(),
|
||||
equalTo(ResourcesPerDay.amount(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theHoursAreDistributedTakingIntoAccountTheWorkableHours() {
|
||||
final LocalDate start = new LocalDate(2000, 2, 4);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue