@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); }
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") public CashFlowForm prepareCashFlowForm(int startYear, int startMonth, int noOfMonths, BigDecimal loanAmount, Double indebtednessRatio, boolean captureCapitalLiabilityInfo) { CashFlowDetail cashFlowDetail = cashFlowService.cashFlowFor(startYear, startMonth, noOfMonths); return new CashFlowForm(cashFlowDetail, captureCapitalLiabilityInfo, loanAmount, indebtednessRatio); }
CashFlowController { @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") public CashFlowForm prepareCashFlowForm(int startYear, int startMonth, int noOfMonths, BigDecimal loanAmount, Double indebtednessRatio, boolean captureCapitalLiabilityInfo) { CashFlowDetail cashFlowDetail = cashFlowService.cashFlowFor(startYear, startMonth, noOfMonths); return new CashFlowForm(cashFlowDetail, captureCapitalLiabilityInfo, loanAmount, indebtednessRatio); } }
CashFlowController { @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") public CashFlowForm prepareCashFlowForm(int startYear, int startMonth, int noOfMonths, BigDecimal loanAmount, Double indebtednessRatio, boolean captureCapitalLiabilityInfo) { CashFlowDetail cashFlowDetail = cashFlowService.cashFlowFor(startYear, startMonth, noOfMonths); return new CashFlowForm(cashFlowDetail, captureCapitalLiabilityInfo, loanAmount, indebtednessRatio); } @Autowired  CashFlowController(CashFlowService cashFlowService); }
CashFlowController { @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") public CashFlowForm prepareCashFlowForm(int startYear, int startMonth, int noOfMonths, BigDecimal loanAmount, Double indebtednessRatio, boolean captureCapitalLiabilityInfo) { CashFlowDetail cashFlowDetail = cashFlowService.cashFlowFor(startYear, startMonth, noOfMonths); return new CashFlowForm(cashFlowDetail, captureCapitalLiabilityInfo, loanAmount, indebtednessRatio); } @Autowired  CashFlowController(CashFlowService cashFlowService); @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") LoanAccountCashFlow transformCashFlow(CashFlowForm cashFlow); CashFlowForm retrieveCashFlowForm(CashFlowDto cashFlowSettings); @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") List<MonthlyCashFlowDto> retrieveMonthlyCashflowDetails(CashFlowForm cashFlowForm, Date disbursementDate, Double loanAmount); @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") CashFlowForm prepareCashFlowForm(int startYear, int startMonth, int noOfMonths, BigDecimal loanAmount,
                                            Double indebtednessRatio, boolean captureCapitalLiabilityInfo); }
CashFlowController { @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") public CashFlowForm prepareCashFlowForm(int startYear, int startMonth, int noOfMonths, BigDecimal loanAmount, Double indebtednessRatio, boolean captureCapitalLiabilityInfo) { CashFlowDetail cashFlowDetail = cashFlowService.cashFlowFor(startYear, startMonth, noOfMonths); return new CashFlowForm(cashFlowDetail, captureCapitalLiabilityInfo, loanAmount, indebtednessRatio); } @Autowired  CashFlowController(CashFlowService cashFlowService); @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") LoanAccountCashFlow transformCashFlow(CashFlowForm cashFlow); CashFlowForm retrieveCashFlowForm(CashFlowDto cashFlowSettings); @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") List<MonthlyCashFlowDto> retrieveMonthlyCashflowDetails(CashFlowForm cashFlowForm, Date disbursementDate, Double loanAmount); @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") CashFlowForm prepareCashFlowForm(int startYear, int startMonth, int noOfMonths, BigDecimal loanAmount,
                                            Double indebtednessRatio, boolean captureCapitalLiabilityInfo);  }