[FINERACT-1825] fixing integration tests failing on specific dates
This commit is contained in:
+41
-67
@@ -27,7 +27,10 @@ import io.restassured.specification.RequestSpecification;
|
|||||||
import io.restassured.specification.ResponseSpecification;
|
import io.restassured.specification.ResponseSpecification;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -1855,27 +1858,20 @@ public class RecurringDepositTest {
|
|||||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||||
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||||
|
|
||||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy");
|
||||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM", Locale.US);
|
|
||||||
DateFormat currentDateFormat = new SimpleDateFormat("dd");
|
|
||||||
|
|
||||||
Calendar todaysDate = Calendar.getInstance();
|
LocalDate todaysDate = LocalDate.of(2022, 6, 20);
|
||||||
todaysDate.add(Calendar.MONTH, -3);
|
LocalDate validFromDate = todaysDate.minusMonths(3);
|
||||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
final String VALID_FROM = validFromDate.format(dateFormat);
|
||||||
todaysDate.add(Calendar.YEAR, 10);
|
LocalDate validToDate = todaysDate.minusMonths(3).plusYears(10);
|
||||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
final String VALID_TO = validToDate.format(dateFormat);
|
||||||
|
|
||||||
todaysDate = Calendar.getInstance();
|
todaysDate = LocalDate.of(2022, 5, 19);
|
||||||
todaysDate.add(Calendar.MONTH, -1);
|
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate);
|
||||||
todaysDate.add(Calendar.DAY_OF_MONTH, -1);
|
final String APPROVED_ON_DATE = dateFormat.format(todaysDate);
|
||||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
final String ACTIVATION_DATE = dateFormat.format(todaysDate);
|
||||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
String expectedFirstDepositOnDate = dateFormat.format(todaysDate);
|
||||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
final String CLOSED_ON_DATE = dateFormat.format(LocalDate.of(2022, 7, 2));
|
||||||
String expectedFirstDepositOnDate = dateFormat.format(todaysDate.getTime());
|
|
||||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
|
||||||
todaysDate.add(Calendar.MONTH, 1);
|
|
||||||
todaysDate.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
final String CLOSED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
|
||||||
|
|
||||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||||
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||||
@@ -1914,13 +1910,11 @@ public class RecurringDepositTest {
|
|||||||
ArrayList<ArrayList<HashMap>> interestRateChartData = RecurringDepositProductHelper
|
ArrayList<ArrayList<HashMap>> interestRateChartData = RecurringDepositProductHelper
|
||||||
.getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
|
.getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
|
||||||
|
|
||||||
Calendar activationDate = Calendar.getInstance();
|
LocalDate activationDate = LocalDate.of(2022, 6, 20);
|
||||||
activationDate.add(Calendar.MONTH, -1);
|
ZonedDateTime start = ZonedDateTime.of(activationDate.minusMonths(1).minusDays(1), LocalTime.MIN, Utils.getZoneIdOfTenant());
|
||||||
activationDate.add(Calendar.DAY_OF_MONTH, -1);
|
|
||||||
ZonedDateTime start = ZonedDateTime.ofInstant(activationDate.getTime().toInstant(), Utils.getZoneIdOfTenant());
|
|
||||||
|
|
||||||
Calendar prematureClosureDate = Calendar.getInstance();
|
LocalDate prematureClosureDate = LocalDate.of(2022, 6, 20);
|
||||||
ZonedDateTime end = ZonedDateTime.ofInstant(prematureClosureDate.getTime().toInstant(), Utils.getZoneIdOfTenant());
|
ZonedDateTime end = ZonedDateTime.of(prematureClosureDate, LocalTime.MIN, Utils.getZoneIdOfTenant());
|
||||||
|
|
||||||
Integer depositedPeriod = Math.toIntExact(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate()));
|
Integer depositedPeriod = Math.toIntExact(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate()));
|
||||||
|
|
||||||
@@ -1938,18 +1932,14 @@ public class RecurringDepositTest {
|
|||||||
LOG.info("per day = {}", perDay);
|
LOG.info("per day = {}", perDay);
|
||||||
double interestPerDay = interestRateInFraction * perDay;
|
double interestPerDay = interestRateInFraction * perDay;
|
||||||
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
LocalDate date = LocalDate.of(2022, 6, 20);
|
||||||
calendar.add(Calendar.MONTH, -1);
|
Integer currentDate = date.minusMonths(1).minusDays(1).getDayOfMonth();
|
||||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
Integer daysInMonth = date.withDayOfMonth(date.getMonth().length(date.isLeapYear())).getDayOfMonth();
|
||||||
Integer currentDate = Integer.valueOf(currentDateFormat.format(calendar.getTime()));
|
|
||||||
Integer daysInMonth = calendar.getActualMaximum(Calendar.DATE);
|
|
||||||
daysInMonth = daysInMonth - currentDate + 1;
|
daysInMonth = daysInMonth - currentDate + 1;
|
||||||
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
|
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
|
||||||
principal += interestPerMonth + depositAmount;
|
principal += interestPerMonth + depositAmount;
|
||||||
calendar.add(Calendar.DATE, daysInMonth);
|
|
||||||
LOG.info("{}", monthDayFormat.format(calendar.getTime()));
|
|
||||||
|
|
||||||
expectedFirstDepositOnDate = dateFormat.format(calendar.getTime());
|
expectedFirstDepositOnDate = dateFormat.format(date.plusDays(daysInMonth));
|
||||||
Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
|
Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
|
||||||
DEPOSIT_AMOUNT, expectedFirstDepositOnDate);
|
DEPOSIT_AMOUNT, expectedFirstDepositOnDate);
|
||||||
Assertions.assertNotNull(transactionIdForDeposit);
|
Assertions.assertNotNull(transactionIdForDeposit);
|
||||||
@@ -1991,27 +1981,18 @@ public class RecurringDepositTest {
|
|||||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||||
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||||
|
|
||||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy");
|
||||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM", Locale.US);
|
|
||||||
DateFormat currentDateFormat = new SimpleDateFormat("dd");
|
|
||||||
|
|
||||||
Calendar todaysDate = Calendar.getInstance();
|
LocalDate todaysDate = LocalDate.of(2022, 6, 20);
|
||||||
todaysDate.add(Calendar.MONTH, -3);
|
final String VALID_FROM = dateFormat.format(todaysDate.minusMonths(3));
|
||||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
final String VALID_TO = dateFormat.format(todaysDate.plusYears(10));
|
||||||
todaysDate.add(Calendar.YEAR, 10);
|
|
||||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
|
||||||
|
|
||||||
todaysDate = Calendar.getInstance();
|
todaysDate = LocalDate.of(2022, 5, 19);
|
||||||
todaysDate.add(Calendar.MONTH, -1);
|
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate);
|
||||||
todaysDate.add(Calendar.DAY_OF_MONTH, -1);
|
final String APPROVED_ON_DATE = dateFormat.format(todaysDate);
|
||||||
final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
final String ACTIVATION_DATE = dateFormat.format(todaysDate);
|
||||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
String expectedFirstDepositOnDate = dateFormat.format(todaysDate);
|
||||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
final String CLOSED_ON_DATE = dateFormat.format(LocalDate.of(2022, 7, 2));
|
||||||
String expectedFirstDepositOnDate = dateFormat.format(todaysDate.getTime());
|
|
||||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
|
||||||
todaysDate.add(Calendar.MONTH, 1);
|
|
||||||
todaysDate.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
final String CLOSED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
|
||||||
|
|
||||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||||
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||||
@@ -2055,13 +2036,11 @@ public class RecurringDepositTest {
|
|||||||
ArrayList<ArrayList<HashMap>> interestRateChartData = RecurringDepositProductHelper
|
ArrayList<ArrayList<HashMap>> interestRateChartData = RecurringDepositProductHelper
|
||||||
.getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
|
.getInterestRateChartSlabsByProductId(this.requestSpec, this.responseSpec, recurringDepositProductId);
|
||||||
|
|
||||||
Calendar activationDate = Calendar.getInstance();
|
LocalDate activationDate = LocalDate.of(2022, 6, 20);
|
||||||
activationDate.add(Calendar.MONTH, -1);
|
ZonedDateTime start = ZonedDateTime.of(activationDate.minusMonths(1).minusDays(1), LocalTime.MIN, Utils.getZoneIdOfTenant());
|
||||||
activationDate.add(Calendar.DAY_OF_MONTH, -1);
|
|
||||||
ZonedDateTime start = ZonedDateTime.ofInstant(activationDate.getTime().toInstant(), Utils.getZoneIdOfTenant());
|
|
||||||
|
|
||||||
Calendar prematureClosureDate = Calendar.getInstance();
|
LocalDate prematureClosureDate = LocalDate.of(2022, 6, 20);
|
||||||
ZonedDateTime end = ZonedDateTime.ofInstant(prematureClosureDate.getTime().toInstant(), Utils.getZoneIdOfTenant());
|
ZonedDateTime end = ZonedDateTime.of(prematureClosureDate, LocalTime.MIN, Utils.getZoneIdOfTenant());
|
||||||
|
|
||||||
Integer depositedPeriod = Math.toIntExact(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate()));
|
Integer depositedPeriod = Math.toIntExact(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate()));
|
||||||
|
|
||||||
@@ -2079,18 +2058,13 @@ public class RecurringDepositTest {
|
|||||||
LOG.info("per day = {}", perDay);
|
LOG.info("per day = {}", perDay);
|
||||||
double interestPerDay = interestRateInFraction * perDay;
|
double interestPerDay = interestRateInFraction * perDay;
|
||||||
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
LocalDate date = LocalDate.of(2022, 6, 20);
|
||||||
calendar.add(Calendar.MONTH, -1);
|
Integer currentDate = date.minusMonths(1).minusDays(1).getDayOfMonth();
|
||||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
Integer daysInMonth = date.withDayOfMonth(date.getMonth().length(date.isLeapYear())).getDayOfMonth();
|
||||||
Integer currentDate = Integer.valueOf(currentDateFormat.format(calendar.getTime()));
|
|
||||||
Integer daysInMonth = calendar.getActualMaximum(Calendar.DATE);
|
|
||||||
daysInMonth = daysInMonth - currentDate + 1;
|
daysInMonth = daysInMonth - currentDate + 1;
|
||||||
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
|
Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth);
|
||||||
principal += interestPerMonth + depositAmount;
|
principal += interestPerMonth + depositAmount;
|
||||||
calendar.add(Calendar.DATE, daysInMonth);
|
expectedFirstDepositOnDate = dateFormat.format(date.plusDays(daysInMonth));
|
||||||
LOG.info("{}", monthDayFormat.format(calendar.getTime()));
|
|
||||||
|
|
||||||
expectedFirstDepositOnDate = dateFormat.format(calendar.getTime());
|
|
||||||
Integer newTransactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
|
Integer newTransactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
|
||||||
DEPOSIT_AMOUNT, expectedFirstDepositOnDate);
|
DEPOSIT_AMOUNT, expectedFirstDepositOnDate);
|
||||||
Assertions.assertNotNull(newTransactionIdForDeposit);
|
Assertions.assertNotNull(newTransactionIdForDeposit);
|
||||||
|
|||||||
Reference in New Issue
Block a user