Search in sources :

Example 6 with ClientPersonalDetailDto

use of org.mifos.dto.screen.ClientPersonalDetailDto in project head by mifos.

the class ClientIntegrationTest method testSuccessfulCreateWithoutFeeAndCustomField.

@Test
public void testSuccessfulCreateWithoutFeeAndCustomField() throws Exception {
    String name = "Client 1";
    Short povertyStatus = Short.valueOf("41");
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "Client", "", "1", "");
    clientNameDetailDto.setNames(ClientRules.getNameSequence());
    ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
    spouseNameDetailView.setNames(ClientRules.getNameSequence());
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), povertyStatus);
    client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.fromInt(new Short("1")), null, null, null, null, null, null, personnel, officeBo, null, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
    legacyClientDao.saveClient(client);
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getClient(client.getCustomerId());
    Assert.assertEquals(name, client.getDisplayName());
    Assert.assertEquals(povertyStatus, client.getCustomerDetail().getPovertyStatus());
    Assert.assertEquals(officeId, client.getOffice().getOfficeId());
}
Also used : ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) Test(org.junit.Test)

Example 7 with ClientPersonalDetailDto

use of org.mifos.dto.screen.ClientPersonalDetailDto in project head by mifos.

the class ClientIntegrationTest method testCreateClientWithoutOffice.

@Test
public void testCreateClientWithoutOffice() throws Exception {
    try {
        ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "", "last", "");
        clientNameDetailDto.setNames(ClientRules.getNameSequence());
        ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
        spouseNameDetailView.setNames(ClientRules.getNameSequence());
        ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
        client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.fromInt(new Short("1")), null, null, null, null, null, null, personnel, null, null, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
        Assert.fail("Client Created");
    } catch (CustomerException ce) {
        Assert.assertNull(client);
        Assert.assertEquals(ce.getKey(), CustomerConstants.INVALID_OFFICE);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) Test(org.junit.Test)

Example 8 with ClientPersonalDetailDto

use of org.mifos.dto.screen.ClientPersonalDetailDto in project head by mifos.

the class ClientIntegrationTest method testSuccessfulCreateInActiveState_WithAssociatedSavingsOffering.

@Test
public void testSuccessfulCreateInActiveState_WithAssociatedSavingsOffering() throws Exception {
    savingsOffering1 = TestObjectFactory.createSavingsProduct("offering1", "s1", SavingsType.MANDATORY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
    StaticHibernateUtil.flushSession();
    List<SavingsOfferingBO> selectedOfferings = new ArrayList<SavingsOfferingBO>();
    selectedOfferings.add(savingsOffering1);
    String name = "Client 1";
    Short povertyStatus = Short.valueOf("41");
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "Client", "", "1", "");
    clientNameDetailDto.setNames(ClientRules.getNameSequence());
    ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
    spouseNameDetailView.setNames(ClientRules.getNameSequence());
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), povertyStatus);
    client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.CLIENT_ACTIVE, null, null, null, null, null, selectedOfferings, personnel, new OfficePersistence().getOffice(TestObjectFactory.SAMPLE_BRANCH_OFFICE), getMeeting(), personnel, null, null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
    legacyClientDao.saveClient(client);
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getClient(client.getCustomerId());
    Assert.assertEquals(name, client.getDisplayName());
    Assert.assertEquals(1, client.getOfferingsAssociatedInCreate().size());
    Assert.assertEquals(2, client.getAccounts().size());
    for (AccountBO account : client.getAccounts()) {
        if (account instanceof SavingsBO) {
            Assert.assertEquals(savingsOffering1.getPrdOfferingId(), ((SavingsBO) account).getSavingsOffering().getPrdOfferingId());
            Assert.assertNotNull(account.getGlobalAccountNum());
            Assert.assertTrue(true);
        }
    }
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getClient(client.getCustomerId());
    savingsOffering1 = null;
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ArrayList(java.util.ArrayList) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Date(java.sql.Date) Test(org.junit.Test)

Example 9 with ClientPersonalDetailDto

use of org.mifos.dto.screen.ClientPersonalDetailDto in project head by mifos.

the class ClientIntegrationTest method testInitialSavingsOfferingAtCreate.

@Test
public void testInitialSavingsOfferingAtCreate() throws Exception {
    savingsOffering1 = TestObjectFactory.createSavingsProduct("Offering1", "s1", SavingsType.MANDATORY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
    savingsOffering2 = TestObjectFactory.createSavingsProduct("Offering2", "s2", SavingsType.VOLUNTARY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "Client", "", "1", "");
    clientNameDetailDto.setNames(ClientRules.getNameSequence());
    ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
    spouseNameDetailView.setNames(ClientRules.getNameSequence());
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
    List<SavingsOfferingBO> offerings = new ArrayList<SavingsOfferingBO>();
    offerings.add(savingsOffering1);
    offerings.add(savingsOffering2);
    client = new ClientBO(TestObjectFactory.getContext(), clientNameDetailDto.getDisplayName(), CustomerStatus.CLIENT_PARTIAL, null, null, null, null, null, offerings, personnel, officeBo, null, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
    legacyClientDao.saveClient(client);
    StaticHibernateUtil.flushSession();
    client = customerDao.findClientById(client.getCustomerId());
    Assert.assertEquals(offerings.size(), client.getOfferingsAssociatedInCreate().size());
    for (ClientInitialSavingsOfferingEntity clientOffering : client.getOfferingsAssociatedInCreate()) {
        if (clientOffering.getSavingsOffering().getPrdOfferingId().equals(savingsOffering1.getPrdOfferingId())) {
            Assert.assertTrue(true);
        }
        if (clientOffering.getSavingsOffering().getPrdOfferingId().equals(savingsOffering2.getPrdOfferingId())) {
            Assert.assertTrue(true);
        }
    }
    savingsOffering1 = (SavingsOfferingBO) TestObjectFactory.getObject(SavingsOfferingBO.class, savingsOffering1.getPrdOfferingId());
    savingsOffering2 = (SavingsOfferingBO) TestObjectFactory.getObject(SavingsOfferingBO.class, savingsOffering2.getPrdOfferingId());
}
Also used : ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ArrayList(java.util.ArrayList) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) Date(java.sql.Date) Test(org.junit.Test)

Example 10 with ClientPersonalDetailDto

use of org.mifos.dto.screen.ClientPersonalDetailDto in project head by mifos.

the class AddGroupMembershipActionStrutsTest method createAndSetClientInSession.

private void createAndSetClientInSession() throws Exception {
    OfficeBO office = new OfficePersistence().getOffice(TestObjectFactory.HEAD_OFFICE);
    PersonnelBO personnel = legacyPersonnelDao.getPersonnel(PersonnelConstants.TEST_USER);
    meeting = getMeeting();
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), 1, "Client", "", "1", "");
    clientNameDetailDto.setNames(ClientRules.getNameSequence());
    ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), 1, "first", "middle", "last", "secondLast");
    spouseNameDetailView.setNames(ClientRules.getNameSequence());
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
    client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.fromInt(new Short("1")), null, null, new Address(), getCustomFields(), null, null, personnel, office, meeting, personnel, new java.util.Date(), null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
    legacyClientDao.saveClient(client);
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getClient(Integer.valueOf(client.getCustomerId()).intValue());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
}
Also used : Address(org.mifos.framework.business.util.Address) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ClientBO(org.mifos.customers.client.business.ClientBO) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence)

Aggregations

ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)26 ClientPersonalDetailDto (org.mifos.dto.screen.ClientPersonalDetailDto)26 Test (org.junit.Test)13 CustomerException (org.mifos.customers.exceptions.CustomerException)12 ClientBO (org.mifos.customers.client.business.ClientBO)9 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)8 ArrayList (java.util.ArrayList)7 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)7 InputStream (java.io.InputStream)5 LocalDate (org.joda.time.LocalDate)5 OfficeBO (org.mifos.customers.office.business.OfficeBO)5 AddressDto (org.mifos.dto.domain.AddressDto)5 ClientFamilyDetailDto (org.mifos.dto.screen.ClientFamilyDetailDto)5 Date (java.sql.Date)4 Date (java.util.Date)4 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)4 ClientCreationDetail (org.mifos.dto.domain.ClientCreationDetail)4 MeetingDto (org.mifos.dto.domain.MeetingDto)4 Address (org.mifos.framework.business.util.Address)4 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)3