Search in sources :

Example 21 with ClientPersonalDetailDto

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

the class ClientIntegrationTest method testFailureCreateActiveClientWithParentGroupInLowerStatus.

@Test
public void testFailureCreateActiveClientWithParentGroupInLowerStatus() throws Exception {
    try {
        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"));
        createParentObjects(CustomerStatus.GROUP_PARTIAL);
        client = new ClientBO(TestUtils.makeUserWithLocales(), clientNameDetailDto.getDisplayName(), CustomerStatus.CLIENT_ACTIVE, null, null, null, null, null, null, personnel, group.getOffice(), group, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
        Assert.fail();
    } catch (CustomerException e) {
        Assert.assertNull(client);
        Assert.assertEquals(ClientConstants.INVALID_CLIENT_STATUS_EXCEPTION, e.getKey());
    }
}
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 22 with ClientPersonalDetailDto

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

the class ClientIntegrationTest method testFailure_InitialSavingsOfferingAtCreate.

@Test
public void testFailure_InitialSavingsOfferingAtCreate() throws Exception {
    savingsOffering1 = TestObjectFactory.createSavingsProduct("Offering1", "s1", SavingsType.MANDATORY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
    ClientNameDetailDto clientView = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "Client", "", "1", "");
    clientView.setNames(ClientRules.getNameSequence());
    ClientNameDetailDto spouseView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
    spouseView.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(savingsOffering1);
    try {
        client = new ClientBO(TestObjectFactory.getContext(), clientView.getDisplayName(), CustomerStatus.CLIENT_PARTIAL, null, null, null, null, null, offerings, personnel, officeBo, null, null, null, null, null, YesNoFlag.NO.getValue(), clientView, spouseView, clientPersonalDetailDto);
    } catch (CustomerException ce) {
        Assert.assertEquals(ClientConstants.ERRORS_DUPLICATE_OFFERING_SELECTED, ce.getKey());
        Assert.assertTrue(true);
    }
    savingsOffering1 = (SavingsOfferingBO) TestObjectFactory.getObject(SavingsOfferingBO.class, savingsOffering1.getPrdOfferingId());
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) 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 23 with ClientPersonalDetailDto

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

the class ClientIntegrationTest method testCreateClientWithoutName.

@Test
public void testCreateClientWithoutName() throws Exception {
    try {
        ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "", "", "", "");
        ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
        ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
        client = new ClientBO(TestUtils.makeUser(), "", CustomerStatus.fromInt(new Short("1")), null, null, null, null, null, null, personnel, officeBo, null, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
        Assert.fail("Client Created");
    } catch (CustomerException ce) {
        Assert.assertNull(client);
        Assert.assertEquals(CustomerConstants.INVALID_NAME, ce.getKey());
    }
}
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 24 with ClientPersonalDetailDto

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

the class TestObjectFactory method createClient.

public static ClientBO createClient(final String customerName, final CustomerStatus status, final CustomerBO parentCustomer, final Date startDate) {
    ClientBO client;
    Short personnel = PersonnelConstants.SYSTEM_USER;
    try {
        ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.MAYBE_CLIENT.getValue(), SAMPLE_SALUTATION, customerName, "", customerName, "");
        clientNameDetailDto.setNames(ClientRules.getNameSequence());
        ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), SAMPLE_SALUTATION, customerName, "middle", customerName, "secondLast");
        ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
        // groups
        if (null == parentCustomer) {
            client = new // UserContext
            ClientBO(// UserContext
            TestUtils.makeUserWithLocales(), // String
            clientNameDetailDto.getDisplayName(), // CustomerStatus
            status, // String externalId
            null, // Date mfiJoiningDate
            null, // Address
            null, // List<CustomFieldDto> customFields
            null, // List<FeeDto> fees
            getFees(), // List<SavingsOfferingBO> offeringsSelected
            null, // Short
            getPersonnel(personnel), // Short
            new OfficePersistence().getOffice(SAMPLE_BRANCH_OFFICE), // MeetingBO
            null, // Short loanOfficerId
            null, // Date dateOfBirth
            null, // String governmentId
            "", // Short trained
            null, // Date trainedDate
            null, // Short groupFlag
            YesNoFlag.NO.getValue(), // ClientNameDetailDto
            clientNameDetailDto, // ClientNameDetailDto
            spouseNameDetailView, // ClientPersonalDetailDto
            clientPersonalDetailDto, // InputStream picture
            null);
        } else {
            client = new ClientBO(TestUtils.makeUserWithLocales(), clientNameDetailDto.getDisplayName(), status, null, null, null, null, getFees(), null, getPersonnel(personnel), parentCustomer.getOffice(), parentCustomer, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
        }
        ApplicationContextProvider.getBean(LegacyClientDao.class).saveClient(client);
        StaticHibernateUtil.flushSession();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return client;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientBO(org.mifos.customers.client.business.ClientBO) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) LegacyClientDao(org.mifos.customers.client.persistence.LegacyClientDao) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) OfficeException(org.mifos.customers.office.exceptions.OfficeException)

Example 25 with ClientPersonalDetailDto

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

the class TestObjectFactory method createClient.

public static ClientBO createClient(final String customerName, final CustomerStatus status, final CustomerBO parentCustomer, final List<FeeDto> fees, final String governmentId, final Date dateOfBirth, final Address address) {
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(132, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
    ClientNameDetailDto clientNameDetailDto = clientNameView(NameType.CLIENT, customerName);
    ClientNameDetailDto spouseNameDetailView = clientNameView(NameType.SPOUSE, customerName);
    ClientBO client;
    try {
        client = new ClientBO(TestUtils.makeUserWithLocales(), customerName, status, null, null, address, null, fees, null, getPersonnel(PersonnelConstants.SYSTEM_USER), new OfficePersistence().getOffice(SAMPLE_BRANCH_OFFICE), parentCustomer, dateOfBirth, governmentId, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
        ApplicationContextProvider.getBean(LegacyClientDao.class).saveClient(client);
    } catch (CustomerException e) {
        throw new RuntimeException(e);
    } catch (PersistenceException e) {
        throw new RuntimeException(e);
    }
    StaticHibernateUtil.flushSession();
    return client;
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ClientBO(org.mifos.customers.client.business.ClientBO) LegacyClientDao(org.mifos.customers.client.persistence.LegacyClientDao) PersistenceException(org.mifos.framework.exceptions.PersistenceException) 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