use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class MonthlyOnDateScheduledEventTest method canRollForwardDateToMatchDayOfMonthWhenCurrentDayOfMonthIsBehind.
@Test
public void canRollForwardDateToMatchDayOfMonthWhenCurrentDayOfMonthIsBehind() {
scheduledEvent = new ScheduledEventBuilder().every(1).months().onDayOfMonth(3).build();
DateTime firstOfNextMonth = new DateTime().plusMonths(1).withDayOfMonth(1).toDateMidnight().toDateTime();
DateTime result = scheduledEvent.nearestMatchingDateBeginningAt(firstOfNextMonth);
assertThat(result, is(firstOfNextMonth.plusDays(2)));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class MonthlyOnDateScheduledEventTest method canRollForwardDateTwoMonthsToMatchDayOfMonthWhenDayOfMonthHasBeingPast.
@Test
public void canRollForwardDateTwoMonthsToMatchDayOfMonthWhenDayOfMonthHasBeingPast() {
scheduledEvent = new ScheduledEventBuilder().every(2).months().onDayOfMonth(3).build();
DateTime fifthDayOfMonth = new DateTime().plusMonths(1).withDayOfMonth(5).toDateMidnight().toDateTime();
DateTime result = scheduledEvent.nearestMatchingDateBeginningAt(fifthDayOfMonth);
assertThat(result, is(fifthDayOfMonth.plusMonths(2).minusDays(2)));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class MonthlyOnWeekAndWeekDayScheduledEventTest method canRollForwardDateToMatchWeekOfMonthAndDayOfWeekWhenStartingOneWeekAndDayBehind.
@Test
public void canRollForwardDateToMatchWeekOfMonthAndDayOfWeekWhenStartingOneWeekAndDayBehind() {
scheduledEvent = new ScheduledEventBuilder().every(1).months().onWeekOfMonth(2).on(DayOfWeek.tuesday()).build();
DateTime firstMondayOfMay2010 = new DateTime().withYear(2010).withMonthOfYear(5).withDayOfMonth(3).toDateMidnight().toDateTime();
DateTime result = scheduledEvent.nearestMatchingDateBeginningAt(firstMondayOfMay2010);
assertThat(result, is(firstMondayOfMay2010.plusDays(1).plusWeeks(1)));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class MonthlyOnWeekAndWeekDayScheduledEventTest method canRollForwardDateToMatchWeekOfMonthAndDayOfWeekWhenStartingInSameWeekButOneDayBehind.
@Test
public void canRollForwardDateToMatchWeekOfMonthAndDayOfWeekWhenStartingInSameWeekButOneDayBehind() {
scheduledEvent = new ScheduledEventBuilder().every(1).months().onWeekOfMonth(1).on(DayOfWeek.tuesday()).build();
DateTime firstMondayOfMay2010 = new DateTime().withYear(2010).withMonthOfYear(5).withDayOfMonth(3).toDateMidnight().toDateTime();
DateTime result = scheduledEvent.nearestMatchingDateBeginningAt(firstMondayOfMay2010);
assertThat(result, is(firstMondayOfMay2010.plusDays(1)));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class ScheduledEventTest method numberOfEventsRollingUpToThisMasterEveryTwoSlaveEveryThree.
@Test
public void numberOfEventsRollingUpToThisMasterEveryTwoSlaveEveryThree() {
ScheduledEvent master = new ScheduledEventBuilder().every(2).weeks().build();
ScheduledEvent slave = new ScheduledEventBuilder().every(3).weeks().build();
assertThat(master.numberOfEventsRollingUpToThis(slave, 1), is(1));
assertThat(master.numberOfEventsRollingUpToThis(slave, 2), is(0));
assertThat(master.numberOfEventsRollingUpToThis(slave, 3), is(1));
assertThat(master.numberOfEventsRollingUpToThis(slave, 4), is(1));
assertThat(master.numberOfEventsRollingUpToThis(slave, 5), is(0));
assertThat(master.numberOfEventsRollingUpToThis(slave, 6), is(1));
assertThat(master.numberOfEventsRollingUpToThis(slave, 7), is(1));
assertThat(master.numberOfEventsRollingUpToThis(slave, 8), is(0));
}
Aggregations