Search in sources :

Example 31 with CustomFieldDto

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

the class CustomerCreationDaoHibernateIntegrationTest method testShouldCreateCustomerAndCustomerAccount.

@Test
public void testShouldCreateCustomerAndCustomerAccount() throws Exception {
    String displayName = "centerCascade";
    Address address = null;
    final List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    final List<FeeDto> fees = new ArrayList<FeeDto>();
    final String externalId = null;
    final Date mfiJoiningDate = new DateTime().minusDays(1).toDate();
    final OfficeBO existingOffice = IntegrationTestObjectMother.sampleBranchOffice();
    final PersonnelBO loanOfficer = IntegrationTestObjectMother.testUser();
    UserContext userContext = new UserContext();
    userContext.setId(loanOfficer.getPersonnelId());
    userContext.setBranchId(existingOffice.getOfficeId());
    userContext.setBranchGlobalNum(existingOffice.getGlobalOfficeNum());
    center = new CenterBO(userContext, displayName, address, customFields, fees, externalId, mfiJoiningDate, existingOffice, weeklyMeeting, loanOfficer, new CustomerPersistence());
    StaticHibernateUtil.startTransaction();
    customerDao.save(center);
    StaticHibernateUtil.flushSession();
    assertThat(center.getCustomerAccount(), is(notNullValue()));
    assertThat(center.getGlobalCustNum(), is(nullValue()));
}
Also used : Address(org.mifos.framework.business.util.Address) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) FeeDto(org.mifos.accounts.fees.business.FeeDto) CenterBO(org.mifos.customers.center.business.CenterBO) Date(java.util.Date) DateTime(org.joda.time.DateTime) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) Test(org.junit.Test)

Example 32 with CustomFieldDto

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

the class PersonnelNoteActionStrutsTest method createPersonnelAndSetInSession.

private void createPersonnelAndSetInSession(OfficeBO office, PersonnelLevel personnelLevel) throws Exception {
    List<CustomFieldDto> customFieldDto = new ArrayList<CustomFieldDto>();
    customFieldDto.add(new CustomFieldDto(Short.valueOf("9"), "123456", CustomFieldType.NUMERIC.getValue()));
    Address address = new Address("abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd");
    Name name = new Name("XYZ", null, null, "Last Name");
    Date date = new Date();
    personnel = new PersonnelBO(personnelLevel, office, Integer.valueOf("1"), Short.valueOf("1"), "ABCD", "XYZ", "xyz@yahoo.com", null, customFieldDto, name, "111111", date, Integer.valueOf("1"), Integer.valueOf("1"), date, date, address, userContext.getId(), null, null);
    IntegrationTestObjectMother.createPersonnel(personnel);
    personnel = IntegrationTestObjectMother.findPersonnelById(personnel.getPersonnelId());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, personnel, request);
}
Also used : Address(org.mifos.framework.business.util.Address) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) Date(java.util.Date) Name(org.mifos.framework.business.util.Name)

Example 33 with CustomFieldDto

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

the class PersonnelSettingsActionStrutsTest method createPersonnel.

private PersonnelBO createPersonnel(OfficeBO office, PersonnelLevel personnelLevel) throws Exception {
    List<CustomFieldDto> customFieldDto = new ArrayList<CustomFieldDto>();
    customFieldDto.add(new CustomFieldDto(Short.valueOf("9"), "123456", CustomFieldType.NUMERIC.getValue()));
    Address address = new Address("abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd");
    Date date = new Date();
    personnel = new PersonnelBO(personnelLevel, office, Integer.valueOf("1"), Short.valueOf("1"), "ABCD", "XYZ", "xyz@yahoo.com", getRoles(), customFieldDto, new Name("XYZ", null, null, "ABC"), "111111", date, Integer.valueOf("1"), Integer.valueOf("1"), date, date, address, userContext.getId(), new Date(), new HashSet());
    IntegrationTestObjectMother.createPersonnel(personnel);
    return IntegrationTestObjectMother.findPersonnelById(personnel.getPersonnelId());
}
Also used : Address(org.mifos.framework.business.util.Address) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) Date(java.util.Date) Name(org.mifos.framework.business.util.Name) BusinessServiceName(org.mifos.framework.util.helpers.BusinessServiceName) HashSet(java.util.HashSet)

Example 34 with CustomFieldDto

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

the class GroupActionStrutsTest method testSuccessfulPreview.

@Test
public void testSuccessfulPreview() throws Exception {
    List<FeeDto> feesToRemove = getFees(RecurrenceType.WEEKLY);
    createParentCustomer();
    StaticHibernateUtil.flushAndClearSession();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("centerSystemId", center.getGlobalCustNum());
    actionPerform();
    List<ApplicableAccountFeeDto> feeList = getFeesFromSession();
    ApplicableAccountFeeDto fee = feeList.get(0);
    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());
    addRequestParameter("loanOfficerId", center.getLoanOfficerId().toString());
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "11");
        i++;
    }
    addRequestParameter("selectedFee[0].feeId", fee.getFeeId().toString());
    addRequestParameter("selectedFee[0].amount", fee.getAmount());
    actionPerform();
    Assert.assertEquals(0, getErrorSize());
    verifyForward(ActionForwards.preview_success.toString());
    verifyNoActionErrors();
    verifyNoActionMessages();
    StaticHibernateUtil.flushAndClearSession();
    removeFees(feesToRemove);
    Assert.assertNotNull(SessionUtils.getAttribute(CustomerConstants.PENDING_APPROVAL_DEFINED, request));
    center = TestObjectFactory.getCenter(center.getCustomerId());
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) Test(org.junit.Test)

Example 35 with CustomFieldDto

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

the class GroupActionStrutsTest method testUpdateSuccessForLogging.

@Test
public void testUpdateSuccessForLogging() 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("externalId", "1");
    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();
    verifyNoActionErrors();
    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)

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