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