use of org.mifos.platform.cashflow.service.CashFlowDetail in project head by mifos.
the class CashFlowControllerTest method prepareCashFlowForm.
@Test
public void prepareCashFlowForm() throws Exception {
CashFlowDetail cashFlowDetail = new CashFlowDetail(new ArrayList<MonthlyCashFlowDetail>());
Mockito.when(cashFlowService.cashFlowFor(2012, 1, 12)).thenReturn(cashFlowDetail);
CashFlowController cashFlowController = new CashFlowController(cashFlowService);
BigDecimal loanAmount = new BigDecimal("1234");
Double indebtednessRatio = 12d;
CashFlowForm cashFlowForm = cashFlowController.prepareCashFlowForm(2012, 1, 12, loanAmount, indebtednessRatio, true);
CashFlowForm expectedCashFlowForm = new CashFlowForm(cashFlowDetail, true, loanAmount, indebtednessRatio);
assertThat(cashFlowForm, new CashFlowFormMatcher(expectedCashFlowForm));
Mockito.verify(cashFlowService).cashFlowFor(2012, 1, 12);
}
use of org.mifos.platform.cashflow.service.CashFlowDetail in project head by mifos.
the class CashFlowValidatorTest method validateCaptureCashFlow.
@Test
public void validateCaptureCashFlow() throws Exception {
when(validationContext.getMessageContext()).thenReturn(messageContext);
CashFlowDetail cashFlowDetail = new CashFlowDetail(EMPTY_LIST);
cashFlowDetail.setTotalCapital(new BigDecimal(123d));
cashFlowDetail.setTotalLiability(new BigDecimal(456d));
CashFlowForm cashFlowForm = new CashFlowForm(cashFlowDetail, true, null, 0d);
cashFlowValidator.validateCaptureCashFlow(cashFlowForm, validationContext);
verify(validationContext).getMessageContext();
verify(messageContext, never()).addMessage(Matchers.<MessageResolver>anyObject());
}
use of org.mifos.platform.cashflow.service.CashFlowDetail in project head by mifos.
the class CashFlowValidatorTest method validateCaptureCashFlowWhenTotalCapitalAndLiabilityIsNull.
@Test
public void validateCaptureCashFlowWhenTotalCapitalAndLiabilityIsNull() throws Exception {
when(validationContext.getMessageContext()).thenReturn(messageContext);
CashFlowDetail cashFlowDetail = new CashFlowDetail(EMPTY_LIST);
cashFlowDetail.setTotalCapital(null);
cashFlowDetail.setTotalLiability(null);
CashFlowForm cashFlowForm = new CashFlowForm(cashFlowDetail, true, null, 0d);
cashFlowValidator.validateCaptureCashFlow(cashFlowForm, validationContext);
verify(validationContext).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher(CashFlowConstants.TOTAL_CAPITAL_SHOULD_NOT_BE_EMPTY)));
verify(messageContext).addMessage(argThat(new MessageMatcher(CashFlowConstants.TOTAL_LIABILITY_SHOULD_NOT_BE_EMPTY)));
}
Aggregations