@Test public void validateCaptureCashFlowWhenTotalCapitalAndTotalLiabilityIsNegative() throws Exception { when(validationContext.getMessageContext()).thenReturn(messageContext); CashFlowDetail cashFlowDetail = new CashFlowDetail(EMPTY_LIST); cashFlowDetail.setTotalCapital(new BigDecimal(-23)); cashFlowDetail.setTotalLiability(new BigDecimal(-1)); 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_BE_GREATER_THAN_ZERO))); verify(messageContext).addMessage(argThat(new MessageMatcher(CashFlowConstants.TOTAL_LIABILITY_SHOULD_BE_NON_NEGATIVE))); }
public void validateCaptureCashFlow(CashFlowForm cashFlow, ValidationContext context) { MessageContext messageContext = context.getMessageContext(); for (MonthlyCashFlowForm monthlyCashFlowForm : cashFlow.getMonthlyCashFlows()) { validateExpense(messageContext, monthlyCashFlowForm); validateRevenue(messageContext, monthlyCashFlowForm); validateNotes(messageContext, monthlyCashFlowForm); } validateCumulativeCashFlow(cashFlow, messageContext); validateTotalCapitalAndLiability(cashFlow, messageContext); validateIndebtednessRatio(cashFlow, messageContext); setTotalsOnCashFlowForm(cashFlow, messageContext); }
CashFlowValidator { public void validateCaptureCashFlow(CashFlowForm cashFlow, ValidationContext context) { MessageContext messageContext = context.getMessageContext(); for (MonthlyCashFlowForm monthlyCashFlowForm : cashFlow.getMonthlyCashFlows()) { validateExpense(messageContext, monthlyCashFlowForm); validateRevenue(messageContext, monthlyCashFlowForm); validateNotes(messageContext, monthlyCashFlowForm); } validateCumulativeCashFlow(cashFlow, messageContext); validateTotalCapitalAndLiability(cashFlow, messageContext); validateIndebtednessRatio(cashFlow, messageContext); setTotalsOnCashFlowForm(cashFlow, messageContext); } }
CashFlowValidator { public void validateCaptureCashFlow(CashFlowForm cashFlow, ValidationContext context) { MessageContext messageContext = context.getMessageContext(); for (MonthlyCashFlowForm monthlyCashFlowForm : cashFlow.getMonthlyCashFlows()) { validateExpense(messageContext, monthlyCashFlowForm); validateRevenue(messageContext, monthlyCashFlowForm); validateNotes(messageContext, monthlyCashFlowForm); } validateCumulativeCashFlow(cashFlow, messageContext); validateTotalCapitalAndLiability(cashFlow, messageContext); validateIndebtednessRatio(cashFlow, messageContext); setTotalsOnCashFlowForm(cashFlow, messageContext); }  }
CashFlowValidator { public void validateCaptureCashFlow(CashFlowForm cashFlow, ValidationContext context) { MessageContext messageContext = context.getMessageContext(); for (MonthlyCashFlowForm monthlyCashFlowForm : cashFlow.getMonthlyCashFlows()) { validateExpense(messageContext, monthlyCashFlowForm); validateRevenue(messageContext, monthlyCashFlowForm); validateNotes(messageContext, monthlyCashFlowForm); } validateCumulativeCashFlow(cashFlow, messageContext); validateTotalCapitalAndLiability(cashFlow, messageContext); validateIndebtednessRatio(cashFlow, messageContext); setTotalsOnCashFlowForm(cashFlow, messageContext); }  void validateCaptureCashFlow(CashFlowForm cashFlow, ValidationContext context); }
CashFlowValidator { public void validateCaptureCashFlow(CashFlowForm cashFlow, ValidationContext context) { MessageContext messageContext = context.getMessageContext(); for (MonthlyCashFlowForm monthlyCashFlowForm : cashFlow.getMonthlyCashFlows()) { validateExpense(messageContext, monthlyCashFlowForm); validateRevenue(messageContext, monthlyCashFlowForm); validateNotes(messageContext, monthlyCashFlowForm); } validateCumulativeCashFlow(cashFlow, messageContext); validateTotalCapitalAndLiability(cashFlow, messageContext); validateIndebtednessRatio(cashFlow, messageContext); setTotalsOnCashFlowForm(cashFlow, messageContext); }  void validateCaptureCashFlow(CashFlowForm cashFlow, ValidationContext context);  }