use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class ClientCreationTest method throwsCheckedExceptionWhenClientValidationFails.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenClientValidationFails() throws Exception {
// setup
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
List<SavingsOfferingBO> noSavings = new ArrayList<SavingsOfferingBO>();
// stubbing
doThrow(new CustomerException(ClientConstants.ERRORS_GROUP_CANCELLED)).when(mockedClient).validate();
// exercise test
customerService.createClient(mockedClient, meeting, accountFees, noSavings);
// verify
verify(mockedClient).validate();
}
use of org.mifos.customers.exceptions.CustomerException 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.exceptions.CustomerException in project head by mifos.
the class GroupUpdateTest method throwsCheckedExceptionWhenVersionOfGroupForUpdateIsDifferentToPersistedGroupVersion.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenVersionOfGroupForUpdateIsDifferentToPersistedGroupVersion() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
GroupUpdate groupUpdate = new GroupUpdateBuilder().build();
// stubbing
when(customerDao.findGroupBySystemId(groupUpdate.getGlobalCustNum())).thenReturn(mockedGroup);
doThrow(new CustomerException(Constants.ERROR_VERSION_MISMATCH)).when(mockedGroup).validateVersion(groupUpdate.getVersionNo());
// exercise test
customerService.updateGroup(userContext, groupUpdate);
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class ClientUpdateTest method rollsbackTransactionClosesSessionAndReThrowsApplicationException2.
@Test(expected = CustomerException.class)
public void rollsbackTransactionClosesSessionAndReThrowsApplicationException2() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientPersonalInfoUpdate clientPersonalInfoUpdate = new ClientPersonalInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientPersonalInfoUpdate.getCustomerId())).thenReturn(mockedClient);
doThrow(new CustomerException(ClientConstants.INVALID_DOB_EXCEPTION)).when(mockedClient).updatePersonalInfo(clientPersonalInfoUpdate);
// exercise test
customerService.updateClientPersonalInfo(userContext, clientPersonalInfoUpdate);
// verification
verify(hibernateTransactionHelper).rollbackTransaction();
verify(hibernateTransactionHelper).closeSession();
}
use of org.mifos.customers.exceptions.CustomerException 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()));
}
Aggregations