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()));
}
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);
}
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);
}
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);
}
Aggregations