Search in sources :

Example 1 with CustomerAccountBuilder

use of org.mifos.domain.builders.CustomerAccountBuilder in project head by mifos.

the class UpdateCustomerMeetingScheduleTest method givenCustomerHasNoExistingMeetingShouldCreateMeetingOnCustomer.

@Test
public void givenCustomerHasNoExistingMeetingShouldCreateMeetingOnCustomer() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    CustomerAccountBuilder accountBuilder = new CustomerAccountBuilder();
    CenterBO center = new CenterBuilder().active().withAccount(accountBuilder).build();
    center.setCustomerMeeting(null);
    MeetingBO weeklyWednesdayMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).occuringOnA(WeekDay.WEDNESDAY).build();
    weeklyWednesdayMeeting.updateDetails(userContext);
    // stubbing
    when(holidayDao.findCalendarEventsForThisYearAndNext(anyShort())).thenReturn(new CalendarEventBuilder().build());
    // exercise test
    customerService.updateCustomerMeetingSchedule(weeklyWednesdayMeeting, center);
    // verification
    assertThat(center.getCustomerMeeting(), is(notNullValue()));
    assertThat(center.getCustomerMeetingValue(), is(notNullValue()));
}
Also used : UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerAccountBuilder(org.mifos.domain.builders.CustomerAccountBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Example 2 with CustomerAccountBuilder

use of org.mifos.domain.builders.CustomerAccountBuilder in project head by mifos.

the class UpdateCustomerMeetingScheduleTest method givenDayOfWeekIsDifferentShouldRegenerateSchedules.

@Test
public void givenDayOfWeekIsDifferentShouldRegenerateSchedules() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    DateTime mondayTwoWeeksAgo = new DateTime().withDayOfWeek(DayOfWeek.monday()).minusWeeks(2);
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(mondayTwoWeeksAgo).build();
    weeklyMeeting.updateDetails(userContext);
    CustomerAccountBuilder accountBuilder = new CustomerAccountBuilder();
    CenterBO center = new CenterBuilder().active().with(weeklyMeeting).withAccount(accountBuilder).build();
    MeetingBO weeklyWednesdayMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).occuringOnA(WeekDay.WEDNESDAY).build();
    weeklyWednesdayMeeting.updateDetails(userContext);
    // stubbing
    when(holidayDao.findCalendarEventsForThisYearAndNext(anyShort())).thenReturn(new CalendarEventBuilder().build());
    // pre - verification
    assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(center, WeekDay.MONDAY);
    // exercise test
    customerService.updateCustomerMeetingSchedule(weeklyWednesdayMeeting, center);
    // verification
    assertThatAllCustomerSchedulesOccuringBeforeOrOnCurrentInstallmentPeriodRemainUnchanged(center, WeekDay.MONDAY);
    assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(center, WeekDay.WEDNESDAY);
}
Also used : UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerAccountBuilder(org.mifos.domain.builders.CustomerAccountBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Example 3 with CustomerAccountBuilder

use of org.mifos.domain.builders.CustomerAccountBuilder in project head by mifos.

the class UpdateCustomerMeetingScheduleTest method givenDayOfWeekRemainsUnchangedShouldNotRegenerateSchedules.

@Test
public void givenDayOfWeekRemainsUnchangedShouldNotRegenerateSchedules() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    MeetingBO weeklyMondayMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).occuringOnA(WeekDay.MONDAY).build();
    weeklyMondayMeeting.updateDetails(userContext);
    CustomerAccountBuilder accountBuilder = new CustomerAccountBuilder();
    CenterBO center = new CenterBuilder().active().with(weeklyMondayMeeting).withAccount(accountBuilder).build();
    // pre - verification
    assertThatAllCustomerSchedulesOccuringBeforeOrOnCurrentInstallmentPeriodRemainUnchanged(center, WeekDay.MONDAY);
    assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(center, WeekDay.MONDAY);
    // exercise test
    customerService.updateCustomerMeetingSchedule(weeklyMondayMeeting, mockedCenter);
    // verification
    assertThatAllCustomerSchedulesOccuringBeforeOrOnCurrentInstallmentPeriodRemainUnchanged(center, WeekDay.MONDAY);
    assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(center, WeekDay.MONDAY);
}
Also used : UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerAccountBuilder(org.mifos.domain.builders.CustomerAccountBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) Test(org.junit.Test)

Example 4 with CustomerAccountBuilder

use of org.mifos.domain.builders.CustomerAccountBuilder in project head by mifos.

the class UpdateCustomerMeetingScheduleTest method givenLsimIsEnabledShouldNotRegenerateSchedulesForLoanAccountsButShouldRegenerateSchedulesForCustomerAndSavingsAccounts.

@Test
public void givenLsimIsEnabledShouldNotRegenerateSchedulesForLoanAccountsButShouldRegenerateSchedulesForCustomerAndSavingsAccounts() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    DateTime mondayTwoWeeksAgo = new DateTime().withDayOfWeek(DayOfWeek.monday()).minusWeeks(2);
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(mondayTwoWeeksAgo).build();
    weeklyMeeting.updateDetails(userContext);
    CustomerAccountBuilder accountBuilder = new CustomerAccountBuilder();
    CenterBO center = new CenterBuilder().active().with(weeklyMeeting).withAccount(accountBuilder).withAccount(this.loanAccount).build();
    MeetingBO weeklyWednesdayMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).occuringOnA(WeekDay.WEDNESDAY).build();
    weeklyWednesdayMeeting.updateDetails(userContext);
    // stubbing
    CalendarEvent calendarEvent = new CalendarEventBuilder().build();
    when(holidayDao.findCalendarEventsForThisYearAndNext(anyShort())).thenReturn(calendarEvent);
    when(configurationHelper.isLoanScheduleRepaymentIndependentOfCustomerMeetingEnabled()).thenReturn(true);
    // pre - verification
    assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(center, WeekDay.MONDAY);
    // exercise test
    customerService.updateCustomerMeetingSchedule(weeklyWednesdayMeeting, center);
    // verification
    assertThatAllCustomerSchedulesOccuringBeforeOrOnCurrentInstallmentPeriodRemainUnchanged(center, WeekDay.MONDAY);
    assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(center, WeekDay.WEDNESDAY);
}
Also used : UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerAccountBuilder(org.mifos.domain.builders.CustomerAccountBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) CalendarEvent(org.mifos.calendar.CalendarEvent) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 MeetingBO (org.mifos.application.meeting.business.MeetingBO)4 CenterBO (org.mifos.customers.center.business.CenterBO)4 CenterBuilder (org.mifos.domain.builders.CenterBuilder)4 CustomerAccountBuilder (org.mifos.domain.builders.CustomerAccountBuilder)4 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)4 UserContext (org.mifos.security.util.UserContext)4 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)3 DateTime (org.joda.time.DateTime)2 CalendarEvent (org.mifos.calendar.CalendarEvent)1