return createCalendar(klass, capacity, 1);
}
private <T extends BaseCalendar> T createCalendar(Class<T> klass,
final Capacity capacity, int units) {
final Capacity capacityMultipliedByUnits = capacity.multiplyBy(units);
BaseCalendar baseCalendar = createNiceMock(klass);
expect(baseCalendar.getCapacityOn(isA(PartialDay.class))).andAnswer(
new IAnswer<EffortDuration>() {
@Override
public EffortDuration answer() throws Throwable {
PartialDay day = (PartialDay) getCurrentArguments()[0];
return day.limitWorkingDay(capacityMultipliedByUnits
.getStandardEffort());
}
}).anyTimes();
expect(baseCalendar.isActive(isA(LocalDate.class))).andReturn(true)
.anyTimes();
expect(baseCalendar.canWorkOn(isA(LocalDate.class))).andReturn(true)
.anyTimes();
expect(baseCalendar.getAvailability()).andReturn(
AvailabilityTimeLine.allValid()).anyTimes();
IAnswer<EffortDuration> durationAnswer = new IAnswer<EffortDuration>() {
@Override
public EffortDuration answer() throws Throwable {
PartialDay day = (PartialDay) getCurrentArguments()[0];
ResourcesPerDay resourcesPerDay = (ResourcesPerDay) getCurrentArguments()[1];
return capacityMultipliedByUnits.limitDuration(resourcesPerDay
.asDurationGivenWorkingDayOf(day.limitWorkingDay(capacity
.getStandardEffort())));
}
};
expect(