Search in sources :

Example 16 with CustomFieldDto

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

the class CenterUpdateUsingCustomerServiceIntegrationTest method canUpdateCenterWithExternalId.

@Test
public void canUpdateCenterWithExternalId() throws Exception {
    // setup
    Short loanOfficerId = center.getPersonnel().getPersonnelId();
    String newExternalId = "ext123";
    LocalDate dateInPast = new LocalDate(center.getMfiJoiningDate()).minusWeeks(4);
    String mfiJoiningDate = new SimpleDateFormat("dd/MM/yyyy").format(dateInPast.toDateMidnight().toDate());
    AddressDto newAddress = null;
    if (center.getAddress() != null) {
        newAddress = Address.toDto(center.getAddress());
    }
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    List<CustomerPositionDto> customerPositions = new ArrayList<CustomerPositionDto>();
    String updatedDisplayName = "Center " + RandomStringUtils.randomAlphanumeric(5);
    CenterUpdate centerUpdate = new CenterUpdate(center.getCustomerId(), updatedDisplayName, center.getVersionNo(), loanOfficerId, newExternalId, mfiJoiningDate, newAddress, customFields, customerPositions);
    UserContext userContext = TestUtils.makeUser();
    // exercise test
    customerService.updateCenter(userContext, centerUpdate);
    // verification
    center = customerDao.findCenterBySystemId(center.getGlobalCustNum());
    assertThat(center.getExternalId(), is(newExternalId));
}
Also used : CenterUpdate(org.mifos.dto.domain.CenterUpdate) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto) AddressDto(org.mifos.dto.domain.AddressDto) LocalDate(org.joda.time.LocalDate) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 17 with CustomFieldDto

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

the class CenterBOIntegrationTest 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 18 with CustomFieldDto

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

the class ClientCustActionStrutsTest method testCreateSuccessWithAssociatedSavingsOfferings.

@Test
public void testCreateSuccessWithAssociatedSavingsOfferings() 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);
    savingsOffering1 = TestObjectFactory.createSavingsProduct("savingsPrd1", "s1", SavingsType.MANDATORY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
    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();
    List<SavingsDetailDto> savingsOfferingList = getSavingsOfferingsFromSession();
    SavingsDetailDto savingsOffering = savingsOfferingList.get(0);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "mfiInfo");
    addRequestParameter("loanOfficerId", "1");
    addRequestParameter("formedByPersonnel", "1");
    addRequestParameter("savingsOffering[0]", savingsOffering.getPrdOfferingId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.preview_success.toString());
    MeetingBO weeklyMeeting = new MeetingBuilder().weekly().every(1).occuringOnA(WeekDay.WEDNESDAY).build();
    SessionUtils.setAttribute(CustomerConstants.CUSTOMER_MEETING, weeklyMeeting, request);
    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());
    Assert.assertNotNull(client);
    Assert.assertNotNull(client.getOfferingsAssociatedInCreate());
    Assert.assertEquals(1, client.getOfferingsAssociatedInCreate().size());
    for (ClientInitialSavingsOfferingEntity offering : client.getOfferingsAssociatedInCreate()) {
        Assert.assertEquals(savingsOffering1.getPrdOfferingId(), offering.getSavingsOffering().getPrdOfferingId());
        Assert.assertTrue(true);
    }
    removeFees(feesToRemove);
    savingsOffering1 = (SavingsOfferingBO) TestObjectFactory.getObject(SavingsOfferingBO.class, savingsOffering.getPrdOfferingId());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) 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) MifosUser(org.mifos.security.MifosUser) MifosUserBuilder(org.mifos.builders.MifosUserBuilder) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) ClientInitialSavingsOfferingEntity(org.mifos.customers.client.business.ClientInitialSavingsOfferingEntity) Date(java.util.Date) 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)

Example 19 with CustomFieldDto

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

the class ClientCustActionStrutsTest method testPreviewFailureForTrainedDate.

@Test
public void testPreviewFailureForTrainedDate() 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");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "Req");
        i++;
    }
    actionPerform();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("formedByPersonnel", "1");
    addRequestParameter("trained", "1");
    addRequestParameter("input", "mfiInfo");
    actionPerform();
    Assert.assertEquals(1, getErrorSize());
    Assert.assertEquals("Client Trained date not present", 1, getErrorSize(CustomerConstants.TRAINED_DATE_MANDATORY));
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) Test(org.junit.Test)

Example 20 with CustomFieldDto

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

the class ClientCustActionStrutsTest 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)

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