use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.
the class ClientCustActionStrutsTest method createClientForAuditLog.
private void createClientForAuditLog() throws Exception {
OfficeBO office = new OfficePersistence().getOffice(TestObjectFactory.HEAD_OFFICE);
PersonnelBO personnel = legacyPersonnelDao.getPersonnel(PersonnelConstants.TEST_USER);
meeting = getMeeting();
Integer salutation = 47;
Integer ethnicity = 218;
Integer citizenship = 130;
Integer handicapped = 138;
Integer businessActivities = 225;
Integer educationLevel = 226;
Short numChildren = Short.valueOf("1");
Short gender = Short.valueOf("49");
Short povertyStatus = Short.valueOf("41");
StaticHibernateUtil.startTransaction();
ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), 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(ethnicity, citizenship, handicapped, businessActivities, ClientPersonalDetailDto.MARRIED, educationLevel, numChildren, gender, povertyStatus);
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.flushAndClearSession();
client = TestObjectFactory.getClient(new Integer(client.getCustomerId()).intValue());
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
}
use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.
the class ClientCustActionStrutsTest method createGroupWithoutFee.
private void createGroupWithoutFee() throws Exception {
meeting = new MeetingBO(WeekDay.MONDAY, TestObjectFactory.EVERY_WEEK, new Date(), MeetingType.CUSTOMER_MEETING, "Delhi");
group = new GroupBO(userContext, "groupName", CustomerStatus.GROUP_PENDING, "1234", false, null, null, null, null, legacyPersonnelDao.getPersonnel(Short.valueOf("3")), new OfficePersistence().getOffice(Short.valueOf("3")), meeting, legacyPersonnelDao.getPersonnel(Short.valueOf("3")));
new GroupPersistence().saveGroup(group);
StaticHibernateUtil.flushAndClearSession();
}
use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.
the class ClientIntegrationTest method testSuccessfulCreateClientInBranch.
@Test
public void testSuccessfulCreateClientInBranch() throws Exception {
OfficeBO office = new OfficePersistence().getOffice(TestObjectFactory.HEAD_OFFICE);
String firstName = "Client";
String lastName = "Last";
String displayName = "Client Last";
ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, firstName, "", lastName, "");
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, getCustomFields(), null, null, personnel, office, meeting, personnel, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
legacyClientDao.saveClient(client);
StaticHibernateUtil.flushSession();
client = TestObjectFactory.getClient(client.getCustomerId());
Assert.assertEquals(displayName, client.getDisplayName());
Assert.assertEquals(firstName, client.getFirstName());
Assert.assertEquals(lastName, client.getLastName());
Assert.assertEquals(officeId, client.getOffice().getOfficeId());
}
use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.
the class ClientIntegrationTest method testUpdateBranchSecondTime.
@Test
public void testUpdateBranchSecondTime() throws Exception {
StaticHibernateUtil.closeSession();
createObjectsForClientTransfer();
Assert.assertNull(client.getActiveCustomerMovement());
OfficeBO oldOffice = client.getOffice();
client.transferToBranch(office);
StaticHibernateUtil.flushSession();
client = TestObjectFactory.getClient(client.getCustomerId());
client.setUserContext(TestUtils.makeUser());
CustomerMovementEntity currentMovement = client.getActiveCustomerMovement();
Assert.assertNotNull(currentMovement);
Assert.assertEquals(office.getOfficeId(), currentMovement.getOffice().getOfficeId());
Assert.assertEquals(office.getOfficeId(), client.getOffice().getOfficeId());
client.transferToBranch(oldOffice);
StaticHibernateUtil.flushSession();
client = TestObjectFactory.getClient(client.getCustomerId());
currentMovement = client.getActiveCustomerMovement();
Assert.assertNotNull(currentMovement);
Assert.assertEquals(oldOffice.getOfficeId(), currentMovement.getOffice().getOfficeId());
Assert.assertEquals(oldOffice.getOfficeId(), client.getOffice().getOfficeId());
office = new OfficePersistence().getOffice(office.getOfficeId());
}
use of org.mifos.customers.office.persistence.OfficePersistence 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;
}
Aggregations