use of org.mifos.dto.domain.AccountPaymentDto in project head by mifos.
the class LoanAccountServiceFacadeWebTierTest method testValidateMakeEarlyRepayment.
@Test
public void testValidateMakeEarlyRepayment() throws AccountException, PersistenceException {
setMifosUserFromContext();
when(loanDao.findByGlobalAccountNum("1")).thenReturn(loanBO);
when(loanDao.findById(0)).thenReturn(loanBO);
boolean actualWaiveInterestValue = false;
java.sql.Date date = mock(java.sql.Date.class);
when(customerDao.getFirstMeetingDateForCustomer(2)).thenReturn(date);
when(configurationPersistence.isRepaymentIndepOfMeetingEnabled()).thenReturn(false);
when(loanBO.isInterestWaived()).thenReturn(actualWaiveInterestValue);
when(loanBO.getOfficeId()).thenReturn((short) 1);
when(loanBO.getCustomer()).thenReturn(customer);
when(loanBO.isTrxnDateValid(date, date, false)).thenReturn(true);
when(customer.getLoanOfficerId()).thenReturn((short) 1);
when(customer.getCustomerId()).thenReturn(2);
try {
loanAccountServiceFacade.makeEarlyRepayment(new RepayLoanInfoDto("1", "100", "001", mock(java.sql.Date.class), "1", (short) 1, true, date, BigDecimal.ZERO, BigDecimal.ZERO));
} catch (BusinessRuleException e) {
verify(loanBO, never()).makeEarlyRepayment((AccountPaymentDto) anyObject(), (Short) anyObject(), anyBoolean(), Matchers.<Money>anyObject());
verify(loanBO, never()).getCurrency();
verify(loanBusinessService, never()).computeExtraInterest(eq(loanBO), Matchers.<Date>anyObject());
assertThat(e.getMessageKey(), is(LoanConstants.WAIVER_INTEREST_NOT_CONFIGURED));
}
}
Aggregations