@Test
public void shouldComputeTotalExpenseAndTotalRevenueForAllMonthlyCashFlows() {

    when(validationContext.getMessageContext()).thenReturn(messageContext);
    when(messageContext.hasErrorMessages()).thenReturn(false);
    MonthlyCashFlowDetail cashFlowDetail1 = new MonthlyCashFlowDetail(new DateTime(), new BigDecimal(12), new BigDecimal(12), "notes");
    MonthlyCashFlowDetail cashFlowDetail2 = new MonthlyCashFlowDetail(new DateTime(), new BigDecimal(23), new BigDecimal(34), "notes");
    MonthlyCashFlowDetail cashFlowDetail3 = new MonthlyCashFlowDetail(new DateTime(), new BigDecimal(20), new BigDecimal(30), "notes");
    CashFlowDetail cashFlowDetail = new CashFlowDetail(asList(cashFlowDetail1, cashFlowDetail2, cashFlowDetail3));
    CashFlowForm cashFlowForm = new CashFlowForm(cashFlowDetail, false, new BigDecimal(1000), 10d);
    cashFlowValidator.validateCaptureCashFlow(cashFlowForm, validationContext);
    assertThat(cashFlowForm.getTotalExpenses().doubleValue(), is(76d));
    assertThat(cashFlowForm.getTotalRevenues().doubleValue(), is(55d));
    verify(messageContext, times(2)).hasErrorMessages();
    verify(validationContext).getMessageContext();
}