Search in sources :

Example 1 with OriginalScheduleInfoDtoMatcher

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)));
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) OriginalScheduleInfoDtoMatcher(org.mifos.accounts.loan.business.matchers.OriginalScheduleInfoDtoMatcher) OriginalScheduleInfoDto(org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto) OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Test (org.junit.Test)1 OriginalLoanScheduleEntity (org.mifos.accounts.loan.business.OriginalLoanScheduleEntity)1 OriginalScheduleInfoDtoMatcher (org.mifos.accounts.loan.business.matchers.OriginalScheduleInfoDtoMatcher)1 OriginalScheduleInfoDto (org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto)1 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)1 Money (org.mifos.framework.util.helpers.Money)1