Search in sources :

Example 41 with CustomFieldDto

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

the class AddGroupMembershipActionStrutsTest method getCustomFields.

private List<CustomFieldDto> getCustomFields() {
    List<CustomFieldDto> fields = new ArrayList<CustomFieldDto>();
    fields.add(new CustomFieldDto(Short.valueOf("5"), "value1", CustomFieldType.ALPHA_NUMERIC.getValue()));
    fields.add(new CustomFieldDto(Short.valueOf("6"), "value2", CustomFieldType.ALPHA_NUMERIC.getValue()));
    return fields;
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList)

Example 42 with CustomFieldDto

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

the class GroupActionStrutsTest method testPreviewManageSuccessForNameChange_AfterTrainedSet.

/**
     * This test asserts that when a group name for a trained group is edited, there are no errors and the trained date
     * is present in the action form.
     */
@Test
public void testPreviewManageSuccessForNameChange_AfterTrainedSet() throws Exception {
    Calendar cal = new GregorianCalendar();
    cal.set(Calendar.DAY_OF_MONTH, 2);
    cal.set(Calendar.MONTH, 5);
    cal.set(Calendar.YEAR, 2008);
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    createTrainedGroupAndSetInSession(cal.getTime());
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "manage");
    addRequestParameter("officeId", "3");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "previewManage");
    addRequestParameter("officeId", "3");
    // editing group name
    addRequestParameter("displayName", "group123");
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "Req");
        i++;
    }
    addRequestParameter("trained", "1");
    addRequestParameter("trainedDate", "2/6/2008");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    GroupCustActionForm actionForm = (GroupCustActionForm) getActionForm();
    Assert.assertEquals("2/6/2008", actionForm.getTrainedDate());
    Assert.assertEquals(0, getErrorSize());
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) GregorianCalendar(java.util.GregorianCalendar) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) Test(org.junit.Test)

Example 43 with CustomFieldDto

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

the class GroupActionStrutsTest method testPreviewManageFailureForName.

@Test
public void testPreviewManageFailureForName() throws Exception {
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    createGroupWithCenterAndSetInSession();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "manage");
    addRequestParameter("officeId", "3");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "previewManage");
    addRequestParameter("officeId", "3");
    addRequestParameter("displayName", "");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "Req");
        i++;
    }
    addRequestParameter("trained", "1");
    addRequestParameter("trainedDate", "20/3/2006");
    actionPerform();
    Assert.assertEquals(1, getErrorSize());
    Assert.assertEquals("Group Name not present", 1, getErrorSize(CustomerConstants.NAME));
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) Test(org.junit.Test)

Example 44 with CustomFieldDto

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

the class GroupActionStrutsTest method testFailurePreview_WithoutMandatoryCustomField_IfAny.

@Test
public void testFailurePreview_WithoutMandatoryCustomField_IfAny() throws Exception {
    createParentCustomer();
    StaticHibernateUtil.flushAndClearSession();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("centerSystemId", center.getGlobalCustNum());
    actionPerform();
    List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
    boolean isCustomFieldMandatory = false;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        if (customFieldDef.isMandatory()) {
            isCustomFieldMandatory = true;
            break;
        }
    }
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("displayName", "group");
    addRequestParameter("status", CustomerStatus.GROUP_PENDING.getValue().toString());
    addRequestParameter("formedByPersonnel", center.getPersonnel().getPersonnelId().toString());
    addRequestParameter("loanOfficerId", center.getLoanOfficerId().toString());
    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));
        verifyInputForward();
    } else {
        Assert.assertEquals("CustomField", 0, getErrorSize(CustomerConstants.CUSTOM_FIELD));
        verifyForward(ActionForwards.preview_success.toString());
    }
    center = TestObjectFactory.getCenter(center.getCustomerId());
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) Test(org.junit.Test)

Example 45 with CustomFieldDto

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

the class GroupActionStrutsTest method testFailureCreate_DuplicateName.

@Test
public void testFailureCreate_DuplicateName() throws Exception {
    createGroupWithCenter();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("centerSystemId", center.getGlobalCustNum());
    actionPerform();
    List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("displayName", "group");
    addRequestParameter("status", CustomerStatus.GROUP_PENDING.getValue().toString());
    addRequestParameter("formedByPersonnel", center.getPersonnel().getPersonnelId().toString());
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "11");
        i++;
    }
    actionPerform();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "create");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyActionErrors(new String[] { CustomerConstants.ERRORS_DUPLICATE_CUSTOMER });
    verifyForward(ActionForwards.create_failure.toString());
    group = TestObjectFactory.getGroup(group.getCustomerId());
    center = TestObjectFactory.getCenter(center.getCustomerId());
    GroupCustActionForm actionForm = (GroupCustActionForm) request.getSession().getAttribute("groupCustActionForm");
    actionForm.setParentCustomer(null);
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) 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