use of org.mifos.dto.domain.ClientFamilyInfoUpdate in project head by mifos.
the class PictureFormFile method updateFamilyInfo.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateFamilyInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientCustActionForm actionForm = (ClientCustActionForm) form;
ClientBO clientInSession = getClientFromSession(request);
Integer customerId = clientInSession.getCustomerId();
ClientFamilyInfoUpdate clientFamilyInfoUpdate = new ClientFamilyInfoUpdate(customerId, clientInSession.getVersionNo(), actionForm.getFamilyPrimaryKey(), actionForm.getFamilyNames(), actionForm.getFamilyDetails());
this.clientServiceFacade.updateFamilyInfo(clientFamilyInfoUpdate);
actionForm.setFamilyDateOfBirth();
actionForm.constructFamilyDetails();
SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
return mapping.findForward(ActionForwards.updateFamilyInfo_success.toString());
}
use of org.mifos.dto.domain.ClientFamilyInfoUpdate 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.dto.domain.ClientFamilyInfoUpdate 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.dto.domain.ClientFamilyInfoUpdate 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.dto.domain.ClientFamilyInfoUpdate 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