use of org.mifos.domain.builders.CenterBuilder 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.CenterBuilder 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.CenterBuilder in project head by mifos.
the class CenterCreationUsingCustomerServiceIntegrationTest method canNotCreateCenterWithNameOfAlreadyExistingCenter.
@Test(expected = BusinessRuleException.class)
public void canNotCreateCenterWithNameOfAlreadyExistingCenter() throws Exception {
// minimal details
MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday();
String centerName = "existingCenterName";
OfficeBO anExistingBranch = sampleBranchOffice();
PersonnelBO existingLoanOfficer = testUser();
DateTime aWeekFromNow = new DateTime().plusWeeks(1);
CenterBO existingCenter = new CenterBuilder().withName(centerName).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
IntegrationTestObjectMother.createCenter(existingCenter, existingCenter.getCustomerMeetingValue());
CenterBO newCenter = new CenterBuilder().withName(existingCenter.getDisplayName()).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
// setup
List<AccountFeesEntity> noCenterAccountFees = new ArrayList<AccountFeesEntity>();
// exercise test
customerService.createCenter(newCenter, newCenter.getCustomerMeetingValue(), noCenterAccountFees);
// verification
assertThat(existingCenter.getGlobalCustNum(), is(not(newCenter.getGlobalCustNum())));
assertThat(existingCenter.getDisplayName(), is(newCenter.getDisplayName()));
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class CenterCreationUsingCustomerServiceIntegrationTest method canCreateCenterWithAddress.
@Test
public void canCreateCenterWithAddress() throws Exception {
// minimal details
MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday();
String centerName = "Center-IntegrationTest";
OfficeBO anExistingBranch = sampleBranchOffice();
PersonnelBO existingLoanOfficer = testUser();
DateTime aWeekFromNow = new DateTime().plusWeeks(1);
CenterBO center = new CenterBuilder().withName(centerName).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).with(anAddress()).withUserContext().build();
List<AccountFeesEntity> noAccountFees = new ArrayList<AccountFeesEntity>();
// exercise test
customerService.createCenter(center, center.getCustomerMeetingValue(), noAccountFees);
// verification
assertThat(center.getCustomerId(), is(notNullValue()));
assertThat(center.getGlobalCustNum(), is(notNullValue()));
assertThat(center.getAddress(), is(notNullValue()));
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class CenterCreationUsingCustomerServiceIntegrationTest method canCreateCenterWithFeeThatMatchesMeetingPeriod.
@Test
public void canCreateCenterWithFeeThatMatchesMeetingPeriod() throws Exception {
// minimal details
MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday();
String centerName = "Center-IntegrationTest";
OfficeBO anExistingBranch = sampleBranchOffice();
PersonnelBO existingLoanOfficer = testUser();
DateTime aWeekFromNow = new DateTime().plusWeeks(1);
CenterBO center = new CenterBuilder().withName(centerName).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
// setup
AmountFeeBO existingWeeklyFee = new FeeBuilder().with(aWeeklyMeeting).appliesToCenterOnly().with(anExistingBranch).build();
IntegrationTestObjectMother.saveFee(existingWeeklyFee);
AccountFeesEntity accountFee = new AccountFeesEntity(null, existingWeeklyFee, existingWeeklyFee.getFeeAmount().getAmountDoubleValue());
List<AccountFeesEntity> centerAccountFees = new ArrayList<AccountFeesEntity>();
centerAccountFees.add(accountFee);
// exercise test
customerService.createCenter(center, center.getCustomerMeetingValue(), centerAccountFees);
// verification
assertThat(center.getCustomerId(), is(notNullValue()));
assertThat(center.getGlobalCustNum(), is(notNullValue()));
assertThat(center.getCustomerAccount().getAccountFees().isEmpty(), is(false));
}
Aggregations