Search in sources :

Example 66 with CustomFieldDto

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

the class GroupActionStrutsTest method testSuccessfulCreate_UnderBranch.

@Test
public void testSuccessfulCreate_UnderBranch() throws Exception {
    createParentCustomer();
    StaticHibernateUtil.flushAndClearSession();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("branchId", officeId.toString());
    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", "groupUnderBranch");
    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();
    SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, Boolean.FALSE, request);
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "create");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.create_success.toString());
    GroupCustActionForm actionForm = (GroupCustActionForm) request.getSession().getAttribute("groupCustActionForm");
    group = TestObjectFactory.getGroup(actionForm.getCustomerIdAsInt());
    center = TestObjectFactory.getCenter(center.getCustomerId());
    actionForm.setParentCustomer(null);
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) Test(org.junit.Test)

Example 67 with CustomFieldDto

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

the class GroupActionStrutsTest method testPreviewManageFailureForTrainedDate.

@Test
public void testPreviewManageFailureForTrainedDate() 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", "group");
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "Req");
        i++;
    }
    addRequestParameter("trained", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    Assert.assertEquals(1, getErrorSize());
    Assert.assertEquals("Group Trained date not present", 1, getErrorSize(CustomerConstants.TRAINED_DATE_MANDATORY));
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) Test(org.junit.Test)

Example 68 with CustomFieldDto

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

the class GroupActionStrutsTest method testUpdateSuccess.

@Test
public void testUpdateSuccess() throws Exception {
    String newDisplayName = "group_01";
    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", newDisplayName);
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldType", customFieldDef.getFieldType().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "Req");
        i++;
    }
    addRequestParameter("trained", "1");
    addRequestParameter("trainedDate", "20/03/2006");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.previewManage_success.toString());
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "update");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyNoActionMessages();
    verifyForward(ActionForwards.update_success.toString());
    group = TestObjectFactory.getGroup(Integer.valueOf(group.getCustomerId()).intValue());
    Assert.assertTrue(group.isTrained());
    Assert.assertEquals(newDisplayName, group.getDisplayName());
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) Test(org.junit.Test)

Example 69 with CustomFieldDto

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

the class GroupActionStrutsTest method testPreviewFailure_TrainedWithoutTrainedDate.

@Test
public void testPreviewFailure_TrainedWithoutTrainedDate() throws Exception {
    createParentCustomer();
    StaticHibernateUtil.flushAndClearSession();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("centerSystemId", center.getGlobalCustNum());
    actionPerform();
    List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("displayName", "group");
    addRequestParameter("trained", "1");
    addRequestParameter("status", CustomerStatus.GROUP_PENDING.getValue().toString());
    addRequestParameter("formedByPersonnel", center.getPersonnel().getPersonnelId().toString());
    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", "11");
        i++;
    }
    actionPerform();
    Assert.assertEquals("Trained Date", 1, getErrorSize(CustomerConstants.TRAINED_DATE_MANDATORY));
    verifyInputForward();
    center = TestObjectFactory.getCenter(center.getCustomerId());
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) Test(org.junit.Test)

Example 70 with CustomFieldDto

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

the class ClientCustActionStrutsTest method testCreateSuccessWithoutGroup.

@Test
public void testCreateSuccessWithoutGroup() throws Exception {
    SecurityContext securityContext = new SecurityContextImpl();
    MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
    Authentication authentication = new TestingAuthenticationToken(principal, principal);
    securityContext.setAuthentication(authentication);
    SecurityContextHolder.setContext(securityContext);
    //        List<FeeDto> feesToRemove = getFees(RecurrenceType.WEEKLY);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("officeId", "3");
    addRequestParameter("groupFlag", "0");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = (String) request.getAttribute(Constants.CURRENTFLOWKEY);
    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", "Req");
        i++;
    }
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    MeetingBO weeklyMeeting = new MeetingBuilder().weekly().every(1).occuringOnA(WeekDay.WEDNESDAY).build();
    SessionUtils.setAttribute(CustomerConstants.CUSTOMER_MEETING, weeklyMeeting, request);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "mfiInfo");
    addRequestParameter("loanOfficerId", "1");
    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());
//        removeFees(feesToRemove);
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) MifosUser(org.mifos.security.MifosUser) MifosUserBuilder(org.mifos.builders.MifosUserBuilder) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Authentication(org.springframework.security.core.Authentication) SecurityContext(org.springframework.security.core.context.SecurityContext) List(java.util.List) ArrayList(java.util.ArrayList) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) 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