use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class BasicHolidayStrategyTest method whenAHolidayFallsOnDateTheDateShouldBeAdjusted.
@Test
public void whenAHolidayFallsOnDateTheDateShouldBeAdjusted() {
// setup
List<Holiday> upcomingHolidays = Arrays.asList(holiday);
holidayStrategy = new BasicHolidayStrategy(upcomingHolidays, workingDays, scheduledEvent);
DateTime firstOfNextMonth = new DateTime().plusMonths(1).withDayOfMonth(1).toDateMidnight().toDateTime();
// stubbing
when(holiday.encloses(firstOfNextMonth.toDate())).thenReturn(true);
when(holiday.adjust(firstOfNextMonth, workingDays, scheduledEvent)).thenReturn(firstOfNextMonth.plusDays(1));
// exercise test
DateTime adjustedDate = holidayStrategy.adjust(firstOfNextMonth);
assertThat(adjustedDate, is(firstOfNextMonth.plusDays(1)));
}
use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class BasicHolidayStrategyTest method whenAHolidayAdjustmentCausesAdjustedDateToFallOnAnotherHolidayTheDateShouldAgainBeAdjustedForSubsequentHoliday.
@Test
public void whenAHolidayAdjustmentCausesAdjustedDateToFallOnAnotherHolidayTheDateShouldAgainBeAdjustedForSubsequentHoliday() {
// setup
List<Holiday> upcomingHolidays = Arrays.asList(holiday, holiday2);
holidayStrategy = new BasicHolidayStrategy(upcomingHolidays, workingDays, scheduledEvent);
DateTime firstOfNextMonth = new DateTime().plusMonths(1).withDayOfMonth(1).toDateMidnight().toDateTime();
DateTime secondOfNextMonth = firstOfNextMonth.plusDays(1);
when(holiday.encloses(firstOfNextMonth.toDate())).thenReturn(true);
when(holiday.adjust(firstOfNextMonth, workingDays, scheduledEvent)).thenReturn(secondOfNextMonth);
when(holiday2.encloses(secondOfNextMonth.toDate())).thenReturn(true);
when(holiday2.adjust(secondOfNextMonth, workingDays, scheduledEvent)).thenReturn(secondOfNextMonth.plusDays(1));
DateTime adjustedDate = holidayStrategy.adjust(firstOfNextMonth);
assertThat(adjustedDate, is(secondOfNextMonth.plusDays(1)));
}
use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class CalendarEventBuilder method build.
public CalendarEvent build() {
List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
List<Holiday> holidays = new ArrayList<Holiday>();
return new CalendarEvent(workingDays, holidays);
}
use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class HolidayDaoHibernateIntegrationTest method nextDayRepaymentIsFutureRepaymentHoliday.
@Test
@Ignore
public void nextDayRepaymentIsFutureRepaymentHoliday() {
DateTime secondLastDayOfYear = new DateTime().withMonthOfYear(12).withDayOfMonth(30).toDateMidnight().toDateTime();
Holiday nextDayRepaymentHoliday = new HolidayBuilder().from(secondLastDayOfYear).to(secondLastDayOfYear).withNextMeetingRule().build();
insertHoliday(nextDayRepaymentHoliday);
Assert.assertTrue(holidayDao.isFutureRepaymentHoliday((short) 1, secondLastDayOfYear.toLocalDate().toString()));
}
use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class HolidayDaoHibernateIntegrationTest method sameDayHolidayIsNotFutureRepaymentHoliday.
@Test
@Ignore
public void sameDayHolidayIsNotFutureRepaymentHoliday() {
DateTime secondLastDayOfYear = new DateTime().withMonthOfYear(12).withDayOfMonth(30).toDateMidnight().toDateTime();
Holiday sameDayRepaymentHoliday = new HolidayBuilder().from(secondLastDayOfYear).to(secondLastDayOfYear).withSameDayAsRule().build();
insertHoliday(sameDayRepaymentHoliday);
Assert.assertFalse(holidayDao.isFutureRepaymentHoliday((short) 1, secondLastDayOfYear.toLocalDate().toString()));
}
Aggregations