ItEr41S09RFSoporteRecursosVirtuaisItEr40S12: Renaming method and documenting it to show better its intent
This commit is contained in:
parent
f7461e2e82
commit
639b62485a
16 changed files with 85 additions and 78 deletions
|
|
@ -250,14 +250,14 @@ public class BaseCalendar extends BaseEntity implements IWorkHours {
|
|||
* calendar restrictions.
|
||||
*/
|
||||
public Integer getWorkableHours(Date date) {
|
||||
return getWorkableHours(new LocalDate(date));
|
||||
return getCapacityAt(new LocalDate(date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of workable hours for a specific date depending on the
|
||||
* calendar restrictions.
|
||||
*/
|
||||
public Integer getWorkableHours(LocalDate date) {
|
||||
public Integer getCapacityAt(LocalDate date) {
|
||||
CalendarException exceptionDay = getExceptionDay(date);
|
||||
if (exceptionDay != null) {
|
||||
return exceptionDay.getHours();
|
||||
|
|
@ -329,7 +329,7 @@ public class BaseCalendar extends BaseEntity implements IWorkHours {
|
|||
int total = 0;
|
||||
for (LocalDate current = init; current.compareTo(end) <= 0; current = current
|
||||
.plusDays(1)) {
|
||||
total += getWorkableHours(current);
|
||||
total += getCapacityAt(current);
|
||||
init = init.plusDays(1);
|
||||
}
|
||||
return total;
|
||||
|
|
@ -442,7 +442,7 @@ public class BaseCalendar extends BaseEntity implements IWorkHours {
|
|||
return DayType.ANCESTOR_EXCEPTION;
|
||||
}
|
||||
|
||||
if (getWorkableHours(date) == 0) {
|
||||
if (getCapacityAt(date) == 0) {
|
||||
return DayType.ZERO_HOURS;
|
||||
}
|
||||
|
||||
|
|
@ -640,7 +640,7 @@ public class BaseCalendar extends BaseEntity implements IWorkHours {
|
|||
Set<LocalDate> result = new HashSet<LocalDate>();
|
||||
for (LocalDate current = init; current.compareTo(end) <= 0; current = current
|
||||
.plusDays(1)) {
|
||||
if (getWorkableHours(current) == 0) {
|
||||
if (getCapacityAt(current) == 0) {
|
||||
result.add(current);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,18 +43,18 @@ public abstract class CombinedWorkHours implements IWorkHours {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer getWorkableHours(LocalDate date) {
|
||||
public Integer getCapacityAt(LocalDate date) {
|
||||
Integer current = null;
|
||||
for (IWorkHours workHour : workHours) {
|
||||
current = current == null ? workHours(workHour, date)
|
||||
: updateWorkHours(current, workHour, date);
|
||||
current = current == null ? capacity(workHour, date)
|
||||
: updateCapacity(current, workHour, date);
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
protected abstract Integer workHours(IWorkHours workHour, LocalDate date);
|
||||
protected abstract Integer capacity(IWorkHours workHour, LocalDate date);
|
||||
|
||||
protected abstract Integer updateWorkHours(Integer current,
|
||||
protected abstract Integer updateCapacity(Integer current,
|
||||
IWorkHours workHour, LocalDate date);
|
||||
|
||||
}
|
||||
|
|
@ -66,13 +66,13 @@ class Min extends CombinedWorkHours {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Integer updateWorkHours(Integer current, IWorkHours workHour,
|
||||
protected Integer updateCapacity(Integer current, IWorkHours workHour,
|
||||
LocalDate date) {
|
||||
return Math.min(current, workHour.getWorkableHours(date));
|
||||
return Math.min(current, workHour.getCapacityAt(date));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer workHours(IWorkHours workHour, LocalDate date) {
|
||||
return workHour.getWorkableHours(date);
|
||||
protected Integer capacity(IWorkHours workHour, LocalDate date) {
|
||||
return workHour.getCapacityAt(date);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,13 @@ import org.joda.time.LocalDate;
|
|||
|
||||
public interface IWorkHours {
|
||||
|
||||
public Integer getWorkableHours(LocalDate date);
|
||||
/**
|
||||
* Calculates the capacity at a given date. It means all the hours that
|
||||
* could be worked without having overtime
|
||||
* @param date
|
||||
* the date at which the capacity is calculated
|
||||
* @return the capacity at which the resource can work
|
||||
*/
|
||||
public Integer getCapacityAt(LocalDate date);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,11 +59,11 @@ public class ResourceCalendar extends BaseCalendar {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer getWorkableHours(LocalDate date) {
|
||||
public Integer getCapacityAt(LocalDate date) {
|
||||
if (!isActive(date)) {
|
||||
return 0;
|
||||
}
|
||||
return multiplyByCapacity(super.getWorkableHours(date));
|
||||
return multiplyByCapacity(super.getCapacityAt(date));
|
||||
}
|
||||
|
||||
private Integer multiplyByCapacity(Integer workableHours) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class SameWorkHoursEveryDay implements IWorkHours {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer getWorkableHours(LocalDate date) {
|
||||
public Integer getCapacityAt(LocalDate date) {
|
||||
return hours;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class HoursDistributor {
|
|||
Resource resource = resources.get(i);
|
||||
IWorkHours workHoursForResource = workHours.get(i);
|
||||
int alreadyAssignedHours = resource.getAssignedHours(day);
|
||||
Integer workableHours = workHoursForResource.getWorkableHours(day);
|
||||
Integer workableHours = workHoursForResource.getCapacityAt(day);
|
||||
// a resource would have a zero share if all it's hours for a
|
||||
// given day are filled
|
||||
shares.add(new Share(alreadyAssignedHours - workableHours));
|
||||
|
|
|
|||
|
|
@ -425,7 +425,7 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
List<Share> shares = new ArrayList<Share>();
|
||||
for (LocalDate day : days) {
|
||||
shares.add(new Share(-getWorkHoursPerDay()
|
||||
.getWorkableHours(day)));
|
||||
.getCapacityAt(day)));
|
||||
}
|
||||
ShareDivision original = ShareDivision.create(shares);
|
||||
ShareDivision newShare = original.plus(hoursToSum);
|
||||
|
|
@ -450,7 +450,7 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
|
||||
final int calculateTotalToDistribute(LocalDate day,
|
||||
ResourcesPerDay resourcesPerDay) {
|
||||
Integer workableHours = getWorkHoursPerDay().getWorkableHours(day);
|
||||
Integer workableHours = getWorkHoursPerDay().getCapacityAt(day);
|
||||
return resourcesPerDay.asHoursGivenResourceWorkingDayOf(workableHours);
|
||||
}
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
int sumTotalHours = 0;
|
||||
int sumWorkableHours = 0;
|
||||
for (Entry<LocalDate, List<DayAssignment>> entry : byDay.entrySet()) {
|
||||
sumWorkableHours += getWorkHoursPerDay().getWorkableHours(
|
||||
sumWorkableHours += getWorkHoursPerDay().getCapacityAt(
|
||||
entry.getKey());
|
||||
sumTotalHours += getAssignedHours(entry.getValue());
|
||||
}
|
||||
|
|
@ -478,12 +478,12 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
private IWorkHours getTaskWorkHoursLimit() {
|
||||
return new IWorkHours() {
|
||||
@Override
|
||||
public Integer getWorkableHours(LocalDate day) {
|
||||
public Integer getCapacityAt(LocalDate day) {
|
||||
if (getTaskCalendar() == null) {
|
||||
return SameWorkHoursEveryDay.getDefaultWorkingDay()
|
||||
.getWorkableHours(day);
|
||||
.getCapacityAt(day);
|
||||
} else {
|
||||
return getTaskCalendar().getWorkableHours(day);
|
||||
return getTaskCalendar().getCapacityAt(day);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -692,7 +692,7 @@ public abstract class Resource extends BaseEntity{
|
|||
final int days = Days.daysBetween(start, end).getDays();
|
||||
for (int i = 0; i < days; i++) {
|
||||
LocalDate current = start.plusDays(i);
|
||||
Integer workableHours = calendar.getWorkableHours(current);
|
||||
Integer workableHours = calendar.getCapacityAt(current);
|
||||
if (workableHours != null) {
|
||||
sum += workableHours;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,10 +116,10 @@ public class BaseCalendarTest {
|
|||
public void testGetWorkableHoursBasic() {
|
||||
BaseCalendar calendar = createBasicCalendar();
|
||||
|
||||
int wednesdayHours = calendar.getWorkableHours(WEDNESDAY_LOCAL_DATE);
|
||||
int wednesdayHours = calendar.getCapacityAt(WEDNESDAY_LOCAL_DATE);
|
||||
assertThat(wednesdayHours, equalTo(8));
|
||||
|
||||
int sundayHours = calendar.getWorkableHours(SUNDAY_LOCAL_DATE);
|
||||
int sundayHours = calendar.getCapacityAt(SUNDAY_LOCAL_DATE);
|
||||
assertThat(sundayHours, equalTo(0));
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ public class BaseCalendarTest {
|
|||
public void testGetWorkableHoursChristmas() {
|
||||
BaseCalendar calendar = createChristmasCalendar();
|
||||
|
||||
int hours = calendar.getWorkableHours(CHRISTMAS_DAY_LOCAL_DATE);
|
||||
int hours = calendar.getCapacityAt(CHRISTMAS_DAY_LOCAL_DATE);
|
||||
assertThat(hours, equalTo(0));
|
||||
}
|
||||
|
||||
|
|
@ -143,10 +143,10 @@ public class BaseCalendarTest {
|
|||
public void testGetWorkableHoursDerivedBasicCalendar() {
|
||||
BaseCalendar calendar = createBasicCalendar().newDerivedCalendar();
|
||||
|
||||
int wednesdayHours = calendar.getWorkableHours(WEDNESDAY_LOCAL_DATE);
|
||||
int wednesdayHours = calendar.getCapacityAt(WEDNESDAY_LOCAL_DATE);
|
||||
assertThat(wednesdayHours, equalTo(8));
|
||||
|
||||
int sundayHours = calendar.getWorkableHours(SUNDAY_LOCAL_DATE);
|
||||
int sundayHours = calendar.getCapacityAt(SUNDAY_LOCAL_DATE);
|
||||
assertThat(sundayHours, equalTo(0));
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ public class BaseCalendarTest {
|
|||
public void testGetWorkableHoursDerivedChristmasCalendar() {
|
||||
BaseCalendar calendar = createChristmasCalendar().newDerivedCalendar();
|
||||
|
||||
int hours = calendar.getWorkableHours(CHRISTMAS_DAY_LOCAL_DATE);
|
||||
int hours = calendar.getCapacityAt(CHRISTMAS_DAY_LOCAL_DATE);
|
||||
assertThat(hours, equalTo(0));
|
||||
}
|
||||
|
||||
|
|
@ -166,13 +166,13 @@ public class BaseCalendarTest {
|
|||
4, createCalendarExceptionType());
|
||||
calendar.addExceptionDay(day);
|
||||
|
||||
int mondayHours = calendar.getWorkableHours(MONDAY_LOCAL_DATE);
|
||||
int mondayHours = calendar.getCapacityAt(MONDAY_LOCAL_DATE);
|
||||
assertThat(mondayHours, equalTo(8));
|
||||
|
||||
int wednesdayHours = calendar.getWorkableHours(WEDNESDAY_LOCAL_DATE);
|
||||
int wednesdayHours = calendar.getCapacityAt(WEDNESDAY_LOCAL_DATE);
|
||||
assertThat(wednesdayHours, equalTo(4));
|
||||
|
||||
int sundayHours = calendar.getWorkableHours(SUNDAY_LOCAL_DATE);
|
||||
int sundayHours = calendar.getCapacityAt(SUNDAY_LOCAL_DATE);
|
||||
assertThat(sundayHours, equalTo(0));
|
||||
}
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ public class BaseCalendarTest {
|
|||
CHRISTMAS_DAY_LOCAL_DATE, 4, createCalendarExceptionType());
|
||||
calendar.addExceptionDay(day);
|
||||
|
||||
int hours = calendar.getWorkableHours(CHRISTMAS_DAY_LOCAL_DATE);
|
||||
int hours = calendar.getCapacityAt(CHRISTMAS_DAY_LOCAL_DATE);
|
||||
assertThat(hours, equalTo(4));
|
||||
}
|
||||
|
||||
|
|
@ -262,15 +262,15 @@ public class BaseCalendarTest {
|
|||
calendar.setHours(Days.WEDNESDAY, 4);
|
||||
calendar.setHours(Days.SUNDAY, 4);
|
||||
|
||||
assertThat(calendar.getWorkableHours(WEDNESDAY_LOCAL_DATE), equalTo(4));
|
||||
assertThat(calendar.getCapacityAt(WEDNESDAY_LOCAL_DATE), equalTo(4));
|
||||
|
||||
assertThat(calendar
|
||||
.getWorkableHours(WEDNESDAY_LOCAL_DATE.minusWeeks(1)),
|
||||
.getCapacityAt(WEDNESDAY_LOCAL_DATE.minusWeeks(1)),
|
||||
equalTo(8));
|
||||
|
||||
assertThat(calendar.getWorkableHours(SUNDAY_LOCAL_DATE), equalTo(4));
|
||||
assertThat(calendar.getCapacityAt(SUNDAY_LOCAL_DATE), equalTo(4));
|
||||
|
||||
assertThat(calendar.getWorkableHours(SUNDAY_LOCAL_DATE.minusWeeks(1)),
|
||||
assertThat(calendar.getCapacityAt(SUNDAY_LOCAL_DATE.minusWeeks(1)),
|
||||
equalTo(0));
|
||||
}
|
||||
|
||||
|
|
@ -282,14 +282,14 @@ public class BaseCalendarTest {
|
|||
calendar.setHours(Days.MONDAY, 1);
|
||||
calendar.setHours(Days.SUNDAY, 2);
|
||||
|
||||
assertThat(calendar.getWorkableHours(MONDAY_LOCAL_DATE), equalTo(1));
|
||||
assertThat(calendar.getCapacityAt(MONDAY_LOCAL_DATE), equalTo(1));
|
||||
|
||||
assertThat(calendar.getWorkableHours(SUNDAY_LOCAL_DATE), equalTo(2));
|
||||
assertThat(calendar.getCapacityAt(SUNDAY_LOCAL_DATE), equalTo(2));
|
||||
|
||||
assertThat(calendar
|
||||
.getWorkableHours(MONDAY_LOCAL_DATE.minusWeeks(1)), equalTo(8));
|
||||
.getCapacityAt(MONDAY_LOCAL_DATE.minusWeeks(1)), equalTo(8));
|
||||
|
||||
assertThat(calendar.getWorkableHours(MONDAY_LOCAL_DATE
|
||||
assertThat(calendar.getCapacityAt(MONDAY_LOCAL_DATE
|
||||
.minusDays(1)), equalTo(0));
|
||||
}
|
||||
|
||||
|
|
@ -334,10 +334,10 @@ public class BaseCalendarTest {
|
|||
createCalendarExceptionType());
|
||||
|
||||
assertThat(calendar
|
||||
.getWorkableHours(CHRISTMAS_DAY_LOCAL_DATE.plusYears(1)), equalTo(8));
|
||||
.getCapacityAt(CHRISTMAS_DAY_LOCAL_DATE.plusYears(1)), equalTo(8));
|
||||
|
||||
assertThat(calendar
|
||||
.getWorkableHours(CHRISTMAS_DAY_LOCAL_DATE), equalTo(0));
|
||||
.getCapacityAt(CHRISTMAS_DAY_LOCAL_DATE), equalTo(0));
|
||||
}
|
||||
|
||||
public static void setHoursForAllDays(BaseCalendar calendar, Integer hours) {
|
||||
|
|
@ -361,11 +361,11 @@ public class BaseCalendarTest {
|
|||
calendar.newVersion(FRIDAY_LOCAL_DATE);
|
||||
setHoursForAllDays(calendar, 2);
|
||||
|
||||
assertThat(calendar.getWorkableHours(MONDAY_LOCAL_DATE), equalTo(8));
|
||||
assertThat(calendar.getCapacityAt(MONDAY_LOCAL_DATE), equalTo(8));
|
||||
|
||||
assertThat(calendar.getWorkableHours(WEDNESDAY_LOCAL_DATE), equalTo(4));
|
||||
assertThat(calendar.getCapacityAt(WEDNESDAY_LOCAL_DATE), equalTo(4));
|
||||
|
||||
assertThat(calendar.getWorkableHours(FRIDAY_LOCAL_DATE), equalTo(2));
|
||||
assertThat(calendar.getCapacityAt(FRIDAY_LOCAL_DATE), equalTo(2));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -379,15 +379,15 @@ public class BaseCalendarTest {
|
|||
calendar.newVersion(WEDNESDAY_LOCAL_DATE);
|
||||
setHoursForAllDays(calendar, 2);
|
||||
|
||||
assertThat(baseCalendar.getWorkableHours(MONDAY_LOCAL_DATE), equalTo(8));
|
||||
assertThat(baseCalendar.getCapacityAt(MONDAY_LOCAL_DATE), equalTo(8));
|
||||
|
||||
assertThat(calendar.getWorkableHours(MONDAY_LOCAL_DATE), equalTo(4));
|
||||
assertThat(calendar.getCapacityAt(MONDAY_LOCAL_DATE), equalTo(4));
|
||||
|
||||
assertThat(baseCalendar.getWorkableHours(FRIDAY_LOCAL_DATE), equalTo(8));
|
||||
assertThat(baseCalendar.getCapacityAt(FRIDAY_LOCAL_DATE), equalTo(8));
|
||||
|
||||
assertThat(calendar.getWorkableHours(FRIDAY_LOCAL_DATE), equalTo(2));
|
||||
assertThat(calendar.getCapacityAt(FRIDAY_LOCAL_DATE), equalTo(2));
|
||||
|
||||
assertThat(calendar.getWorkableHours(CHRISTMAS_DAY_LOCAL_DATE),
|
||||
assertThat(calendar.getCapacityAt(CHRISTMAS_DAY_LOCAL_DATE),
|
||||
equalTo(0));
|
||||
}
|
||||
|
||||
|
|
@ -414,7 +414,7 @@ public class BaseCalendarTest {
|
|||
|
||||
private void thenForAllDaysReturnsZero() {
|
||||
for (LocalDate localDate : DAYS_OF_A_WEEK_EXAMPLE) {
|
||||
assertThat(calendarFixture.getWorkableHours(localDate), equalTo(0));
|
||||
assertThat(calendarFixture.getCapacityAt(localDate), equalTo(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -513,7 +513,7 @@ public class BaseCalendarTest {
|
|||
calendar.setParent(parent);
|
||||
|
||||
assertThat(calendar.getParent(), equalTo(parent));
|
||||
assertThat(calendar.getWorkableHours(CHRISTMAS_DAY_LOCAL_DATE),
|
||||
assertThat(calendar.getCapacityAt(CHRISTMAS_DAY_LOCAL_DATE),
|
||||
equalTo(0));
|
||||
}
|
||||
|
||||
|
|
@ -523,7 +523,7 @@ public class BaseCalendarTest {
|
|||
BaseCalendar derived = calendar.newDerivedCalendar();
|
||||
BaseCalendar copy = derived.newCopy();
|
||||
|
||||
assertThat(copy.getWorkableHours(CHRISTMAS_DAY_LOCAL_DATE), equalTo(0));
|
||||
assertThat(copy.getCapacityAt(CHRISTMAS_DAY_LOCAL_DATE), equalTo(0));
|
||||
assertThat(copy.getParent(), equalTo(calendar));
|
||||
assertThat(copy.getCalendarDataVersions().size(), equalTo(1));
|
||||
}
|
||||
|
|
@ -551,10 +551,10 @@ public class BaseCalendarTest {
|
|||
assertThat(calendar.getParent(MONDAY_LOCAL_DATE),
|
||||
equalTo(parent1));
|
||||
|
||||
assertThat(calendar.getWorkableHours(MONDAY_LOCAL_DATE),
|
||||
assertThat(calendar.getCapacityAt(MONDAY_LOCAL_DATE),
|
||||
equalTo(8));
|
||||
|
||||
assertThat(calendar.getWorkableHours(FRIDAY_LOCAL_DATE),
|
||||
assertThat(calendar.getCapacityAt(FRIDAY_LOCAL_DATE),
|
||||
equalTo(4));
|
||||
}
|
||||
|
||||
|
|
@ -568,10 +568,10 @@ public class BaseCalendarTest {
|
|||
calendar.addExceptionDay(CalendarException.create(FRIDAY_LOCAL_DATE, 0,
|
||||
createCalendarExceptionType()));
|
||||
|
||||
assertThat(calendar.getWorkableHours(MONDAY_LOCAL_DATE),
|
||||
assertThat(calendar.getCapacityAt(MONDAY_LOCAL_DATE),
|
||||
equalTo(0));
|
||||
|
||||
assertThat(calendar.getWorkableHours(FRIDAY_LOCAL_DATE),
|
||||
assertThat(calendar.getCapacityAt(FRIDAY_LOCAL_DATE),
|
||||
equalTo(0));
|
||||
|
||||
assertThat(calendar.getOwnExceptions().size(), equalTo(2));
|
||||
|
|
|
|||
|
|
@ -55,13 +55,13 @@ public class CombinedWorkHoursTest {
|
|||
public void returnsTheMinOfCalendars() {
|
||||
IWorkHours minOf = CombinedWorkHours
|
||||
.minOf(hours(4), hours(2), hours(7));
|
||||
Integer hours = minOf.getWorkableHours(new LocalDate(2000, 3, 3));
|
||||
Integer hours = minOf.getCapacityAt(new LocalDate(2000, 3, 3));
|
||||
assertThat(hours, equalTo(2));
|
||||
}
|
||||
|
||||
private IWorkHours hours(int hours) {
|
||||
IWorkHours result = createNiceMock(IWorkHours.class);
|
||||
expect(result.getWorkableHours(isA(LocalDate.class))).andReturn(hours);
|
||||
expect(result.getCapacityAt(isA(LocalDate.class))).andReturn(hours);
|
||||
replay(result);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ public class ResourceCalendarTest {
|
|||
public void testGetWorkableHours() {
|
||||
ResourceCalendar calendar = createBasicResourceCalendar();
|
||||
|
||||
assertThat(calendar.getWorkableHours(PAST), equalTo(0));
|
||||
assertThat(calendar.getWorkableHours(FUTURE), equalTo(8));
|
||||
assertThat(calendar.getCapacityAt(PAST), equalTo(0));
|
||||
assertThat(calendar.getCapacityAt(FUTURE), equalTo(8));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ public class GenericResourceAllocationTest {
|
|||
BaseCalendar baseCalendar = createNiceMock(BaseCalendar.class);
|
||||
expect(baseCalendar.getWorkableHours(isA(Date.class))).andReturn(
|
||||
hoursPerDay).anyTimes();
|
||||
expect(baseCalendar.getWorkableHours(isA(LocalDate.class))).andReturn(
|
||||
expect(baseCalendar.getCapacityAt(isA(LocalDate.class))).andReturn(
|
||||
hoursPerDay).anyTimes();
|
||||
replay(baseCalendar);
|
||||
this.baseCalendar = baseCalendar;
|
||||
|
|
@ -319,7 +319,7 @@ public class GenericResourceAllocationTest {
|
|||
public void allocatingSeveralResourcesPerDayHavingJustOneResourceProducesOvertime() {
|
||||
LocalDate start = new LocalDate(2006, 10, 5);
|
||||
final Integer standardHoursPerDay = SameWorkHoursEveryDay
|
||||
.getDefaultWorkingDay().getWorkableHours(start);
|
||||
.getDefaultWorkingDay().getCapacityAt(start);
|
||||
final int TASK_DURATION_DAYS = 4;
|
||||
givenBaseCalendarWithoutExceptions(standardHoursPerDay);
|
||||
givenTaskWithStartAndEnd(toInterval(start, Period
|
||||
|
|
@ -360,7 +360,7 @@ public class GenericResourceAllocationTest {
|
|||
LocalDate start = new LocalDate(2006, 10, 5);
|
||||
final int TASK_DURATION_DAYS = 1;
|
||||
final Integer defaultWorkableHours = SameWorkHoursEveryDay
|
||||
.getDefaultWorkingDay().getWorkableHours(start);
|
||||
.getDefaultWorkingDay().getCapacityAt(start);
|
||||
givenBaseCalendarWithoutExceptions(defaultWorkableHours);
|
||||
givenTaskWithStartAndEnd(toInterval(start, Period
|
||||
.days(TASK_DURATION_DAYS)));
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class SpecificResourceAllocationTest {
|
|||
|
||||
private void givenResourceCalendarAlwaysReturning(int hours) {
|
||||
this.calendar = createNiceMock(ResourceCalendar.class);
|
||||
expect(this.calendar.getWorkableHours(isA(LocalDate.class))).andReturn(
|
||||
expect(this.calendar.getCapacityAt(isA(LocalDate.class))).andReturn(
|
||||
hours).anyTimes();
|
||||
expect(this.calendar.getWorkableHours(isA(Date.class)))
|
||||
.andReturn(hours).anyTimes();
|
||||
|
|
@ -76,7 +76,7 @@ public class SpecificResourceAllocationTest {
|
|||
|
||||
private void givenResourceCalendar(final int defaultAnswer, final Map<LocalDate, Integer> answersForDates){
|
||||
this.calendar = createNiceMock(ResourceCalendar.class);
|
||||
expect(this.calendar.getWorkableHours(isA(LocalDate.class))).andAnswer(new IAnswer<Integer>() {
|
||||
expect(this.calendar.getCapacityAt(isA(LocalDate.class))).andAnswer(new IAnswer<Integer>() {
|
||||
|
||||
@Override
|
||||
public Integer answer() throws Throwable {
|
||||
|
|
|
|||
|
|
@ -123,10 +123,10 @@ public abstract class ChartFiller implements IChartFiller {
|
|||
int result = 0;
|
||||
ResourceCalendar calendar = resource.getCalendar();
|
||||
if (calendar != null) {
|
||||
result += calendar.getWorkableHours(day);
|
||||
result += calendar.getCapacityAt(day);
|
||||
} else {
|
||||
result += SameWorkHoursEveryDay.getDefaultWorkingDay()
|
||||
.getWorkableHours(day);
|
||||
.getCapacityAt(day);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -625,9 +625,9 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
BaseCalendar calendar = resource.getCalendar();
|
||||
|
||||
int workableHours = SameWorkHoursEveryDay
|
||||
.getDefaultWorkingDay().getWorkableHours(day);
|
||||
.getDefaultWorkingDay().getCapacityAt(day);
|
||||
if (calendar != null) {
|
||||
workableHours = calendar.getWorkableHours(day);
|
||||
workableHours = calendar.getCapacityAt(day);
|
||||
}
|
||||
|
||||
int assignedHours = dayAssignmentGrouped.get(day).get(
|
||||
|
|
@ -657,9 +657,9 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
BaseCalendar calendar = resource.getCalendar();
|
||||
|
||||
int workableHours = SameWorkHoursEveryDay
|
||||
.getDefaultWorkingDay().getWorkableHours(day);
|
||||
.getDefaultWorkingDay().getCapacityAt(day);
|
||||
if (calendar != null) {
|
||||
workableHours = calendar.getWorkableHours(day);
|
||||
workableHours = calendar.getCapacityAt(day);
|
||||
}
|
||||
|
||||
int assignedHours = dayAssignmentGrouped.get(day).get(
|
||||
|
|
|
|||
|
|
@ -853,9 +853,9 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
BaseCalendar calendar = resource.getCalendar();
|
||||
|
||||
int workableHours = SameWorkHoursEveryDay.getDefaultWorkingDay()
|
||||
.getWorkableHours(day);
|
||||
.getCapacityAt(day);
|
||||
if (calendar != null) {
|
||||
workableHours = calendar.getWorkableHours(day);
|
||||
workableHours = calendar.getCapacityAt(day);
|
||||
}
|
||||
|
||||
return workableHours;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue