Search in sources :

Example 91 with CustomerException

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();
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) ArrayList(java.util.ArrayList) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 92 with CustomerException

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));
    }
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Example 93 with CustomerException

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);
}
Also used : GroupUpdateBuilder(org.mifos.domain.builders.GroupUpdateBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) UserContext(org.mifos.security.util.UserContext) GroupUpdate(org.mifos.dto.domain.GroupUpdate) Test(org.junit.Test)

Example 94 with CustomerException

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();
}
Also used : ClientPersonalInfoUpdate(org.mifos.dto.domain.ClientPersonalInfoUpdate) CustomerException(org.mifos.customers.exceptions.CustomerException) UserContext(org.mifos.security.util.UserContext) ClientPersonalInfoUpdateBuilder(org.mifos.domain.builders.ClientPersonalInfoUpdateBuilder) Test(org.junit.Test)

Example 95 with CustomerException

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()));
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) Test(org.junit.Test)

Aggregations

CustomerException (org.mifos.customers.exceptions.CustomerException)103 Test (org.junit.Test)52 UserContext (org.mifos.security.util.UserContext)29 ClientBO (org.mifos.customers.client.business.ClientBO)23 GroupBuilder (org.mifos.domain.builders.GroupBuilder)21 PersistenceException (org.mifos.framework.exceptions.PersistenceException)21 BusinessRuleException (org.mifos.service.BusinessRuleException)21 CenterBO (org.mifos.customers.center.business.CenterBO)20 GroupBO (org.mifos.customers.group.business.GroupBO)20 AccountException (org.mifos.accounts.exceptions.AccountException)18 CenterBuilder (org.mifos.domain.builders.CenterBuilder)18 ArrayList (java.util.ArrayList)17 MifosRuntimeException (org.mifos.core.MifosRuntimeException)14 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)13 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)13 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)12 MeetingBO (org.mifos.application.meeting.business.MeetingBO)12 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 MifosUser (org.mifos.security.MifosUser)11 DateTime (org.joda.time.DateTime)10