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());
}
}
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());
}
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());
}
}
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;
}
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;
}
Aggregations