use of org.mifos.application.servicefacade.CollectionSheetCustomerDto in project head by mifos.
the class CollectionSheetDaoHibernateIntegrationTest method testShouldRetrieveCustomerHierarchyWithACenterAsRootByBranchId.
@Test
public void testShouldRetrieveCustomerHierarchyWithACenterAsRootByBranchId() throws Exception {
// setup
final Integer customerId = center.getCustomerId();
final LocalDate transactionDate = new LocalDate();
// exercise test
final List<CollectionSheetCustomerDto> customerHierarchy = collectionSheetDao.findCustomerHierarchy(customerId, transactionDate);
// verification
Assert.assertNotNull(customerHierarchy);
Assert.assertFalse(customerHierarchy.isEmpty());
Assert.assertNotNull(customerHierarchy.get(0));
Assert.assertEquals(center.getCustomerId(), customerHierarchy.get(0).getCustomerId());
Assert.assertThat(customerHierarchy.get(0).getParentCustomerId(), is(nullValue()));
Assert.assertEquals(center.getDisplayName(), customerHierarchy.get(0).getName());
Assert.assertEquals(center.getSearchId(), customerHierarchy.get(0).getSearchId());
Assert.assertEquals(center.getLevel().getValue(), customerHierarchy.get(0).getLevelId());
Assert.assertNull("center should have no attendance against them", customerHierarchy.get(0).getAttendanceId());
Assert.assertNotNull(customerHierarchy.get(1));
Assert.assertEquals(group.getCustomerId(), customerHierarchy.get(1).getCustomerId());
Assert.assertThat(customerHierarchy.get(1).getParentCustomerId(), is(center.getCustomerId()));
Assert.assertEquals(group.getDisplayName(), customerHierarchy.get(1).getName());
Assert.assertEquals(group.getSearchId(), customerHierarchy.get(1).getSearchId());
Assert.assertEquals(group.getLevel().getValue(), customerHierarchy.get(1).getLevelId());
Assert.assertNull("group should have no attendance against them", customerHierarchy.get(1).getAttendanceId());
}
use of org.mifos.application.servicefacade.CollectionSheetCustomerDto in project head by mifos.
the class CollectionSheetDaoHibernateIntegrationTest method testShouldRetrieveCustomerHierarchyWithAGroupAsRootByBranchId.
@Test
public void testShouldRetrieveCustomerHierarchyWithAGroupAsRootByBranchId() throws Exception {
// setup
final Integer customerId = group.getCustomerId();
final LocalDate transactionDate = new LocalDate();
// exercise test
final List<CollectionSheetCustomerDto> customerHierarchy = collectionSheetDao.findCustomerHierarchy(customerId, transactionDate);
// verification
Assert.assertNotNull(customerHierarchy);
Assert.assertFalse(customerHierarchy.isEmpty());
Assert.assertNotNull(customerHierarchy.get(0));
Assert.assertNotNull(customerHierarchy.get(0));
Assert.assertEquals(group.getCustomerId(), customerHierarchy.get(0).getCustomerId());
Assert.assertEquals(group.getDisplayName(), customerHierarchy.get(0).getName());
Assert.assertEquals(group.getSearchId(), customerHierarchy.get(0).getSearchId());
Assert.assertEquals(group.getLevel().getValue(), customerHierarchy.get(0).getLevelId());
Assert.assertNull("group should have no attendance against them", customerHierarchy.get(0).getAttendanceId());
Assert.assertNotNull(customerHierarchy.get(1));
Assert.assertEquals(client.getCustomerId(), customerHierarchy.get(1).getCustomerId());
Assert.assertEquals(client.getDisplayName(), customerHierarchy.get(1).getName());
Assert.assertEquals(client.getSearchId(), customerHierarchy.get(1).getSearchId());
Assert.assertEquals(client.getLevel().getValue(), customerHierarchy.get(1).getLevelId());
Assert.assertNull("client should have no attendance against them", customerHierarchy.get(1).getAttendanceId());
}
use of org.mifos.application.servicefacade.CollectionSheetCustomerDto in project head by mifos.
the class CustomerPersistenceIntegrationTest method verifyCustomerNotLoaded.
private void verifyCustomerNotLoaded(Integer customerId, String customerName) {
CollectionSheetCustomerDto collectionSheetCustomerDto = customerPersistence.findCustomerWithNoAssocationsLoaded(customerId);
Assert.assertNull(customerName + " was returned", collectionSheetCustomerDto);
}
use of org.mifos.application.servicefacade.CollectionSheetCustomerDto in project head by mifos.
the class CustomerPersistenceIntegrationTest method verifyCustomerLoaded.
private void verifyCustomerLoaded(Integer customerId, String customerName) {
CollectionSheetCustomerDto collectionSheetCustomerDto = customerPersistence.findCustomerWithNoAssocationsLoaded(customerId);
Assert.assertNotNull(customerName + " was not returned", collectionSheetCustomerDto);
Assert.assertEquals(collectionSheetCustomerDto.getCustomerId(), customerId);
}
use of org.mifos.application.servicefacade.CollectionSheetCustomerDto in project head by mifos.
the class CollectionSheetDaoHibernate method findCustomerHierarchy.
@Override
@SuppressWarnings("unchecked")
public List<CollectionSheetCustomerDto> findCustomerHierarchy(final Integer customerId, final LocalDate transactionDate) {
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("CUSTOMER_ID", customerId);
queryParameters.put("TRANSACTION_DATE", transactionDate.toString());
CollectionSheetCustomerDto topCustomer = execUniqueResultNamedQueryWithResultTransformer("findCustomerAtTopOfHierarchyAsDto", queryParameters, CollectionSheetCustomerDto.class);
if (topCustomer == null) {
return new ArrayList<CollectionSheetCustomerDto>();
}
final Map<String, Object> withinHierarchyQueryParameters = new HashMap<String, Object>();
withinHierarchyQueryParameters.put("BRANCH_ID", topCustomer.getBranchId());
withinHierarchyQueryParameters.put("SEARCH_ID", topCustomer.getSearchId() + ".%");
withinHierarchyQueryParameters.put("TRANSACTION_DATE", transactionDate.toString());
final List<CollectionSheetCustomerDto> restOfHierarchy = executeNamedQueryWithResultTransformer("findCustomersWithinHierarchyAsDto", withinHierarchyQueryParameters, CollectionSheetCustomerDto.class);
final List<CollectionSheetCustomerDto> collectionSheetCutomerList = new ArrayList<CollectionSheetCustomerDto>();
collectionSheetCutomerList.add(topCustomer);
collectionSheetCutomerList.addAll(restOfHierarchy);
return collectionSheetCutomerList;
}
Aggregations