use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class MonthlyOnWeekAndWeekDayScheduledEventTest method canRollForwardDateTwoMonthsToMatchWeekOfMonthAndDayOfWeekWhenStartingOneWeekAndDayAhead.
@Test
public void canRollForwardDateTwoMonthsToMatchWeekOfMonthAndDayOfWeekWhenStartingOneWeekAndDayAhead() {
scheduledEvent = new ScheduledEventBuilder().every(2).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).plusMonths(1)));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class ScheduledEventTest method numberOfEventsRollingUpToThisMasterEveryTwoSlaveEveryOne.
@Test
public void numberOfEventsRollingUpToThisMasterEveryTwoSlaveEveryOne() {
ScheduledEvent master = new ScheduledEventBuilder().every(2).weeks().build();
ScheduledEvent slave = new ScheduledEventBuilder().every(1).weeks().build();
assertThat(master.numberOfEventsRollingUpToThis(slave, 1), is(1));
assertThat(master.numberOfEventsRollingUpToThis(slave, 2), is(2));
assertThat(master.numberOfEventsRollingUpToThis(slave, 3), is(2));
assertThat(master.numberOfEventsRollingUpToThis(slave, 4), is(2));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class ScheduledEventTest method numberOfEventsRollingUpToThisShouldThrowExceptionWhenInstallmentIsZero.
@Test(expected = IllegalArgumentException.class)
public void numberOfEventsRollingUpToThisShouldThrowExceptionWhenInstallmentIsZero() {
ScheduledEvent master = new ScheduledEventBuilder().every(1).weeks().build();
ScheduledEvent slave = new ScheduledEventBuilder().every(1).weeks().build();
master.numberOfEventsRollingUpToThis(slave, 0);
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class WeeklyScheduledEventTest method canRollForwardDateToNextNearestDateMatchingSchedule.
@Test
public void canRollForwardDateToNextNearestDateMatchingSchedule() {
scheduledEvent = new ScheduledEventBuilder().every(1).weeks().on(DayOfWeek.wednesday()).build();
DateTime monday = DayOfWeek.mondayMidnight();
DateTime result = scheduledEvent.nextEventDateAfter(monday);
assertThat(result, is(monday.plusDays(9)));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class HolidayAndWorkingDaysScheduledDateGenerationTest method canGenerateAllScheduledDatesThatMatchScheduleEvent.
@Test
public void canGenerateAllScheduledDatesThatMatchScheduleEvent() {
DateTime lastScheduledDate = DayOfWeek.mondayMidnight();
DateTime dayAfterLastScheduledDate = DayOfWeek.tuesdayMidnight();
ScheduledEvent scheduleEvent = new ScheduledEventBuilder().every(1).weeks().on(DayOfWeek.monday()).build();
List<DateTime> scheduledDates = scheduleGeneration.generateScheduledDates(10, dayAfterLastScheduledDate, scheduleEvent, false);
DateTime lastDate = lastScheduledDate;
for (DateTime generatedDate : scheduledDates) {
assertThat(generatedDate, is(DayOfWeek.oneWeekFrom(lastDate)));
lastDate = generatedDate;
}
}
Aggregations