use of org.mifos.accounts.loan.business.matchers.OriginalScheduleInfoDtoMatcher in project head by mifos.
the class LoanServiceFacadeWebTierTest method retrieveOriginalLoanSchedule.
@Test
public void retrieveOriginalLoanSchedule() throws PersistenceException {
Integer accountId = new Integer(1);
List<OriginalLoanScheduleEntity> loanScheduleEntities = new ArrayList<OriginalLoanScheduleEntity>();
OriginalLoanScheduleEntity originalLoanScheduleEntity1 = mock(OriginalLoanScheduleEntity.class);
OriginalLoanScheduleEntity originalLoanScheduleEntity2 = mock(OriginalLoanScheduleEntity.class);
loanScheduleEntities.add(originalLoanScheduleEntity1);
loanScheduleEntities.add(originalLoanScheduleEntity2);
RepaymentScheduleInstallment installment1 = new RepaymentScheduleInstallment();
RepaymentScheduleInstallment installment2 = new RepaymentScheduleInstallment();
when(originalLoanScheduleEntity1.toDto()).thenReturn(installment1);
when(originalLoanScheduleEntity2.toDto()).thenReturn(installment2);
List<RepaymentScheduleInstallment> expected = new ArrayList<RepaymentScheduleInstallment>();
expected.add(installment1);
expected.add(installment2);
Date date = new Date();
when(loanBO.getDisbursementDate()).thenReturn(date);
Money money = new Money(rupee, "4.9");
when(loanBO.getLoanAmount()).thenReturn(money);
when(loanBusinessService.retrieveOriginalLoanSchedule(accountId)).thenReturn(loanScheduleEntities);
when(loanDao.findById(accountId)).thenReturn(loanBO);
OriginalScheduleInfoDto expectedOriginalScheduleInfoDto = new OriginalScheduleInfoDto(money.toString(), date, expected);
OriginalScheduleInfoDto originalScheduleInfoDto = loanServiceFacade.retrieveOriginalLoanSchedule(accountId);
assertThat(originalScheduleInfoDto, is(new OriginalScheduleInfoDtoMatcher(expectedOriginalScheduleInfoDto)));
}
Aggregations