use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class ScheduledEventTest method numberOfEventsRollingUpToThisMasterEveryOneSlaveEveryTwo.
@Test
public void numberOfEventsRollingUpToThisMasterEveryOneSlaveEveryTwo() {
ScheduledEvent master = new ScheduledEventBuilder().every(1).weeks().build();
ScheduledEvent slave = new ScheduledEventBuilder().every(2).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(0));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class ScheduledEventTest method numberOfEventsRollingUpToThisMasterEveryTwoSlaveEveryOneWithStart.
@Test
public void numberOfEventsRollingUpToThisMasterEveryTwoSlaveEveryOneWithStart() {
ScheduledEvent master = new ScheduledEventBuilder().every(2).weeks().build();
ScheduledEvent slave = new ScheduledEventBuilder().every(1).weeks().build();
assertThat(master.numberOfDependentOccurrencesRollingUpToThisOccurrenceStartingWith(slave, 4, 4), is(1));
assertThat(master.numberOfDependentOccurrencesRollingUpToThisOccurrenceStartingWith(slave, 5, 4), is(2));
assertThat(master.numberOfDependentOccurrencesRollingUpToThisOccurrenceStartingWith(slave, 6, 4), is(2));
assertThat(master.numberOfDependentOccurrencesRollingUpToThisOccurrenceStartingWith(slave, 7, 4), is(2));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class ScheduledEventTest method numberOfEventsRollingUpToThisMasterEveryTwoSlaveEveryThreeStartingWithFourthOccurrence.
@Test
public void numberOfEventsRollingUpToThisMasterEveryTwoSlaveEveryThreeStartingWithFourthOccurrence() {
ScheduledEvent master = new ScheduledEventBuilder().every(2).weeks().build();
ScheduledEvent slave = new ScheduledEventBuilder().every(3).weeks().build();
assertThat(master.numberOfDependentOccurrencesRollingUpToThisOccurrenceStartingWith(slave, 4, 4), is(1));
assertThat(master.numberOfDependentOccurrencesRollingUpToThisOccurrenceStartingWith(slave, 5, 4), is(0));
assertThat(master.numberOfDependentOccurrencesRollingUpToThisOccurrenceStartingWith(slave, 6, 4), is(1));
assertThat(master.numberOfDependentOccurrencesRollingUpToThisOccurrenceStartingWith(slave, 7, 4), is(1));
assertThat(master.numberOfDependentOccurrencesRollingUpToThisOccurrenceStartingWith(slave, 8, 4), is(0));
assertThat(master.numberOfDependentOccurrencesRollingUpToThisOccurrenceStartingWith(slave, 9, 4), is(1));
assertThat(master.numberOfDependentOccurrencesRollingUpToThisOccurrenceStartingWith(slave, 10, 4), is(1));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class WeeklyScheduledEventTest method canRollForwardDateToMatchDayOfWeekStartingFromTwoDaysBehind.
@Test
public void canRollForwardDateToMatchDayOfWeekStartingFromTwoDaysBehind() {
scheduledEvent = new ScheduledEventBuilder().every(1).weeks().on(DayOfWeek.wednesday()).build();
DateTime monday = DayOfWeek.mondayMidnight();
DateTime result = scheduledEvent.nearestMatchingDateBeginningAt(monday);
assertThat(result, is(monday.plusDays(2)));
}
use of org.mifos.domain.builders.ScheduledEventBuilder in project head by mifos.
the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest 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