use of org.mifos.domain.builders.ClientMfiInfoUpdateBuilder in project head by mifos.
the class ClientUpdateTest method userContextAndUpdateDetailsAreSetBeforeBeginningAuditLogging.
@Test
public void userContextAndUpdateDetailsAreSetBeforeBeginningAuditLogging() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientMfiInfoUpdate clientMfiInfoUpdate = new ClientMfiInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientMfiInfoUpdate.getClientId())).thenReturn(mockedClient);
// exercise test
customerService.updateClientMfiInfo(userContext, clientMfiInfoUpdate);
// verification
InOrder inOrder = inOrder(hibernateTransactionHelper, mockedClient);
inOrder.verify(mockedClient).updateDetails(userContext);
inOrder.verify(hibernateTransactionHelper).beginAuditLoggingFor(mockedClient);
}
use of org.mifos.domain.builders.ClientMfiInfoUpdateBuilder in project head by mifos.
the class ClientUpdateTest method rollsbackTransactionClosesSessionAndReThrowsApplicationException.
@Test(expected = CustomerException.class)
public void rollsbackTransactionClosesSessionAndReThrowsApplicationException() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientMfiInfoUpdate clientMfiInfoUpdate = new ClientMfiInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientMfiInfoUpdate.getClientId())).thenReturn(mockedClient);
when(personnelDao.findPersonnelById(clientMfiInfoUpdate.getPersonnelId())).thenReturn(personnel);
doThrow(new CustomerException(CustomerConstants.ERRORS_DUPLICATE_CUSTOMER)).when(mockedClient).updateMfiInfo(personnel, clientMfiInfoUpdate);
// exercise test
customerService.updateClientMfiInfo(userContext, clientMfiInfoUpdate);
// verification
verify(hibernateTransactionHelper).rollbackTransaction();
verify(hibernateTransactionHelper).closeSession();
}
use of org.mifos.domain.builders.ClientMfiInfoUpdateBuilder in project head by mifos.
the class ClientUpdateTest method rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs.
@Test(expected = MifosRuntimeException.class)
public void rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientMfiInfoUpdate clientMfiInfoUpdate = new ClientMfiInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientMfiInfoUpdate.getClientId())).thenReturn(mockedClient);
when(personnelDao.findPersonnelById(clientMfiInfoUpdate.getPersonnelId())).thenReturn(personnel);
doThrow(new RuntimeException()).when(customerDao).save(mockedClient);
// exercise test
customerService.updateClientMfiInfo(userContext, clientMfiInfoUpdate);
// verification
verify(hibernateTransactionHelper).rollbackTransaction();
verify(hibernateTransactionHelper).closeSession();
}
use of org.mifos.domain.builders.ClientMfiInfoUpdateBuilder in project head by mifos.
the class ClientUpdateTest method throwsCheckedExceptionWhenVersionOfClientForUpdateIsDifferentToPersistedClientVersion.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenVersionOfClientForUpdateIsDifferentToPersistedClientVersion() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientMfiInfoUpdate clientMfiInfoUpdate = new ClientMfiInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientMfiInfoUpdate.getClientId())).thenReturn(mockedClient);
doThrow(new CustomerException(Constants.ERROR_VERSION_MISMATCH)).when(mockedClient).validateVersion(clientMfiInfoUpdate.getOrginalClientVersionNumber());
// exercise test
customerService.updateClientMfiInfo(userContext, clientMfiInfoUpdate);
// verify
verify(mockedClient).validateVersion(clientMfiInfoUpdate.getOrginalClientVersionNumber());
}
use of org.mifos.domain.builders.ClientMfiInfoUpdateBuilder in project head by mifos.
the class ClientUpdateTest method clientMfiDetailsAreUpdated.
@Test
public void clientMfiDetailsAreUpdated() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientMfiInfoUpdate clientMfiInfoUpdate = new ClientMfiInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientMfiInfoUpdate.getClientId())).thenReturn(mockedClient);
when(personnelDao.findPersonnelById(clientMfiInfoUpdate.getPersonnelId())).thenReturn(personnel);
// exercise test
customerService.updateClientMfiInfo(userContext, clientMfiInfoUpdate);
// verification
verify(mockedClient).updateMfiInfo(personnel, clientMfiInfoUpdate);
}
Aggregations