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()));
}
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());
}
}
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());
}
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());
}
}
Aggregations