Search in sources :

Example 11 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto 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 12 with ClientNameDetailDto

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

the class ClientNameDetailDtoTest method shouldGetDisplayName.

@Test
public void shouldGetDisplayName() {
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto();
    clientNameDetailDto.setNames(ClientRules.getNameSequence());
    clientNameDetailDto.setFirstName(" First  ");
    clientNameDetailDto.setLastName(" Last ");
    assertThat(clientNameDetailDto.getDisplayName(), is("First Last"));
}
Also used : ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) Test(org.junit.Test)

Example 13 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto 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 14 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto 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 15 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto 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)41 ClientPersonalDetailDto (org.mifos.dto.screen.ClientPersonalDetailDto)26 CustomerException (org.mifos.customers.exceptions.CustomerException)15 Test (org.junit.Test)14 ClientBO (org.mifos.customers.client.business.ClientBO)14 ArrayList (java.util.ArrayList)12 ClientFamilyDetailDto (org.mifos.dto.screen.ClientFamilyDetailDto)10 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)9 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)8 Address (org.mifos.framework.business.util.Address)8 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)7 OfficeBO (org.mifos.customers.office.business.OfficeBO)7 AddressDto (org.mifos.dto.domain.AddressDto)7 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)7 DateTime (org.joda.time.DateTime)6 MeetingBO (org.mifos.application.meeting.business.MeetingBO)6 UserContext (org.mifos.security.util.UserContext)6 InputStream (java.io.InputStream)5 ClientCreationDetail (org.mifos.dto.domain.ClientCreationDetail)5 MeetingDto (org.mifos.dto.domain.MeetingDto)5