Search in sources :

Example 26 with ScheduledEventBuilder

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));
}
Also used : ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) Test(org.junit.Test)

Example 27 with ScheduledEventBuilder

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));
}
Also used : ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) Test(org.junit.Test)

Example 28 with ScheduledEventBuilder

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));
}
Also used : ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) Test(org.junit.Test)

Example 29 with ScheduledEventBuilder

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)));
}
Also used : ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 30 with ScheduledEventBuilder

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;
    }
}
Also used : ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)32 ScheduledEventBuilder (org.mifos.domain.builders.ScheduledEventBuilder)32 DateTime (org.joda.time.DateTime)17 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)9 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)9 FeeBO (org.mifos.accounts.fees.business.FeeBO)9 FeeInstallment (org.mifos.accounts.util.helpers.FeeInstallment)9 ScheduledEvent (org.mifos.schedule.ScheduledEvent)9 Holiday (org.mifos.application.holiday.business.Holiday)1 HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)1 HolidayAndWorkingDaysScheduledDateGeneration (org.mifos.schedule.internal.HolidayAndWorkingDaysScheduledDateGeneration)1