Search in sources :

Example 86 with CustomerException

use of org.mifos.customers.exceptions.CustomerException in project head by mifos.

the class CustomerStatusUpdateTest method throwsCheckedExceptionWhenCenterTransitionsToInActiveStateAndFailsValidation.

@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenCenterTransitionsToInActiveStateAndFailsValidation() throws Exception {
    // setup
    OfficeBO office = new OfficeBuilder().withGlobalOfficeNum("xxx-9999").build();
    UserContext userContext = TestUtils.makeUser();
    CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().with(CustomerStatus.CENTER_INACTIVE).build();
    // stubbing
    when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(mockedCenter);
    when(mockedCenter.getOffice()).thenReturn(office);
    when(mockedCenter.getCustomerStatus()).thenReturn(new CustomerStatusEntity(CustomerStatus.CENTER_ACTIVE));
    doThrow(new CustomerException(CustomerConstants.CENTER_STATE_CHANGE_EXCEPTION)).when(mockedCenter).validateChangeToInActive();
    // exercise test
    customerService.updateCustomerStatus(userContext, customerStatusUpdate);
    // verification
    verify(mockedCenter).validateChangeToInActive();
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) CustomerStatusUpdate(org.mifos.application.servicefacade.CustomerStatusUpdate) OfficeBO(org.mifos.customers.office.business.OfficeBO) UserContext(org.mifos.security.util.UserContext) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CustomerStatusUpdateBuilder(org.mifos.domain.builders.CustomerStatusUpdateBuilder) Test(org.junit.Test)

Example 87 with CustomerException

use of org.mifos.customers.exceptions.CustomerException in project head by mifos.

the class GroupCreationTest method throwsCheckedExceptionWhenGroupNameIsTakenForOfficeAlready.

@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenGroupNameIsTakenForOfficeAlready() throws Exception {
    // setup
    CenterBO parent = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).build();
    GroupBO stubbedGroup = new GroupBuilder().withName("already-exists-group").withParentCustomer(parent).formedBy(anyLoanOfficer()).build();
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    // stubbing
    doThrow(new CustomerException(CustomerConstants.ERRORS_DUPLICATE_CUSTOMER)).when(customerDao).validateGroupNameIsNotTakenForOffice(anyString(), anyShort());
    // exercise test
    customerService.createGroup(stubbedGroup, meeting, accountFees);
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 88 with CustomerException

use of org.mifos.customers.exceptions.CustomerException 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);
}
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)

Example 89 with CustomerException

use of org.mifos.customers.exceptions.CustomerException 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();
}
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)

Example 90 with CustomerException

use of org.mifos.customers.exceptions.CustomerException in project head by mifos.

the class ClientCreationTest method throwsCheckedExceptionWhenValidationForDuplicateNameOrGovernmentId.

@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenValidationForDuplicateNameOrGovernmentId() throws Exception {
    String displayName = "Test Name";
    Date dob = new Date();
    String govtId = "44354323543";
    // setup
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    List<SavingsOfferingBO> noSavings = new ArrayList<SavingsOfferingBO>();
    // stubbing
    Mockito.when(mockedClient.getDisplayName()).thenReturn(displayName);
    Mockito.when(mockedClient.getDateOfBirth()).thenReturn(dob);
    Mockito.when(mockedClient.getGovernmentId()).thenReturn(govtId);
    doThrow(new CustomerException(CustomerConstants.DUPLICATE_GOVT_ID_EXCEPTION)).when(customerDao).validateClientForDuplicateNameOrGovtId(displayName, dob, govtId);
    // exercise test
    customerService.createClient(mockedClient, meeting, accountFees, noSavings);
    // verify
    verify(customerDao).validateClientForDuplicateNameOrGovtId(mockedClient.getDisplayName(), mockedClient.getDateOfBirth(), mockedClient.getGovernmentId());
}
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) Date(java.util.Date) 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