use of org.mifos.domain.builders.ClientPersonalInfoUpdateBuilder in project head by mifos.
the class ClientUpdateTest method clientPersonalDetailsAreUpdated.
@Test
public void clientPersonalDetailsAreUpdated() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientPersonalInfoUpdate clientPersonalInfoUpdate = new ClientPersonalInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientPersonalInfoUpdate.getCustomerId())).thenReturn(mockedClient);
// exercise test
customerService.updateClientPersonalInfo(userContext, clientPersonalInfoUpdate);
// verification
verify(mockedClient).updatePersonalInfo(clientPersonalInfoUpdate);
}
use of org.mifos.domain.builders.ClientPersonalInfoUpdateBuilder in project head by mifos.
the class ClientUpdateTest method rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs2.
@Test(expected = MifosRuntimeException.class)
public void rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs2() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientPersonalInfoUpdate clientPersonalInfoUpdate = new ClientPersonalInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientPersonalInfoUpdate.getCustomerId())).thenReturn(mockedClient);
doThrow(new RuntimeException()).when(customerDao).save(mockedClient);
// exercise test
customerService.updateClientPersonalInfo(userContext, clientPersonalInfoUpdate);
// verification
verify(hibernateTransactionHelper).rollbackTransaction();
verify(hibernateTransactionHelper).closeSession();
}
use of org.mifos.domain.builders.ClientPersonalInfoUpdateBuilder in project head by mifos.
the class ClientUpdateTest method throwsCheckedExceptionWhenVersionOfClientForUpdateIsDifferentToPersistedClient.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenVersionOfClientForUpdateIsDifferentToPersistedClient() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientPersonalInfoUpdate clientPersonalInfoUpdate = new ClientPersonalInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientPersonalInfoUpdate.getCustomerId())).thenReturn(mockedClient);
doThrow(new CustomerException(Constants.ERROR_VERSION_MISMATCH)).when(mockedClient).validateVersion(clientPersonalInfoUpdate.getOriginalClientVersionNumber());
// exercise test
customerService.updateClientPersonalInfo(userContext, clientPersonalInfoUpdate);
// verify
verify(mockedClient).validateVersion(clientPersonalInfoUpdate.getOriginalClientVersionNumber());
}
use of org.mifos.domain.builders.ClientPersonalInfoUpdateBuilder in project head by mifos.
the class ClientUpdateTest method userContextAndUpdateDetailsAreSetBeforeBeginningAuditLoggingForPersonalInfo.
@Test
public void userContextAndUpdateDetailsAreSetBeforeBeginningAuditLoggingForPersonalInfo() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientPersonalInfoUpdate clientPersonalInfoUpdate = new ClientPersonalInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientPersonalInfoUpdate.getCustomerId())).thenReturn(mockedClient);
// exercise test
customerService.updateClientPersonalInfo(userContext, clientPersonalInfoUpdate);
// verification
InOrder inOrder = inOrder(hibernateTransactionHelper, mockedClient);
inOrder.verify(mockedClient).updateDetails(userContext);
inOrder.verify(hibernateTransactionHelper).beginAuditLoggingFor(mockedClient);
}
use of org.mifos.domain.builders.ClientPersonalInfoUpdateBuilder 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();
}
Aggregations