Search in sources :

Example 21 with CustomFieldDto

use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.

the class ClientCustActionStrutsTest method testFailureNext_WithoutMandatoryCustomField_IfAny.

@Test
public void testFailureNext_WithoutMandatoryCustomField_IfAny() throws Exception {
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("officeId", "3");
    addRequestParameter("groupFlag", "0");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    List<CustomFieldDto> customFieldDefs = getCustomFieldFromSession();
    boolean isCustomFieldMandatory = false;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        if (customFieldDef.isMandatory()) {
            isCustomFieldMandatory = true;
            break;
        }
    }
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "next");
    addRequestParameter("officeId", "3");
    addRequestParameter("clientName.salutation", "1");
    addRequestParameter("clientName.firstName", "Client");
    addRequestParameter("clientName.lastName", "LastName");
    addRequestParameter("spouseName.firstName", "Spouse");
    addRequestParameter("spouseName.lastName", "LastName");
    addRequestParameter("spouseName.nameType", "1");
    addRequestDateParameter("dateOfBirth", "20/3/1987");
    addRequestParameter("gender", "1");
    addRequestParameter("input", "personalInfo");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "");
        i++;
    }
    actionPerform();
    if (isCustomFieldMandatory) {
        Assert.assertEquals("CustomField", 1, getErrorSize(CustomerConstants.CUSTOM_FIELD));
    } else {
        Assert.assertEquals("CustomField", 0, getErrorSize(CustomerConstants.CUSTOM_FIELD));
    }
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) Test(org.junit.Test)

Example 22 with CustomFieldDto

use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.

the class ClientCustActionStrutsTest method testPreviewFailureFormedByPersonnelNotPresent.

@Test
public void testPreviewFailureFormedByPersonnelNotPresent() throws Exception {
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("officeId", "3");
    addRequestParameter("groupFlag", "0");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = request.getAttribute(Constants.CURRENTFLOWKEY).toString();
    List<CustomFieldDto> customFieldDefs = getCustomFieldFromSession();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "next");
    addRequestParameter("officeId", "3");
    addRequestParameter("clientName.salutation", "1");
    addRequestParameter("clientName.firstName", "Client");
    addRequestParameter("clientName.lastName", "LastName");
    addRequestParameter("spouseName.firstName", "Spouse");
    addRequestParameter("spouseName.lastName", "LastName");
    addRequestParameter("spouseName.nameType", "1");
    addRequestDateParameter("dateOfBirth", "20/3/1987");
    addRequestParameter("clientDetailView.gender", "1");
    addRequestParameter("input", "personalInfo");
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "Req");
        i++;
    }
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "mfiInfo");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    Assert.assertEquals(1, getErrorSize());
    Assert.assertEquals("Client formed by not present", 1, getErrorSize(CustomerConstants.FORMED_BY_LOANOFFICER));
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) Test(org.junit.Test)

Example 23 with CustomFieldDto

use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.

the class ClientCustActionStrutsTest method testPreviewSuccess.

@Test
public void testPreviewSuccess() throws Exception {
    List<FeeDto> feesToRemove = getFees(RecurrenceType.MONTHLY);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("officeId", "3");
    addRequestParameter("groupFlag", "0");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = (String) request.getAttribute(Constants.CURRENTFLOWKEY);
    List<CustomFieldDto> customFieldDefs = getCustomFieldFromSession();
    List<BusinessActivityEntity> povertyStatus = (List<BusinessActivityEntity>) SessionUtils.getAttribute(ClientConstants.POVERTY_STATUS, request);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "next");
    addRequestParameter("officeId", "3");
    addRequestParameter("clientName.salutation", "1");
    addRequestParameter("clientName.firstName", "Client");
    addRequestParameter("clientName.lastName", "LastName");
    addRequestParameter("spouseName.firstName", "Spouse");
    addRequestParameter("spouseName.lastName", "LastName");
    addRequestParameter("spouseName.nameType", "1");
    addRequestDateParameter("dateOfBirth", "20/3/1987");
    addRequestParameter("clientDetailView.gender", "1");
    addRequestParameter("input", "personalInfo");
    addRequestParameter("customerDetail.povertyStatus", povertyStatus.get(0).getId().toString());
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "Req");
        i++;
    }
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    List<ApplicableAccountFeeDto> feeList = (List<ApplicableAccountFeeDto>) SessionUtils.getAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, request);
    ApplicableAccountFeeDto fee = feeList.get(0);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "mfiInfo");
    addRequestParameter("formedByPersonnel", "1");
    addRequestParameter("selectedFee[0].feeId", fee.getFeeId().toString());
    addRequestParameter("selectedFee[0].amount", fee.getAmount());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(CustomerConstants.CUSTOMER_MEETING, new MeetingBO(RecurrenceType.MONTHLY, Short.valueOf("2"), new Date(), MeetingType.CUSTOMER_MEETING), request);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.preview_success.toString());
    removeFees(feesToRemove);
}
Also used : BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) List(java.util.List) ArrayList(java.util.ArrayList) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) Date(java.util.Date) Test(org.junit.Test)

Example 24 with CustomFieldDto

use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.

the class ClientCustActionStrutsTest method testSuccessfulUpdatePersonalInfo.

@Test
public void testSuccessfulUpdatePersonalInfo() throws Exception {
    createAndSetClientInSession();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "editPersonalInfo");
    addRequestParameter("officeId", "3");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    List<CustomFieldDto> customFieldDefs = getCustomFieldFromSession();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "previewEditPersonalInfo");
    addRequestParameter("clientDetailView.ethnicity", "1");
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "11");
        addRequestParameter("customField[" + i + "].fieldType", "1");
        i++;
    }
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.previewEditPersonalInfo_success.toString());
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "updatePersonalInfo");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyForward(ActionForwards.updatePersonalInfo_success.toString());
    Assert.assertEquals(1, client.getCustomerDetail().getEthnicity().shortValue());
    client = TestObjectFactory.getClient(client.getCustomerId());
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) Test(org.junit.Test)

Example 25 with CustomFieldDto

use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.

the class ClientCustActionStrutsTest method testCreateSuccessUnderGroup.

@Test
public void testCreateSuccessUnderGroup() throws Exception {
    createParentCustomer();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("parentGroupId", group.getCustomerId().toString());
    addRequestParameter("groupFlag", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = request.getAttribute(Constants.CURRENTFLOWKEY).toString();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.load_success.toString());
    List<BusinessActivityEntity> povertyStatus = (List<BusinessActivityEntity>) SessionUtils.getAttribute(ClientConstants.POVERTY_STATUS, request);
    List<CustomFieldDto> customFieldDefs = getCustomFieldFromSession();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "next");
    addRequestParameter("officeId", "3");
    addRequestParameter("clientName.salutation", "1");
    addRequestParameter("clientName.firstName", "Client");
    addRequestParameter("clientName.lastName", "LastName");
    addRequestParameter("spouseName.firstName", "Spouse");
    addRequestParameter("spouseName.lastName", "LastName");
    addRequestParameter("spouseName.nameType", "1");
    addRequestDateParameter("dateOfBirth", "20/3/1987");
    addRequestParameter("clientDetailView.gender", "1");
    addRequestParameter("input", "personalInfo");
    addRequestParameter("customerDetail.povertyStatus", povertyStatus.get(0).getId().toString());
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "20/3/1987");
        i++;
    }
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.next_success.toString());
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "mfiInfo");
    addRequestParameter("formedByPersonnel", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.preview_success.toString());
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "create");
    addRequestParameter("input", "create");
    addRequestParameter("status", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.create_success.toString());
    ClientCustActionForm actionForm = (ClientCustActionForm) request.getSession().getAttribute("clientCustActionForm");
    client = TestObjectFactory.getClient(actionForm.getCustomerIdAsInt());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)86 ArrayList (java.util.ArrayList)48 Test (org.junit.Test)36 UserContext (org.mifos.security.util.UserContext)16 Date (java.util.Date)14 Address (org.mifos.framework.business.util.Address)14 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)13 AddressDto (org.mifos.dto.domain.AddressDto)12 List (java.util.List)10 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)10 SimpleDateFormat (java.text.SimpleDateFormat)9 BusinessActivityEntity (org.mifos.application.master.business.BusinessActivityEntity)9 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)8 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)8 CustomerPositionDto (org.mifos.dto.domain.CustomerPositionDto)8 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)7 MeetingBO (org.mifos.application.meeting.business.MeetingBO)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)6 GroupCustActionForm (org.mifos.customers.group.struts.actionforms.GroupCustActionForm)6 OfficeBO (org.mifos.customers.office.business.OfficeBO)6