@Test public void calculateLoanNoInstallmentsLeftTest() throws Exception { LoanCalculationInput input = new LoanCalculationInput( new Month(2016, 1), new Decimal(300000), 0, Decimal.valueOf("0.05"), Decimal.valueOf("0.8"), 1); LoanCalculationResult result = this.testedObject.calculateLoan(input); assertNull(result); }
@Test public void calculateLoanTest() throws Exception { LoanCalculationInput input = new LoanCalculationInput( new Month(2016, 1), new Decimal(300000), 360, Decimal.valueOf("0.05"), Decimal.valueOf("0.8"), 1); LoanCalculationResult result = this.testedObject.calculateLoan(input); assertEquals(Decimal.valueOf("1628.19"), result.getInstallment()); assertEquals(Decimal.valueOf("354.09"), result.getCapitalInstallment()); assertEquals(Decimal.valueOf("1274.1"), result.getInterestInstallment()); assertEquals(Decimal.valueOf("509.64"), result.getRnsBonus()); assertEquals(Decimal.valueOf("1118.55"), result.getFinalInstallment()); assertEquals(Decimal.valueOf("299645.91"), result.getLoanLeft()); assertEquals((Integer) 359, result.getNumberOfInstallmentsLeft()); assertEquals((Integer) 0, result.getRnsBonusNumberOfInstallmentsLeft()); }