Search in sources :

Example 1 with ClientFamilyInfoUpdate

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());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) ClientBO(org.mifos.customers.client.business.ClientBO) ClientFamilyInfoUpdate(org.mifos.dto.domain.ClientFamilyInfoUpdate) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with ClientFamilyInfoUpdate

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());
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) UserContext(org.mifos.security.util.UserContext) ClientFamilyInfoUpdate(org.mifos.dto.domain.ClientFamilyInfoUpdate) ClientFamilyInfoUpdateBuilder(org.mifos.domain.builders.ClientFamilyInfoUpdateBuilder) Test(org.junit.Test)

Example 3 with ClientFamilyInfoUpdate

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();
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) UserContext(org.mifos.security.util.UserContext) ClientFamilyInfoUpdate(org.mifos.dto.domain.ClientFamilyInfoUpdate) ClientFamilyInfoUpdateBuilder(org.mifos.domain.builders.ClientFamilyInfoUpdateBuilder) Test(org.junit.Test)

Example 4 with ClientFamilyInfoUpdate

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);
}
Also used : UserContext(org.mifos.security.util.UserContext) ClientFamilyInfoUpdate(org.mifos.dto.domain.ClientFamilyInfoUpdate) ClientFamilyInfoUpdateBuilder(org.mifos.domain.builders.ClientFamilyInfoUpdateBuilder) Test(org.junit.Test)

Example 5 with 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);
}
Also used : InOrder(org.mockito.InOrder) UserContext(org.mifos.security.util.UserContext) ClientFamilyInfoUpdate(org.mifos.dto.domain.ClientFamilyInfoUpdate) ClientFamilyInfoUpdateBuilder(org.mifos.domain.builders.ClientFamilyInfoUpdateBuilder) Test(org.junit.Test)

Aggregations

ClientFamilyInfoUpdate (org.mifos.dto.domain.ClientFamilyInfoUpdate)5 Test (org.junit.Test)4 ClientFamilyInfoUpdateBuilder (org.mifos.domain.builders.ClientFamilyInfoUpdateBuilder)4 UserContext (org.mifos.security.util.UserContext)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 ClientBO (org.mifos.customers.client.business.ClientBO)1 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 CloseSession (org.mifos.framework.util.helpers.CloseSession)1 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)1 InOrder (org.mockito.InOrder)1