Search in sources :

Example 36 with ClientNameDetailDto

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

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

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

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

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