use of org.mifos.domain.builders.CalendarEventBuilder 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.CalendarEventBuilder 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.CalendarEventBuilder in project head by mifos.
the class CenterCreationTest method createsCenterWithCustomerAccount.
@Test
public void createsCenterWithCustomerAccount() throws Exception {
// setup
OfficeBO withOffice = new OfficeBO(new Short("1"), "testOffice", new Integer("1"), new Short("1"));
CenterBO center = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).with(withOffice).build();
center.setCustomerDao(customerDao);
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stub
CalendarEvent upcomingCalendarEvents = new CalendarEventBuilder().build();
when(holidayDao.findCalendarEventsForThisYearAndNext((short) 1)).thenReturn(upcomingCalendarEvents);
when(customerAccountFactory.create(center, accountFees, meeting, upcomingCalendarEvents)).thenReturn(customerAccount);
when(customerAccount.getType()).thenReturn(AccountTypes.CUSTOMER_ACCOUNT);
// exercise test
customerService.createCenter(center, meeting, accountFees);
// verification
assertThat(center.getCustomerAccount(), is(customerAccount));
}
use of org.mifos.domain.builders.CalendarEventBuilder in project head by mifos.
the class CenterCreationTest method rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs.
@Test(expected = MifosRuntimeException.class)
public void rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs() throws Exception {
// setup
CenterBO center = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).build();
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stub
CalendarEvent upcomingCalendarEvents = new CalendarEventBuilder().build();
when(holidayDao.findCalendarEventsForThisYearAndNext((short) 1)).thenReturn(upcomingCalendarEvents);
when(customerAccountFactory.create(center, accountFees, meeting, upcomingCalendarEvents)).thenReturn(customerAccount);
when(customerAccount.getType()).thenReturn(AccountTypes.CUSTOMER_ACCOUNT);
// stub
doThrow(new RuntimeException()).when(customerDao).save(center);
// exercise test
customerService.createCenter(center, meeting, accountFees);
// verification
verify(hibernateTransaction).rollbackTransaction();
verify(hibernateTransaction).closeSession();
}
use of org.mifos.domain.builders.CalendarEventBuilder 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