use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class GroupTransferToOfficeServiceTest method givenOfficeIsSameAsGroupsOfficeGroupTransferToBranchShouldFailValidation.
@Test
public void givenOfficeIsSameAsGroupsOfficeGroupTransferToBranchShouldFailValidation() {
// setup
OfficeBO office = new OfficeBuilder().build();
CenterBO parent = new CenterBuilder().with(office).build();
GroupBO group = new GroupBuilder().withParentCustomer(parent).build();
// exercise test
try {
customerService.transferGroupTo(group, office);
fail("should fail validation");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_SAME_BRANCH_TRANSFER));
}
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class CustomerAccountCreationTest method firstCustomerScheduleIsAlwaysTheClosestMatchingDayOfWeekAndDoesNotTakeIntoAccountMonthlyMeetingFrequency.
@Test
public void firstCustomerScheduleIsAlwaysTheClosestMatchingDayOfWeekAndDoesNotTakeIntoAccountMonthlyMeetingFrequency() throws Exception {
// setup
applicableCalendarEvents = new CalendarEventBuilder().build();
DateTime tue19thOfApril = new DateTime().withDate(2011, 4, 19);
accountFees = new ArrayList<AccountFeesEntity>();
MeetingBO centerMeeting = new MeetingBuilder().customerMeeting().monthly().every(2).occuringOnA(WeekDay.MONDAY).startingFrom(tue19thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
CenterBO center = new CenterBuilder().active().withActivationDate(tue19thOfApril).with(centerMeeting).build();
// exercise test
CustomerAccountBO centerAccount = CustomerAccountBO.createNew(center, accountFees, centerMeeting, applicableCalendarEvents);
// verification
List<AccountActionDateEntity> centerSchedules = new ArrayList<AccountActionDateEntity>(centerAccount.getAccountActionDates());
LocalDate firstCenterDate = new LocalDate(centerSchedules.get(0).getActionDate());
LocalDate mon18thOfMay = new DateTime().withDate(2011, 5, 18).toLocalDate();
assertThat(firstCenterDate, is(mon18thOfMay));
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class GroupTransferToCenterServiceTest method rollsbackTransactionOnException.
@Test(expected = RuntimeException.class)
public void rollsbackTransactionOnException() throws Exception {
// setup
CenterBO toCenter = new CenterBuilder().build();
// stubbing
when(group.isDifferentBranch(toCenter.getOffice())).thenReturn(false);
when(group.getUserContext()).thenReturn(TestUtils.makeUser());
doThrow(new RuntimeException()).when(customerDao).save(group);
// exercise test
customerService.transferGroupTo(group, toCenter);
// verification
verify(hibernateTransaction).rollbackTransaction();
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class GroupTransferToCenterServiceTest method validatesGroupNameIsNotAlreadyTakenWhenTransferingGroupToDifferentOffice.
@Test(expected = CustomerException.class)
public void validatesGroupNameIsNotAlreadyTakenWhenTransferingGroupToDifferentOffice() throws Exception {
// setup
CenterBO toCenter = new CenterBuilder().build();
// stubbing
when(group.isDifferentBranch(toCenter.getOffice())).thenReturn(true);
doThrow(new CustomerException(CustomerConstants.ERRORS_DUPLICATE_CUSTOMER)).when(customerDao).validateGroupNameIsNotTakenForOffice(anyString(), eq(toCenter.getOfficeId()));
// exercise test
customerService.transferGroupTo(group, toCenter);
// verification
verify(customerDao).validateGroupNameIsNotTakenForOffice(anyString(), eq(toCenter.getOfficeId()));
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class GroupTransferToCenterServiceTest method transfersGroupToReceivingCenter.
@Test
public void transfersGroupToReceivingCenter() throws Exception {
// setup
CenterBO toCenter = new CenterBuilder().build();
// stubbing
when(group.isDifferentBranch(toCenter.getOffice())).thenReturn(false);
when(group.getUserContext()).thenReturn(TestUtils.makeUser());
// exercise test
customerService.transferGroupTo(group, toCenter);
// verification
verify(group).transferTo(toCenter);
}
Aggregations