Search in sources :

Example 11 with BusinessActivityEntity

use of org.mifos.application.master.business.BusinessActivityEntity in project head by mifos.

the class ClientCustActionStrutsTest method testFailurePreview_FeeFrequencyMismatch.

@Test
public void testFailurePreview_FeeFrequencyMismatch() throws Exception {
    List<FeeDto> feesToRemove = getFees(RecurrenceType.MONTHLY);
    StaticHibernateUtil.flushAndClearSession();
    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);
    List<ApplicableAccountFeeDto> feeList = (List<ApplicableAccountFeeDto>) SessionUtils.getAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, request);
    Assert.assertEquals(1, feeList.size());
    ApplicableAccountFeeDto fee = feeList.get(0);
    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();
    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.WEEKLY, (short) 2, new Date(), MeetingType.CUSTOMER_MEETING), request);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    Assert.assertEquals("Fee", 1, getErrorSize(CustomerConstants.ERRORS_FEE_FREQUENCY_MISMATCH));
    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 12 with BusinessActivityEntity

use of org.mifos.application.master.business.BusinessActivityEntity in project head by mifos.

the class ClientCustActionStrutsTest method testSuccessfulUpdatePersonalInfo_AuditLog.

@Test
public void testSuccessfulUpdatePersonalInfo_AuditLog() throws Exception {
    createClientForAuditLog();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "editPersonalInfo");
    addRequestParameter("officeId", "3");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    List<CustomFieldDto> customFieldDefs = getCustomFieldFromSession();
    List<BusinessActivityEntity> povertyStatusList = (List<BusinessActivityEntity>) SessionUtils.getAttribute(ClientConstants.POVERTY_STATUS, request);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "previewEditPersonalInfo");
    addRequestParameter("clientName.salutation", Integer.valueOf("48").toString());
    addRequestParameter("clientName.firstName", "Diti");
    addRequestParameter("clientName.middleName", "S");
    addRequestParameter("clientName.secondLastName", "S");
    addRequestParameter("clientName.lastName", "Sharma");
    addRequestParameter("spouseName.firstName", "Abc");
    addRequestParameter("spouseName.middleName", "A");
    addRequestParameter("spouseName.secondLastName", "A");
    addRequestParameter("spouseName.lastName", "Sharma");
    addRequestParameter("spouseName.nameType", "2");
    addRequestParameter("clientDetailView.povertyStatus", povertyStatusList.get(1).getId().toString());
    addRequestParameter("clientDetailView.gender", Integer.valueOf("50").toString());
    addRequestParameter("clientDetailView.citizenship", Integer.valueOf("131").toString());
    addRequestParameter("clientDetailView.ethnicity", Integer.valueOf("219").toString());
    addRequestParameter("clientDetailView.handicapped", Integer.valueOf("139").toString());
    addRequestParameter("clientDetailView.businessActivities", "");
    addRequestParameter("clientDetailView.maritalStatus", Integer.valueOf("67").toString());
    addRequestParameter("clientDetailView.educationLevel", Integer.valueOf("227").toString());
    addRequestParameter("clientDetailView.numChildren", Integer.valueOf("2").toString());
    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());
    client = TestObjectFactory.getClient(client.getCustomerId());
    Assert.assertEquals(219, client.getCustomerDetail().getEthnicity().shortValue(), DELTA);
    StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
    List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.CLIENT, client.getCustomerId());
    Assert.assertEquals(1, auditLogList.size());
    Assert.assertEquals(EntityType.CLIENT.getValue(), auditLogList.get(0).getEntityType());
    Assert.assertEquals(client.getCustomerId(), auditLogList.get(0).getEntityId());
    for (AuditLogRecord auditLogRecord : auditLogList.get(0).getAuditLogRecords()) {
        if (auditLogRecord.getFieldName().equalsIgnoreCase("Gender")) {
            matchValues(auditLogRecord, "Male", "Female");
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Ethnicity")) {
            matchValues(auditLogRecord, "OBC", "FC");
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Number Of Children")) {
            matchValues(auditLogRecord, "1", "2");
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Handicapped")) {
            matchValues(auditLogRecord, "Yes", "No");
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Marital Status")) {
            matchValues(auditLogRecord, "Married", "UnMarried");
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Education Level")) {
            matchValues(auditLogRecord, "Both Literate", "Both Illiterate");
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Poverty Status")) {
            matchValues(auditLogRecord, "Very poor", "Poor");
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Citizenship")) {
            matchValues(auditLogRecord, "Hindu", "Muslim");
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Business Activities")) {
            matchValues(auditLogRecord, "Trading", "-");
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Salutation")) {
            matchValues(auditLogRecord, "Mr", "Mrs");
        }
    }
}
Also used : BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) List(java.util.List) ArrayList(java.util.ArrayList) AuditTransactionForTests(org.mifos.framework.hibernate.helper.AuditTransactionForTests) AuditLog(org.mifos.framework.components.audit.business.AuditLog) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)12 BusinessActivityEntity (org.mifos.application.master.business.BusinessActivityEntity)12 List (java.util.List)10 Test (org.junit.Test)10 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)9 Date (java.util.Date)6 MeetingBO (org.mifos.application.meeting.business.MeetingBO)6 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)5 SavingsDetailDto (org.mifos.dto.domain.SavingsDetailDto)4 FeeDto (org.mifos.accounts.fees.business.FeeDto)3 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)3 MifosUser (org.mifos.security.MifosUser)3 MifosUserBuilder (org.mifos.builders.MifosUserBuilder)2 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)2 ValueListElement (org.mifos.dto.domain.ValueListElement)2 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)2 Authentication (org.springframework.security.core.Authentication)2 SecurityContext (org.springframework.security.core.context.SecurityContext)2 SecurityContextImpl (org.springframework.security.core.context.SecurityContextImpl)2 IOException (java.io.IOException)1