use of org.mifos.dto.domain.CustomerDto in project head by mifos.
the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithLatestMeetingDateWhenBackDatedTransactionsAreAllowed.
@Test
public void shouldPopulateDtoWithLatestMeetingDateWhenBackDatedTransactionsAreAllowed() throws Exception {
// setup
final Integer customerId = Integer.valueOf(3);
final CustomerDto customer1 = new CustomerDto();
customer1.setCustomerId(customerId);
final List<CustomerDto> customers = Arrays.asList(customer1);
final Date expectedMeetingDateAsJavaDate = new DateTime().plusDays(2).toDate();
final java.sql.Date expectedMeetingDateAsSqlDate = new java.sql.Date(expectedMeetingDateAsJavaDate.getTime());
final CollectionSheetEntryFormDto previousCollectionSheetFormDto = new CollectionSheetEntryFormDto(new ArrayList<OfficeDetailsDto>(), new ArrayList<ListItem<Short>>(), new ArrayList<PersonnelDto>(), customers, Constants.YES, Constants.YES, Constants.YES);
when(customerPersistence.getLastMeetingDateForCustomer(customerId)).thenReturn(expectedMeetingDateAsSqlDate);
// NOTE: Backdated transactions is checked through static
// AccountingRules so can't set up for now
// exercise test
CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadMeetingDateForCustomer(customerId, previousCollectionSheetFormDto);
// verification
assertThat(formDto.getMeetingDate(), is(expectedMeetingDateAsJavaDate));
// assert rest of data comes from previousDto
assertThat(formDto.getCustomerList(), is(customers));
}
use of org.mifos.dto.domain.CustomerDto in project head by mifos.
the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithValueToForceFormNotToBeRefreshedWhenAllDropdownListDataIsFetched.
@Test
public void shouldPopulateDtoWithValueToForceFormNotToBeRefreshedWhenAllDropdownListDataIsFetched() throws Exception {
// setup
final Short branchId = userContext.getBranchId();
final Short levelId = OfficeLevel.BRANCHOFFICE.getValue();
OfficeDetailsDto officeStub1 = new OfficeDetailsDto(branchId, "branchName1", levelId, Integer.valueOf(1));
List<OfficeDetailsDto> onlyOneActiveBranch = Arrays.asList(officeStub1);
final PersonnelDto loanOfficer1 = new PersonnelDto(Short.valueOf("1"), "LoanOfficer1");
List<PersonnelDto> onlyOneActiveLoanOfficer = Arrays.asList(loanOfficer1);
final CustomerDto customer1 = new CustomerDto();
List<CustomerDto> customers = Arrays.asList(customer1);
// stub interaction with DAO/Persistence layer.
when(officePersistence.getActiveOffices(branchId)).thenReturn(onlyOneActiveBranch);
when(personnelPersistence.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId())).thenReturn(onlyOneActiveLoanOfficer);
when(customerPersistence.getActiveParentList(loanOfficer1.getPersonnelId(), CustomerLevel.CENTER.getValue(), branchId)).thenReturn(customers);
// exercise test
CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadAllActiveBranchesAndSubsequentDataIfApplicable(userContext);
// verification
assertThat(formDto.getReloadFormAutomatically(), is(Constants.NO));
}
use of org.mifos.dto.domain.CustomerDto in project head by mifos.
the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithCustomersWhenOnlyOneActiveBranchAndOneLoanOfficerExists.
@Ignore
@Test
public void shouldPopulateDtoWithCustomersWhenOnlyOneActiveBranchAndOneLoanOfficerExists() throws Exception {
// setup
final Short branchId = userContext.getBranchId();
final Short levelId = OfficeLevel.BRANCHOFFICE.getValue();
OfficeDetailsDto officeStub1 = new OfficeDetailsDto(branchId, "branchName1", levelId, Integer.valueOf(1));
List<OfficeDetailsDto> onlyOneActiveBranch = Arrays.asList(officeStub1);
final PersonnelDto loanOfficer1 = new PersonnelDto(Short.valueOf("1"), "LoanOfficer1");
List<PersonnelDto> onlyOneActiveLoanOfficer = Arrays.asList(loanOfficer1);
final CustomerDto customer1 = new CustomerDto();
List<CustomerDto> customers = Arrays.asList(customer1);
// stub interaction with DAO/Persistence layer.
when(officePersistence.getActiveOffices(branchId)).thenReturn(onlyOneActiveBranch);
when(personnelPersistence.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId())).thenReturn(onlyOneActiveLoanOfficer);
when(customerPersistence.getActiveParentList(loanOfficer1.getPersonnelId(), CustomerLevel.CENTER.getValue(), branchId)).thenReturn(customers);
// exercise test
CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadAllActiveBranchesAndSubsequentDataIfApplicable(userContext);
// verification
assertThat(formDto.getCustomerList(), is(customers));
}
use of org.mifos.dto.domain.CustomerDto in project head by mifos.
the class BulkEntryDisplayHelperIntegrationTest method getCusomerView.
private CustomerDto getCusomerView(final CustomerBO customer) {
CustomerDto customerDto = new CustomerDto();
customerDto.setCustomerId(customer.getCustomerId());
customerDto.setCustomerLevelId(customer.getCustomerLevel().getId());
customerDto.setCustomerSearchId(customer.getSearchId());
customerDto.setDisplayName(customer.getDisplayName());
customerDto.setGlobalCustNum(customer.getGlobalCustNum());
customerDto.setOfficeId(customer.getOffice().getOfficeId());
if (null != customer.getParentCustomer()) {
customerDto.setParentCustomerId(customer.getParentCustomer().getCustomerId());
}
customerDto.setPersonnelId(customer.getPersonnel().getPersonnelId());
customerDto.setStatusId(customer.getCustomerStatus().getId());
return customerDto;
}
use of org.mifos.dto.domain.CustomerDto in project head by mifos.
the class BulkEntryActionStrutsTest method testSuccessfulGet.
@SuppressWarnings("unchecked")
@Test
public void testSuccessfulGet() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
account = getLoanAccount(group, meeting);
// Using utility method that uses builder pattern to create savings accounts - TestObjectFactory was creating
// installments for all savings accounts (which is wrong)
TestCollectionSheetRetrieveSavingsAccountsUtils collectionSheetRetrieveSavingsAccountsUtils = new TestCollectionSheetRetrieveSavingsAccountsUtils();
centerSavingsAccount = collectionSheetRetrieveSavingsAccountsUtils.createSavingsAccount(center, "cemi", "120.00", false, false);
groupSavingsAccount = collectionSheetRetrieveSavingsAccountsUtils.createSavingsAccount(group, "gvcg", "180.00", true, false);
clientSavingsAccount = collectionSheetRetrieveSavingsAccountsUtils.createSavingsAccount(client, "clm", "222.00", false, false);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
CustomerDto customerDto = new CustomerDto();
customerDto.setCustomerId(center.getCustomerId());
customerDto.setCustomerSearchId(center.getSearchId());
customerDto.setCustomerLevelId(center.getCustomerLevel().getId());
final OfficeDetailsDto officeDetailsDto = new OfficeDetailsDto(Short.valueOf("3"), "", OfficeLevel.BRANCHOFFICE.getValue(), "levelNameKey", Integer.valueOf(-1));
final PersonnelDto personnelDto = new PersonnelDto(Short.valueOf("3"), "");
SessionUtils.setAttribute(CollectionSheetEntryConstants.COLLECTION_SHEET_ENTRY_FORM_DTO, createCollectionSheetDto(customerDto, officeDetailsDto, personnelDto), request);
SessionUtils.setCollectionAttribute(CollectionSheetEntryConstants.PAYMENT_TYPES_LIST, Arrays.asList(getPaymentTypeView()), request);
SessionUtils.setAttribute(CollectionSheetEntryConstants.ISCENTERHIERARCHYEXISTS, Constants.YES, request);
setMasterListInSession(center.getCustomerId());
setRequestPathInfo("/collectionsheetaction.do");
addRequestParameter("method", "get");
addRequestParameter("officeId", "3");
addRequestParameter("loanOfficerId", "3");
addRequestParameter("paymentId", "1");
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
Calendar meetinDateCalendar = new GregorianCalendar();
meetinDateCalendar.setTime(getMeetingDates(account.getOffice().getOfficeId(), meeting));
int year = meetinDateCalendar.get(Calendar.YEAR);
int month = meetinDateCalendar.get(Calendar.MONTH);
int day = meetinDateCalendar.get(Calendar.DAY_OF_MONTH);
meetinDateCalendar = new GregorianCalendar(year, month, day);
SessionUtils.setAttribute("LastMeetingDate", new java.sql.Date(meetinDateCalendar.getTimeInMillis()), request);
addRequestDateParameter("transactionDate", day + "/" + (month + 1) + "/" + year);
addRequestParameter("receiptId", "1");
addRequestDateParameter("receiptDate", "20/03/2006");
addRequestParameter("customerId", String.valueOf(center.getCustomerId().intValue()));
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward("get_success");
}
Aggregations