Search in sources :

Example 1 with HolidayAndWorkingDaysScheduledDateGeneration

use of org.mifos.schedule.internal.HolidayAndWorkingDaysScheduledDateGeneration in project head by mifos.

the class HolidayAndWorkingDaysScheduledDateGenerationTest method givenAHolidayFallsOnScheduledDateAndAdjustmentRuleForHolidayIsNextMeetingShouldGenerateScheduledDatesThatTakeIntoAccountHolidaysAndDuplicateAnyScheduledDatesThatOccurOnHoliday.

@Test
public void givenAHolidayFallsOnScheduledDateAndAdjustmentRuleForHolidayIsNextMeetingShouldGenerateScheduledDatesThatTakeIntoAccountHolidaysAndDuplicateAnyScheduledDatesThatOccurOnHoliday() {
    // setup
    DateTime fourthOfJuly = new DateTime().plusYears(1).withMonthOfYear(7).withDayOfMonth(4).toDateMidnight().toDateTime();
    Holiday independenceDay = new HolidayBuilder().from(fourthOfJuly).to(fourthOfJuly.plusDays(3)).withNextMeetingRule().build();
    List<Holiday> upcomingHolidays = Arrays.asList(independenceDay);
    scheduleGeneration = new HolidayAndWorkingDaysScheduledDateGeneration(workingDays, upcomingHolidays);
    DateTime june29thNextYear = new DateTime().plusYears(1).withMonthOfYear(6).withDayOfMonth(29).toDateMidnight().toDateTime();
    DateTime startingFrom = june29thNextYear.minusDays(1);
    ScheduledEvent scheduleEvent = new ScheduledEventBuilder().every(1).weeks().on(june29thNextYear.getDayOfWeek()).build();
    // exercise test
    List<DateTime> scheduledDates = scheduleGeneration.generateScheduledDates(10, startingFrom, scheduleEvent, false);
    assertThat(scheduledDates.get(0), is(june29thNextYear));
    assertThat(scheduledDates.get(1), is(june29thNextYear.plusWeeks(2)));
    assertThat(scheduledDates.get(2), is(june29thNextYear.plusWeeks(2)));
}
Also used : HolidayAndWorkingDaysScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysScheduledDateGeneration) ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) Holiday(org.mifos.application.holiday.business.Holiday) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 2 with HolidayAndWorkingDaysScheduledDateGeneration

use of org.mifos.schedule.internal.HolidayAndWorkingDaysScheduledDateGeneration in project head by mifos.

the class HolidayAndWorkingDaysScheduledDateGenerationTest method setupAndInjectDependencies.

@Before
public void setupAndInjectDependencies() {
    workingDays = Arrays.asList(DayOfWeek.mondayAsDay(), DayOfWeek.tuesdayAsDay(), DayOfWeek.wednesdayAsDay(), DayOfWeek.thursdayAsDay(), DayOfWeek.fridayAsDay());
    List<Holiday> upcomingHolidays = new ArrayList<Holiday>();
    scheduleGeneration = new HolidayAndWorkingDaysScheduledDateGeneration(workingDays, upcomingHolidays);
}
Also used : HolidayAndWorkingDaysScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysScheduledDateGeneration) Holiday(org.mifos.application.holiday.business.Holiday) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Aggregations

Holiday (org.mifos.application.holiday.business.Holiday)2 HolidayAndWorkingDaysScheduledDateGeneration (org.mifos.schedule.internal.HolidayAndWorkingDaysScheduledDateGeneration)2 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1 Before (org.junit.Before)1 Test (org.junit.Test)1 HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)1 ScheduledEventBuilder (org.mifos.domain.builders.ScheduledEventBuilder)1