FlatLoanInterestCalculator implements LoanInterestCalculator { @Override public Money calculate(LoanInterestCalculationDetails loanInterestCalculationDetails) { Money loanAmount = loanInterestCalculationDetails.getLoanAmount(); Double interestRate = loanInterestCalculationDetails.getInterestRate(); Double durationInYears = loanInterestCalculationDetails.getDurationInYears(); return loanAmount.multiply(interestRate).multiply(durationInYears).divide(new BigDecimal("100")); }  @Override Money calculate(LoanInterestCalculationDetails loanInterestCalculationDetails);  }
@Test public void shouldCalculateFlatLoanInterest() { LoanInterestCalculationDetails loanInterestCalculationDetails = new LoanInterestCalculationDetailsBuilder().withLoanAmount("100.0") .withInterestRate("10.0") .withDurationInYears("1.0") .build(); Money calculatedInterest = flatLoanInterestCalculator.calculate(loanInterestCalculationDetails); assertThat(calculatedInterest, is(TestMoneyUtil.createMoney("10.0"))); }