use of org.mifos.domain.builders.ClientFamilyInfoUpdateBuilder in project head by mifos.
the class ClientUpdateTest method throwsCheckedExceptionWhenVersionOfClientForFamilyInfoUpdateIsDifferentToPersistedClient.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenVersionOfClientForFamilyInfoUpdateIsDifferentToPersistedClient() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientFamilyInfoUpdate clientFamilyInfoUpdate = new ClientFamilyInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientFamilyInfoUpdate.getCustomerId())).thenReturn(mockedClient);
doThrow(new CustomerException(Constants.ERROR_VERSION_MISMATCH)).when(mockedClient).validateVersion(clientFamilyInfoUpdate.getOldVersionNum());
// exercise test
customerService.updateClientFamilyInfo(userContext, clientFamilyInfoUpdate);
// verify
verify(mockedClient).validateVersion(clientFamilyInfoUpdate.getOldVersionNum());
}
use of org.mifos.domain.builders.ClientFamilyInfoUpdateBuilder in project head by mifos.
the class ClientUpdateTest method rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs3.
@Test(expected = MifosRuntimeException.class)
public void rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs3() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientFamilyInfoUpdate clientFamilyInfoUpdate = new ClientFamilyInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientFamilyInfoUpdate.getCustomerId())).thenReturn(mockedClient);
doThrow(new RuntimeException()).when(customerDao).save(mockedClient);
// exercise test
customerService.updateClientFamilyInfo(userContext, clientFamilyInfoUpdate);
// verification
verify(hibernateTransactionHelper).rollbackTransaction();
verify(hibernateTransactionHelper).closeSession();
}
use of org.mifos.domain.builders.ClientFamilyInfoUpdateBuilder in project head by mifos.
the class ClientUpdateTest method familyDetailsAreUpdated.
@Test
public void familyDetailsAreUpdated() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientFamilyInfoUpdate clientFamilyInfoUpdate = new ClientFamilyInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientFamilyInfoUpdate.getCustomerId())).thenReturn(mockedClient);
// exercise test
customerService.updateClientFamilyInfo(userContext, clientFamilyInfoUpdate);
// verification
verify(mockedClient).updateFamilyInfo(clientFamilyInfoUpdate);
}
use of org.mifos.domain.builders.ClientFamilyInfoUpdateBuilder in project head by mifos.
the class ClientUpdateTest method userContextAndUpdateDetailsAreSetBeforeBeginningAuditLoggingForFamilyInfo.
@Test
public void userContextAndUpdateDetailsAreSetBeforeBeginningAuditLoggingForFamilyInfo() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientFamilyInfoUpdate clientFamilyInfoUpdate = new ClientFamilyInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientFamilyInfoUpdate.getCustomerId())).thenReturn(mockedClient);
// exercise test
customerService.updateClientFamilyInfo(userContext, clientFamilyInfoUpdate);
// verification
InOrder inOrder = inOrder(hibernateTransactionHelper, mockedClient);
inOrder.verify(mockedClient).updateDetails(userContext);
inOrder.verify(hibernateTransactionHelper).beginAuditLoggingFor(mockedClient);
}
Aggregations