use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class HolidayAndWorkingDaysScheduledDateGenerationTest method canGenerateScheduledDates.
@Test
public void canGenerateScheduledDates() {
DateTime lastScheduledDate = DayOfWeek.mondayMidnight();
ScheduledEvent recurringEvent = new ScheduledEventBuilder().every(1).weeks().on(DayOfWeek.monday()).build();
List<DateTime> scheduledDates = scheduleGeneration.generateScheduledDates(10, lastScheduledDate, recurringEvent, false);
assertThat(scheduledDates.size(), is(notNullValue()));
assertThat(scheduledDates.size(), is(10));
}
use of org.mifos.domain.builders.ScheduledEventBuilder 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)));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class HolidayAndWorkingDaysScheduledDateGenerationTest method canGenerateScheduledDatesThatMatchScheduledEventBasedOnLastScheduledDate.
@Test
public void canGenerateScheduledDatesThatMatchScheduledEventBasedOnLastScheduledDate() {
DateTime lastScheduledDate = DayOfWeek.mondayMidnight();
ScheduledEvent recurringEvent = new ScheduledEventBuilder().every(1).weeks().on(DayOfWeek.monday()).build();
List<DateTime> scheduledDates = scheduleGeneration.generateScheduledDates(10, lastScheduledDate, recurringEvent, false);
assertThat(scheduledDates.get(0), is(lastScheduledDate));
assertThat(scheduledDates.get(1), is(DayOfWeek.oneWeekFrom(lastScheduledDate)));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class MonthlyOnDateScheduledEventTest method canRollForwardDateToNextMonthToMatchDayOfMonthWhenDayOfMonthHasBeingPast.
@Test
public void canRollForwardDateToNextMonthToMatchDayOfMonthWhenDayOfMonthHasBeingPast() {
scheduledEvent = new ScheduledEventBuilder().every(1).months().onDayOfMonth(3).build();
DateTime fifthDayOfMonth = new DateTime().plusMonths(1).withDayOfMonth(5).toDateMidnight().toDateTime();
DateTime result = scheduledEvent.nearestMatchingDateBeginningAt(fifthDayOfMonth);
assertThat(result, is(fifthDayOfMonth.plusMonths(1).minusDays(2)));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class MonthlyOnWeekAndWeekDayScheduledEventTest method canRollForwardDateToMatchWeekOfMonthAndDayOfWeekWhenStartingOneWeekAndDayAhead.
@Test
public void canRollForwardDateToMatchWeekOfMonthAndDayOfWeekWhenStartingOneWeekAndDayAhead() {
scheduledEvent = new ScheduledEventBuilder().every(1).months().onWeekOfMonth(1).on(DayOfWeek.tuesday()).build();
DateTime wednesday7thOfApril = new DateTime().withDayOfMonth(7).withMonthOfYear(4).withYear(2010).withDayOfWeek(DayOfWeek.wednesday()).toDateMidnight().toDateTime();
DateTime result = scheduledEvent.nearestMatchingDateBeginningAt(wednesday7thOfApril);
assertThat(result, is(tuesdayOnFirstWeekOneMonthFrom(wednesday7thOfApril)));
}
Aggregations