Search in sources :

Example 16 with ScheduledEventBuilder

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

Example 17 with ScheduledEventBuilder

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

Example 18 with ScheduledEventBuilder

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

Example 19 with ScheduledEventBuilder

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

Example 20 with ScheduledEventBuilder

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;
    }
}
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