FINERACT-1016: Fixing rounding issues in integration tests

This commit is contained in:
Petri Tuomola
2020-07-02 12:07:43 +02:00
committed by Michael Vorburger ⛑️
parent 9c3f1addd7
commit 0a01419cd3
2 changed files with 82 additions and 98 deletions
@@ -104,10 +104,11 @@ public class FixedDepositTest {
// TODO Given the difference in calculation methods in test vs application, // TODO Given the difference in calculation methods in test vs application,
// the exact values // the exact values
// returned may differ enough to cause differences in rounding. Given this, // returned may differ enough to cause differences in rounding. Given this,
// we only compare the full // we only compare that the result is within THRESHOLD of the expected amount.
// digits. A proper solution would be to implement the exact interest // A proper solution would be to implement the exact interest
// calculation in this test, // calculation in this test,
// and then to compare the exact results // and then to compare the exact results
public static final Float THRESHOLD = 1.0f;
@BeforeEach @BeforeEach
public void setup() { public void setup() {
@@ -1224,10 +1225,8 @@ public class FixedDepositTest {
principal = FixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, interestPerDay, principal = FixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, interestPerDay,
MONTHLY_INTERVAL, MONTHLY_INTERVAL); MONTHLY_INTERVAL, MONTHLY_INTERVAL);
principal = (float) Math.floor(principal);
maturityAmount = (float) Math.floor(maturityAmount);
LOG.info("{}", principal.toString()); LOG.info("{}", principal.toString());
Assertions.assertEquals(principal, maturityAmount, "Verifying Maturity amount for Fixed Deposit Account"); Assertions.assertTrue(Math.abs(principal - maturityAmount) < THRESHOLD, "Verifying Maturity amount for Fixed Deposit Account");
} }
@Test @Test
@@ -1296,10 +1295,8 @@ public class FixedDepositTest {
principal = FixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, interestPerDay, principal = FixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, interestPerDay,
MONTHLY_INTERVAL, MONTHLY_INTERVAL); MONTHLY_INTERVAL, MONTHLY_INTERVAL);
principal = (float) Math.floor(principal);
maturityAmount = (float) Math.floor(maturityAmount);
LOG.info("{}", principal.toString()); LOG.info("{}", principal.toString());
Assertions.assertEquals(principal, maturityAmount, "Verifying Maturity amount for Fixed Deposit Account"); Assertions.assertTrue(Math.abs(principal - maturityAmount) < THRESHOLD, "Verifying Maturity amount for Fixed Deposit Account");
} }
@Test @Test
@@ -1396,10 +1393,9 @@ public class FixedDepositTest {
fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec, fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
fixedDepositAccountId); fixedDepositAccountId);
principal = (float) Math.floor(principal); Float maturityAmount = (float) fixedDepositAccountData.get("maturityAmount");
Float maturityAmount = (float) Math.floor((Float) fixedDepositAccountData.get("maturityAmount"));
Assertions.assertEquals(principal, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(principal - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@@ -1482,7 +1478,7 @@ public class FixedDepositTest {
principal += interestPerMonth; principal += interestPerMonth;
todaysDate.add(Calendar.DATE, daysInMonth); todaysDate.add(Calendar.DATE, daysInMonth);
LOG.info("{}", monthDayFormat.format(todaysDate.getTime())); LOG.info("{}", monthDayFormat.format(todaysDate.getTime()));
currentDate = Integer.valueOf(currentDateFormat.format(todaysDate.getTime()));
interestPerMonth = (float) (interestPerDay * principal * currentDate); interestPerMonth = (float) (interestPerDay * principal * currentDate);
LOG.info("IPM = {}", interestPerMonth); LOG.info("IPM = {}", interestPerMonth);
principal += interestPerMonth; principal += interestPerMonth;
@@ -1501,10 +1497,9 @@ public class FixedDepositTest {
fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec, fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
fixedDepositAccountId); fixedDepositAccountId);
principal = (float) Math.floor(principal); Float maturityAmount = (float) fixedDepositAccountData.get("maturityAmount");
Float maturityAmount = (float) Math.floor((Float) fixedDepositAccountData.get("maturityAmount"));
Assertions.assertEquals(principal, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(principal - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@@ -1611,10 +1606,10 @@ public class FixedDepositTest {
fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec, fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
fixedDepositAccountId); fixedDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Float expectedPrematureAmount = principal;
Double maturityAmount = Math.floor((float) fixedDepositAccountData.get("maturityAmount")); Float maturityAmount = (float) fixedDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@@ -1725,10 +1720,10 @@ public class FixedDepositTest {
fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec, fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
fixedDepositAccountId); fixedDepositAccountId);
Float expectedPrematureAmount = (float) Math.floor(principal); Float expectedPrematureAmount = principal;
Float maturityAmount = (float) Math.floor((Float) fixedDepositAccountData.get("maturityAmount")); Float maturityAmount = (Float) fixedDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@@ -1799,10 +1794,8 @@ public class FixedDepositTest {
principal = FixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, interestPerDay, principal = FixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, interestPerDay,
DAILY_COMPOUNDING_INTERVAL, MONTHLY_INTERVAL); DAILY_COMPOUNDING_INTERVAL, MONTHLY_INTERVAL);
principal = (float) Math.floor(principal);
maturityAmount = (float) Math.floor(maturityAmount);
LOG.info("{}", principal.toString()); LOG.info("{}", principal.toString());
Assertions.assertEquals(principal, maturityAmount, "Verifying Maturity amount for Fixed Deposit Account"); Assertions.assertTrue(Math.abs(principal - maturityAmount) < THRESHOLD, "Verifying Maturity amount for Fixed Deposit Account");
} }
@@ -1957,10 +1950,10 @@ public class FixedDepositTest {
fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec, fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
fixedDepositAccountId); fixedDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Float expectedPrematureAmount = principal;
Double maturityAmount = Math.floor((Float) fixedDepositAccountData.get("maturityAmount")); Float maturityAmount = (Float) fixedDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Maturity amount");
} }
@@ -2040,10 +2033,10 @@ public class FixedDepositTest {
fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec, fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
fixedDepositAccountId); fixedDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Float expectedPrematureAmount = principal;
Double maturityAmount = Math.floor((Float) fixedDepositAccountData.get("maturityAmount")); Float maturityAmount = (Float) fixedDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Maturity amount");
} }
@@ -2121,10 +2114,10 @@ public class FixedDepositTest {
fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec, fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
fixedDepositAccountId); fixedDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Float expectedPrematureAmount = principal;
Double maturityAmount = Math.floor((Float) fixedDepositAccountData.get("maturityAmount")); Float maturityAmount = (Float) fixedDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@@ -2202,10 +2195,10 @@ public class FixedDepositTest {
fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec, fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
fixedDepositAccountId); fixedDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Float expectedPrematureAmount = principal;
Double maturityAmount = Math.floor((Float) fixedDepositAccountData.get("maturityAmount")); Float maturityAmount = (Float) fixedDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@@ -2283,10 +2276,10 @@ public class FixedDepositTest {
fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec, fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
fixedDepositAccountId); fixedDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Float expectedPrematureAmount = principal;
Double maturityAmount = Math.floor((Float) fixedDepositAccountData.get("maturityAmount")); Float maturityAmount = (Float) fixedDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@Test @Test
@@ -2363,10 +2356,10 @@ public class FixedDepositTest {
fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec, fixedDepositAccountData = FixedDepositAccountHelper.getFixedDepositAccountById(this.requestSpec, this.responseSpec,
fixedDepositAccountId); fixedDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Float expectedPrematureAmount = principal;
Double maturityAmount = Math.floor((Float) fixedDepositAccountData.get("maturityAmount")); Float maturityAmount = (Float) fixedDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
/*** /***
@@ -105,10 +105,11 @@ public class RecurringDepositTest {
// TODO Given the difference in calculation methods in test vs application, // TODO Given the difference in calculation methods in test vs application,
// the exact values // the exact values
// returned may differ enough to cause differences in rounding. Given this, // returned may differ enough to cause differences in rounding. Given this,
// we only compare the full // we only compare that the result is within THRESHOLD of the expected amount.
// digits. A proper solution would be to implement the exact interest // A proper solution would be to implement the exact interest
// calculation in this test, // calculation in this test,
// and then to compare the exact results // and then to compare the exact results
public static final Float THRESHOLD = 1.0f;
@BeforeEach @BeforeEach
public void setup() { public void setup() {
@@ -467,10 +468,11 @@ public class RecurringDepositTest {
HashMap savingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId); HashMap savingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
Double balanceAfter = Math.floor((Float) savingsSummaryAfter.get("accountBalance")); Float balanceAfter = (Float) savingsSummaryAfter.get("accountBalance");
Double expectedSavingsBalance = Math.floor(balanceBefore + prematurityAmount); Float expectedSavingsBalance = balanceBefore + prematurityAmount;
Assertions.assertEquals(expectedSavingsBalance, balanceAfter, "Verifying Savings Account Balance after Premature Closure"); Assertions.assertTrue(Math.abs(expectedSavingsBalance - balanceAfter) < THRESHOLD,
"Verifying Savings Account Balance after Premature Closure");
} }
@@ -675,10 +677,11 @@ public class RecurringDepositTest {
HashMap savingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId); HashMap savingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
Double balanceAfter = Math.floor((Float) savingsSummaryAfter.get("accountBalance")); Float balanceAfter = (Float) savingsSummaryAfter.get("accountBalance");
Double expectedSavingsBalance = Math.floor(balanceBefore + prematurityAmount); Float expectedSavingsBalance = balanceBefore + prematurityAmount;
Assertions.assertEquals(expectedSavingsBalance, balanceAfter, "Verifying Savings Account Balance after Premature Closure"); Assertions.assertTrue(Math.abs(expectedSavingsBalance - balanceAfter) < THRESHOLD,
"Verifying Savings Account Balance after Premature Closure");
} }
@@ -1410,10 +1413,8 @@ public class RecurringDepositTest {
principal = RecurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositAmount, depositPeriod, principal = RecurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositAmount, depositPeriod,
interestPerDay, MONTHLY_INTERVAL, MONTHLY_INTERVAL); interestPerDay, MONTHLY_INTERVAL, MONTHLY_INTERVAL);
principal = (float) Math.floor(principal);
maturityAmount = (float) Math.floor(maturityAmount);
LOG.info("{}", principal.toString()); LOG.info("{}", principal.toString());
Assertions.assertEquals(principal, maturityAmount, "Verifying Maturity amount for Recurring Deposit Account"); Assertions.assertTrue(Math.abs(principal - maturityAmount) < THRESHOLD, "Verifying Maturity amount for Recurring Deposit Account");
} }
/*** /***
@@ -1492,10 +1493,8 @@ public class RecurringDepositTest {
principal = RecurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositAmount, depositPeriod, principal = RecurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositAmount, depositPeriod,
interestPerDay, MONTHLY_INTERVAL, MONTHLY_INTERVAL); interestPerDay, MONTHLY_INTERVAL, MONTHLY_INTERVAL);
principal = (float) Math.floor(principal);
maturityAmount = (float) Math.floor(maturityAmount);
LOG.info("{}", principal.toString()); LOG.info("{}", principal.toString());
Assertions.assertEquals(principal, maturityAmount, "Verifying Maturity amount for Recurring Deposit Account"); Assertions.assertTrue(Math.abs(principal - maturityAmount) < THRESHOLD, "Verifying Maturity amount for Recurring Deposit Account");
} }
/*** /***
@@ -1574,7 +1573,7 @@ public class RecurringDepositTest {
Float interestToBePosted = (float) (interestPerDay * principal * daysInMonth); Float interestToBePosted = (float) (interestPerDay * principal * daysInMonth);
principal += interestToBePosted; principal += interestToBePosted;
Float expectedBalanceAfter = (float) Math.floor(principal); Float expectedBalanceAfter = principal;
LOG.info("{}", expectedBalanceAfter.toString()); LOG.info("{}", expectedBalanceAfter.toString());
Integer transactionIdForPostInterest = this.recurringDepositAccountHelper Integer transactionIdForPostInterest = this.recurringDepositAccountHelper
@@ -1582,13 +1581,13 @@ public class RecurringDepositTest {
Assertions.assertNotNull(transactionIdForPostInterest); Assertions.assertNotNull(transactionIdForPostInterest);
HashMap recurringDepositAccountSummary = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId); HashMap recurringDepositAccountSummary = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId);
Float interestAmountPosted = (float) Math.floor((Float) recurringDepositAccountSummary.get("totalInterestPosted")); Float interestAmountPosted = (Float) recurringDepositAccountSummary.get("totalInterestPosted");
Float principalAfter = (float) Math.floor((Float) recurringDepositAccountSummary.get("accountBalance")); Float principalAfter = (Float) recurringDepositAccountSummary.get("accountBalance");
interestToBePosted = (float) Math.floor(interestToBePosted);
Assertions.assertEquals(interestToBePosted, interestAmountPosted, Assertions.assertTrue(Math.abs(interestToBePosted - interestAmountPosted) < THRESHOLD,
"Verifying Amount of Interest Posted to Recurring Deposit Account"); "Verifying Amount of Interest Posted to Recurring Deposit Account");
Assertions.assertEquals(expectedBalanceAfter, principalAfter, "Verifying Principal Amount after Interest Posting"); Assertions.assertTrue(Math.abs(expectedBalanceAfter - principalAfter) < THRESHOLD,
"Verifying Principal Amount after Interest Posting");
} }
@@ -1710,10 +1709,9 @@ public class RecurringDepositTest {
recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec, recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
recurringDepositAccountId); recurringDepositAccountId);
principal = (float) Math.floor(principal); Float maturityAmount = (Float) recurringDepositAccountData.get("maturityAmount");
Float maturityAmount = (float) Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
Assertions.assertEquals(principal, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(principal - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@@ -1840,10 +1838,9 @@ public class RecurringDepositTest {
recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec, recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
recurringDepositAccountId); recurringDepositAccountId);
principal = (float) Math.floor(principal); Float maturityAmount = (Float) recurringDepositAccountData.get("maturityAmount");
Float maturityAmount = (float) Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
Assertions.assertEquals(principal, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(principal - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@@ -1977,10 +1974,9 @@ public class RecurringDepositTest {
recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec, recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
recurringDepositAccountId); recurringDepositAccountId);
principal = (float) Math.floor(principal); Float maturityAmount = (Float) recurringDepositAccountData.get("maturityAmount");
Float maturityAmount = (float) Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
Assertions.assertEquals(principal, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(principal - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@@ -2119,10 +2115,9 @@ public class RecurringDepositTest {
recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec, recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
recurringDepositAccountId); recurringDepositAccountId);
principal = (float) Math.floor(principal); Float maturityAmount = (Float) recurringDepositAccountData.get("maturityAmount");
Float maturityAmount = (float) Math.floor((Float) recurringDepositAccountData.get("maturityAmount"));
Assertions.assertEquals(principal, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(principal - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@@ -2200,10 +2195,8 @@ public class RecurringDepositTest {
principal = RecurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = RecurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
depositPeriod, interestPerDay, DAILY_COMPOUNDING_INTERVAL, MONTHLY_INTERVAL); depositPeriod, interestPerDay, DAILY_COMPOUNDING_INTERVAL, MONTHLY_INTERVAL);
principal = (float) Math.floor(principal);
maturityAmount = (float) Math.floor(maturityAmount);
LOG.info("{}", principal.toString()); LOG.info("{}", principal.toString());
Assertions.assertEquals(principal, maturityAmount, "Verifying Maturity amount for Recurring Deposit Account"); Assertions.assertTrue(Math.abs(principal - maturityAmount) < THRESHOLD, "Verifying Maturity amount for Recurring Deposit Account");
} }
@@ -2282,10 +2275,8 @@ public class RecurringDepositTest {
principal = RecurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, principal = RecurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount,
depositPeriod, interestPerDay, DAILY_COMPOUNDING_INTERVAL, MONTHLY_INTERVAL); depositPeriod, interestPerDay, DAILY_COMPOUNDING_INTERVAL, MONTHLY_INTERVAL);
principal = (float) Math.floor(principal);
maturityAmount = (float) Math.floor(maturityAmount);
LOG.info("{}", principal.toString()); LOG.info("{}", principal.toString());
Assertions.assertEquals(principal, maturityAmount, "Verifying Maturity amount for Recurring Deposit Account"); Assertions.assertTrue(Math.abs(principal - maturityAmount) < THRESHOLD, "Verifying Maturity amount for Recurring Deposit Account");
} }
@@ -2372,10 +2363,10 @@ public class RecurringDepositTest {
recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec, recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
recurringDepositAccountId); recurringDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Float expectedPrematureAmount = principal;
Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Float maturityAmount = (Float) recurringDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@@ -2462,10 +2453,10 @@ public class RecurringDepositTest {
recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec, recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
recurringDepositAccountId); recurringDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Float expectedPrematureAmount = principal;
Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Float maturityAmount = (Float) recurringDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@@ -2552,10 +2543,10 @@ public class RecurringDepositTest {
recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec, recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
recurringDepositAccountId); recurringDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Float expectedPrematureAmount = principal;
Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Float maturityAmount = (Float) recurringDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Maturity amount");
} }
@@ -2642,10 +2633,10 @@ public class RecurringDepositTest {
recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec, recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
recurringDepositAccountId); recurringDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Float expectedPrematureAmount = principal;
Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Float maturityAmount = (Float) recurringDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Maturity amount");
} }
@@ -2732,10 +2723,10 @@ public class RecurringDepositTest {
recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec, recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
recurringDepositAccountId); recurringDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Float expectedPrematureAmount = principal;
Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Float maturityAmount = (Float) recurringDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }
@@ -2822,10 +2813,10 @@ public class RecurringDepositTest {
recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec, recurringDepositAccountData = RecurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec,
recurringDepositAccountId); recurringDepositAccountId);
Double expectedPrematureAmount = Math.floor(principal); Float expectedPrematureAmount = principal;
Double maturityAmount = Math.floor((Float) recurringDepositAccountData.get("maturityAmount")); Float maturityAmount = (Float) recurringDepositAccountData.get("maturityAmount");
Assertions.assertEquals(expectedPrematureAmount, maturityAmount, "Verifying Pre-Closure maturity amount"); Assertions.assertTrue(Math.abs(expectedPrematureAmount - maturityAmount) < THRESHOLD, "Verifying Pre-Closure maturity amount");
} }