use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class GroupCreationTest method rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs.
@Test(expected = MifosRuntimeException.class)
public void rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs() throws Exception {
// setup
CenterBO parent = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).build();
GroupBO stubbedGroup = new GroupBuilder().withName("group").withParentCustomer(parent).formedBy(anyLoanOfficer()).build();
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stub
doThrow(new RuntimeException()).when(customerDao).save(stubbedGroup);
// exercise test
customerService.createGroup(stubbedGroup, meeting, accountFees);
// verification
verify(hibernateTransactionHelper).rollbackTransaction();
verify(hibernateTransactionHelper).closeSession();
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class GroupTransferToCenterServiceTest method validatesReceivingCenterWhenTransferingGroup.
@Test(expected = CustomerException.class)
public void validatesReceivingCenterWhenTransferingGroup() throws Exception {
// setup
CenterBO toCenter = new CenterBuilder().build();
// stubbing
doThrow(new CustomerException(CustomerConstants.INVALID_PARENT)).when(group).validateReceivingCenter(toCenter);
// exercise test
customerService.transferGroupTo(group, toCenter);
// verification
verify(group).validateReceivingCenter(toCenter);
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class GroupTransferToCenterServiceTest method validatesNoActiveAccountExistWhenTransferingGroup.
@Test(expected = CustomerException.class)
public void validatesNoActiveAccountExistWhenTransferingGroup() throws Exception {
// setup
CenterBO toCenter = new CenterBuilder().build();
// stubbing
doThrow(new CustomerException(CustomerConstants.ERRORS_HAS_ACTIVE_ACCOUNT)).when(group).validateNoActiveAccountsExist();
// exercise test
customerService.transferGroupTo(group, toCenter);
// verification
verify(group).validateNoActiveAccountsExist();
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class CenterValidationTest method cannotCreateCenterWithMultipleInstancesOfSamePeriodFee.
@Test
public void cannotCreateCenterWithMultipleInstancesOfSamePeriodFee() {
// setup
DateTime today = new DateTime();
MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly();
CenterBO center = new CenterBuilder().withName("center1").withLoanOfficer(anyLoanOfficer()).with(aWeeklyMeeting).withMfiJoiningDate(today).build();
MeetingBuilder aWeeklyFeeMeeting = new MeetingBuilder().periodicFeeMeeting().weekly();
AmountFeeBO montlyPeriodicFee = new FeeBuilder().appliesToCenterOnly().with(aWeeklyFeeMeeting).build();
AccountFeesEntity accountFee = new AccountFeesEntity(null, montlyPeriodicFee, montlyPeriodicFee.getFeeAmount().getAmountDoubleValue());
List<AccountFeesEntity> centerAccountFees = new ArrayList<AccountFeesEntity>();
centerAccountFees.add(accountFee);
centerAccountFees.add(accountFee);
// exercise test
try {
center.validateMeetingAndFees(centerAccountFees);
fail("cannotCreateCenterWithFeeThatHasDifferentPeriod");
} catch (ApplicationException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_DUPLICATE_PERIODIC_FEE));
}
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class GroupTransferToCenterTest method transferingGroupToCenterInDifferentBranchCreatesNewCustomerMovementsForGroupAndChangesGroupStatusFromActiveToOnHold.
@Test
public void transferingGroupToCenterInDifferentBranchCreatesNewCustomerMovementsForGroupAndChangesGroupStatusFromActiveToOnHold() throws Exception {
// setup
OfficeBO fromBranch = new OfficeBuilder().branchOffice().withName("fromBranch").withGlobalOfficeNum("xxx1").build();
CenterBO fromCenter = new CenterBuilder().withName("fromCenter").with(fromBranch).build();
GroupBO groupForTransfer = new GroupBuilder().withParentCustomer(fromCenter).active().build();
OfficeBO receivingBranch = new OfficeBuilder().branchOffice().withName("receivingBranch").withGlobalOfficeNum("xxx2").build();
CenterBO receivingCenter = new CenterBuilder().withName("receivingCenter").with(receivingBranch).build();
// exercise test
groupForTransfer.transferTo(receivingCenter);
// verification
assertThat(groupForTransfer.getStatus().isGroupActive(), is(false));
assertThat(groupForTransfer.getStatus().isGroupOnHold(), is(true));
assertThat(groupForTransfer.countOfCustomerMovements(), is(2));
}
Aggregations