Search in sources :

Example 96 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 97 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)

Example 98 with CustomerException

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

the class ClientIntegrationTest method testFailureCreateActiveClientWithParentGroupInLowerStatus.

@Test
public void testFailureCreateActiveClientWithParentGroupInLowerStatus() throws Exception {
    try {
        ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "Client", "", "1", "");
        clientNameDetailDto.setNames(ClientRules.getNameSequence());
        ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
        spouseNameDetailView.setNames(ClientRules.getNameSequence());
        ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
        createParentObjects(CustomerStatus.GROUP_PARTIAL);
        client = new ClientBO(TestUtils.makeUserWithLocales(), clientNameDetailDto.getDisplayName(), CustomerStatus.CLIENT_ACTIVE, null, null, null, null, null, null, personnel, group.getOffice(), group, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
        Assert.fail();
    } catch (CustomerException e) {
        Assert.assertNull(client);
        Assert.assertEquals(ClientConstants.INVALID_CLIENT_STATUS_EXCEPTION, e.getKey());
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) Test(org.junit.Test)

Example 99 with CustomerException

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

the class ClientIntegrationTest method testFailure_InitialSavingsOfferingAtCreate.

@Test
public void testFailure_InitialSavingsOfferingAtCreate() throws Exception {
    savingsOffering1 = TestObjectFactory.createSavingsProduct("Offering1", "s1", SavingsType.MANDATORY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
    ClientNameDetailDto clientView = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "Client", "", "1", "");
    clientView.setNames(ClientRules.getNameSequence());
    ClientNameDetailDto spouseView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
    spouseView.setNames(ClientRules.getNameSequence());
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
    List<SavingsOfferingBO> offerings = new ArrayList<SavingsOfferingBO>();
    offerings.add(savingsOffering1);
    offerings.add(savingsOffering1);
    try {
        client = new ClientBO(TestObjectFactory.getContext(), clientView.getDisplayName(), CustomerStatus.CLIENT_PARTIAL, null, null, null, null, null, offerings, personnel, officeBo, null, null, null, null, null, YesNoFlag.NO.getValue(), clientView, spouseView, clientPersonalDetailDto);
    } catch (CustomerException ce) {
        Assert.assertEquals(ClientConstants.ERRORS_DUPLICATE_OFFERING_SELECTED, ce.getKey());
        Assert.assertTrue(true);
    }
    savingsOffering1 = (SavingsOfferingBO) TestObjectFactory.getObject(SavingsOfferingBO.class, savingsOffering1.getPrdOfferingId());
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ArrayList(java.util.ArrayList) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) Date(java.sql.Date) Test(org.junit.Test)

Example 100 with CustomerException

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

the class ClientIntegrationTest method testCreateClientWithoutName.

@Test
public void testCreateClientWithoutName() throws Exception {
    try {
        ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "", "", "", "");
        ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
        ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
        client = new ClientBO(TestUtils.makeUser(), "", CustomerStatus.fromInt(new Short("1")), null, null, null, null, null, null, personnel, officeBo, null, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
        Assert.fail("Client Created");
    } catch (CustomerException ce) {
        Assert.assertNull(client);
        Assert.assertEquals(CustomerConstants.INVALID_NAME, ce.getKey());
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) 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