Search in sources :

Example 16 with CashFlowDetail

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);
}
Also used : MonthlyCashFlowDetail(org.mifos.platform.cashflow.service.MonthlyCashFlowDetail) CashFlowDetail(org.mifos.platform.cashflow.service.CashFlowDetail) CashFlowForm(org.mifos.platform.cashflow.ui.model.CashFlowForm) CashFlowFormMatcher(org.mifos.platform.cashflow.matchers.CashFlowFormMatcher) MonthlyCashFlowDetail(org.mifos.platform.cashflow.service.MonthlyCashFlowDetail) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 17 with CashFlowDetail

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());
}
Also used : MonthlyCashFlowDetail(org.mifos.platform.cashflow.service.MonthlyCashFlowDetail) CashFlowDetail(org.mifos.platform.cashflow.service.CashFlowDetail) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 18 with CashFlowDetail

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)));
}
Also used : MessageMatcher(org.mifos.platform.matchers.MessageMatcher) MonthlyCashFlowDetail(org.mifos.platform.cashflow.service.MonthlyCashFlowDetail) CashFlowDetail(org.mifos.platform.cashflow.service.CashFlowDetail) Test(org.junit.Test)

Aggregations

CashFlowDetail (org.mifos.platform.cashflow.service.CashFlowDetail)18 Test (org.junit.Test)17 MonthlyCashFlowDetail (org.mifos.platform.cashflow.service.MonthlyCashFlowDetail)17 BigDecimal (java.math.BigDecimal)15 MessageMatcher (org.mifos.platform.matchers.MessageMatcher)7 DateTime (org.joda.time.DateTime)5 CashFlowForm (org.mifos.platform.cashflow.ui.model.CashFlowForm)4 ArrayList (java.util.ArrayList)2 Ignore (org.junit.Ignore)2 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)2 Money (org.mifos.framework.util.helpers.Money)2 Errors (org.mifos.platform.validations.Errors)2 CashFlowFormMatcher (org.mifos.platform.cashflow.matchers.CashFlowFormMatcher)1 MonthlyCashFlowFormMatcher (org.mifos.platform.cashflow.matchers.MonthlyCashFlowFormMatcher)1 CashFlowBoundary (org.mifos.platform.cashflow.service.CashFlowBoundary)1 MonthlyCashFlowForm (org.mifos.platform.cashflow.ui.model.MonthlyCashFlowForm)1