use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class CustomerPersistenceIntegrationTest method testGetChildernOtherThanClosed.
@Test
public void testGetChildernOtherThanClosed() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group);
ClientBO client4 = TestObjectFactory.createClient("client4", CustomerStatus.CLIENT_PENDING, group);
List<CustomerBO> customerList = customerPersistence.getChildren(center.getSearchId(), center.getOffice().getOfficeId(), CustomerLevel.CLIENT, ChildrenStateType.OTHER_THAN_CLOSED);
Assert.assertEquals(new Integer("3").intValue(), customerList.size());
for (CustomerBO customer : customerList) {
if (customer.getCustomerId().intValue() == client3.getCustomerId().intValue()) {
Assert.assertTrue(true);
}
}
// TestObjectFactory.cleanUp(client2);
// TestObjectFactory.cleanUp(client3);
// TestObjectFactory.cleanUp(client4);
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class ClientServiceFacadeWebTierIntegrationTest method shouldCreateGroupWithExpectedSearchId.
@Test
public void shouldCreateGroupWithExpectedSearchId() {
// setup
boolean centerHierarchyExistsOriginal = ClientRules.getCenterHierarchyExists();
MeetingBO meeting = new MeetingBuilder().withStartDate(new DateTime().minusWeeks(2)).build();
MeetingDto meetingDto = meeting.toDto();
String externalId = null;
AddressDto addressDto = new AddressDto("here", "", "", "", "", "", "", "");
PersonnelBO user = IntegrationTestObjectMother.findPersonnelById(Short.valueOf("1"));
Short loanOfficerId = user.getPersonnelId();
List<ApplicableAccountFeeDto> feesToApply = new ArrayList<ApplicableAccountFeeDto>();
CustomerStatus.CLIENT_ACTIVE.getValue();
boolean trained = false;
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
// setup
createOfficeHierarchyUnderHeadOffice(headOffice);
Short officeId = branch1.getOfficeId();
DateTime mfiJoiningDate = new DateTime().minusWeeks(2);
DateTime activationDate = new DateTime().minusWeeks(1);
List<Short> selectedSavingProducts = new ArrayList<Short>();
String clientName = "client";
Short formedBy = loanOfficerId;
Date dateOfBirth = new LocalDate(1990, 1, 1).toDateMidnight().toDate();
String governmentId = "";
Date trainedDate = new LocalDate(2000, 1, 1).toDateMidnight().toDate();
;
// not in a group
Short groupFlag = YesNoFlag.NO.getValue();
Integer salutation = 1;
String firstName = "first";
String middleName = null;
String lastName = "last";
String secondLastName = null;
ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), salutation, firstName, middleName, lastName, secondLastName);
// magic numbers from default data
Integer ethnicity = 218;
Integer citizenship = 130;
Integer handicapped = 138;
Integer businessActivities = 225;
Integer educationLevel = 226;
Short numChildren = 0;
Short gender = 49;
Short povertyStatus = 41;
Integer maritalStatus = ClientPersonalDetailDto.MARRIED;
// active
Short clientStatus = 3;
ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(ethnicity, citizenship, handicapped, businessActivities, maritalStatus, educationLevel, numChildren, gender, povertyStatus);
ClientNameDetailDto spouseFatherName = new ClientNameDetailDto(NameType.SPOUSE.getValue(), salutation, firstName, middleName, lastName, secondLastName);
InputStream picture = null;
String parentGroupId = null;
List<ClientNameDetailDto> familyNames = null;
List<ClientFamilyDetailDto> familyDetails = null;
ClientCreationDetail clientCreationDetail = new ClientCreationDetail(selectedSavingProducts, clientName, clientStatus, mfiJoiningDate.toDate(), externalId, addressDto, formedBy, dateOfBirth, governmentId, trained, trainedDate, groupFlag, clientNameDetailDto, clientPersonalDetailDto, spouseFatherName, picture, feesToApply, parentGroupId, familyNames, familyDetails, loanOfficerId, officeId, activationDate.toLocalDate());
// exercise test
ClientRules.setCenterHierarchyExists(false);
List<SavingsDetailDto> allowedSavingProducts = new ArrayList<SavingsDetailDto>();
CustomerDetailsDto newlyCreatedCustomerDetails = clientServiceFacade.createNewClient(clientCreationDetail, meetingDto, allowedSavingProducts);
// verification
ClientRules.setCenterHierarchyExists(centerHierarchyExistsOriginal);
ClientBO client = customerDao.findClientBySystemId(newlyCreatedCustomerDetails.getGlobalCustNum());
Assert.assertThat(client.getSearchId(), is("1." + client.getCustomerId()));
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class ClientCustActionStrutsTest 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"));
Calendar dob = new GregorianCalendar();
dob.set(Calendar.YEAR, 1970);
client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.fromInt(new Short("1")), null, null, new Address(), getCustomFields(), null, null, personnel, office, meeting, personnel, dob.getTime(), null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
legacyClientDao.saveClient(client);
StaticHibernateUtil.flushAndClearSession();
client = TestObjectFactory.getClient(Integer.valueOf(client.getCustomerId()).intValue());
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class CustomerPersistenceIntegrationTest method testRetrieveAllLoanAccountUnderCustomer.
@Test
public void testRetrieveAllLoanAccountUnderCustomer() throws PersistenceException {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = createCenter("center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
CenterBO center1 = createCenter("center1");
GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center1);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_ACTIVE, group1);
account = getLoanAccount(group, meeting, "cdfggdfs", "1qdd");
AccountBO account1 = getLoanAccount(client, meeting, "fdbdhgsgh", "54hg");
AccountBO account2 = getLoanAccount(client2, meeting, "fasdfdsfasdf", "1qwe");
AccountBO account3 = getLoanAccount(client3, meeting, "fdsgdfgfd", "543g");
AccountBO account4 = getLoanAccount(group1, meeting, "fasdf23", "3fds");
CustomerBOTestUtils.setCustomerStatus(client2, new CustomerStatusEntity(CustomerStatus.CLIENT_CLOSED));
TestObjectFactory.updateObject(client2);
client2 = TestObjectFactory.getClient(client2.getCustomerId());
CustomerBOTestUtils.setCustomerStatus(client3, new CustomerStatusEntity(CustomerStatus.CLIENT_CANCELLED));
TestObjectFactory.updateObject(client3);
client3 = TestObjectFactory.getClient(client3.getCustomerId());
List<AccountBO> loansForCenter = customerPersistence.retrieveAccountsUnderCustomer(center.getSearchId(), Short.valueOf("3"), Short.valueOf("1"));
Assert.assertEquals(3, loansForCenter.size());
List<AccountBO> loansForGroup = customerPersistence.retrieveAccountsUnderCustomer(group.getSearchId(), Short.valueOf("3"), Short.valueOf("1"));
Assert.assertEquals(3, loansForGroup.size());
List<AccountBO> loansForClient = customerPersistence.retrieveAccountsUnderCustomer(client.getSearchId(), Short.valueOf("3"), Short.valueOf("1"));
Assert.assertEquals(1, loansForClient.size());
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class CustomerPersistenceIntegrationTest method testGetAllChildrenForParent.
@Test
public void testGetAllChildrenForParent() throws NumberFormatException, PersistenceException {
center = createCenter("Center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
CenterBO center1 = createCenter("center11");
GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center1);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group1);
List<CustomerBO> customerList1 = customerPersistence.getAllChildrenForParent(center.getSearchId(), Short.valueOf("3"), CustomerLevel.CENTER.getValue());
Assert.assertEquals(2, customerList1.size());
List<CustomerBO> customerList2 = customerPersistence.getAllChildrenForParent(center.getSearchId(), Short.valueOf("3"), CustomerLevel.GROUP.getValue());
Assert.assertEquals(1, customerList2.size());
// TestObjectFactory.cleanUp(client3);
// TestObjectFactory.cleanUp(client2);
group1 = null;
center1 = null;
}
Aggregations