You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by ar...@apache.org on 2022/06/27 07:27:12 UTC
[fineract] branch develop updated: Unstable integration test due different timezones
This is an automated email from the ASF dual-hosted git repository.
arnold pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new 55949bf8b Unstable integration test due different timezones
55949bf8b is described below
commit 55949bf8b07d1c026fc80d2ce393d35d04aa2dd4
Author: Jose Alberto Hernandez <al...@MacBook-Pro.local>
AuthorDate: Sat Jun 25 16:44:51 2022 -0500
Unstable integration test due different timezones
---
.../client/ClientEntityImportHandler.java | 6 +++
.../client/ClientPersonImportHandler.java | 6 +++
.../infrastructure/core/service/DateUtils.java | 30 +++++++++++-
...tandingInstructionWritePlatformServiceImpl.java | 2 +-
.../AccountingScenarioIntegrationTest.java | 55 ++++++++++------------
.../integrationtests/SchedulerJobsTestResults.java | 36 +++++++++-----
.../importhandler/loan/LoanImportHandlerTest.java | 23 ++++-----
.../common/loans/LoanTransactionHelper.java | 2 +-
8 files changed, 102 insertions(+), 58 deletions(-)
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/client/ClientEntityImportHandler.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/client/ClientEntityImportHandler.java
index 2a231c10d..91b7c0be6 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/client/ClientEntityImportHandler.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/client/ClientEntityImportHandler.java
@@ -88,8 +88,14 @@ public class ClientEntityImportHandler implements ImportHandler {
String name = ImportHandlerUtils.readAsString(ClientEntityConstants.NAME_COL, row);
String officeName = ImportHandlerUtils.readAsString(ClientEntityConstants.OFFICE_NAME_COL, row);
Long officeId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME), officeName);
+ if (officeId == 0L) {
+ officeId = null;
+ }
String staffName = ImportHandlerUtils.readAsString(ClientEntityConstants.STAFF_NAME_COL, row);
Long staffId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME), staffName);
+ if (staffId == 0L) {
+ staffId = null;
+ }
LocalDate incorportionDate = ImportHandlerUtils.readAsDate(ClientEntityConstants.INCOPORATION_DATE_COL, row);
LocalDate incorporationTill = ImportHandlerUtils.readAsDate(ClientEntityConstants.INCOPORATION_VALID_TILL_COL, row);
String mobileNo = null;
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/client/ClientPersonImportHandler.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/client/ClientPersonImportHandler.java
index 4f7f04a89..d48aaea1b 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/client/ClientPersonImportHandler.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/client/ClientPersonImportHandler.java
@@ -88,8 +88,14 @@ public class ClientPersonImportHandler implements ImportHandler {
String middleName = ImportHandlerUtils.readAsString(ClientPersonConstants.MIDDLE_NAME_COL, row);
String officeName = ImportHandlerUtils.readAsString(ClientPersonConstants.OFFICE_NAME_COL, row);
Long officeId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME), officeName);
+ if (officeId == 0L) {
+ officeId = null;
+ }
String staffName = ImportHandlerUtils.readAsString(ClientPersonConstants.STAFF_NAME_COL, row);
Long staffId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME), staffName);
+ if (staffId == 0L) {
+ staffId = null;
+ }
String externalId = ImportHandlerUtils.readAsString(ClientPersonConstants.EXTERNAL_ID_COL, row);
LocalDate submittedOn = ImportHandlerUtils.readAsDate(ClientPersonConstants.SUBMITTED_ON_COL, row);
LocalDate activationDate = ImportHandlerUtils.readAsDate(ClientPersonConstants.ACTIVATION_DATE_COL, row);
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/DateUtils.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/DateUtils.java
index b39a3acc2..e5250b0ea 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/DateUtils.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/DateUtils.java
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.core.service;
import java.text.DateFormat;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -74,6 +75,10 @@ public final class DateUtils {
return createDate(localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth());
}
+ public static LocalDate convertToLocalDate(final Date dateToConvert, final ZoneId zoneId) {
+ return dateToConvert.toInstant().atZone(zoneId).toLocalDate();
+ }
+
public static Date createDate(int year, int month, int day) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
@@ -97,10 +102,27 @@ public final class DateUtils {
return today;
}
- public static LocalDate parseLocalDate(final String stringDate, final String pattern) {
+ public static Date parseDate(final String stringDate, final String pattern, final ZoneId zoneId) {
+ try {
+ return new SimpleDateFormat(pattern).parse(stringDate);
+ } catch (final ParseException e) {
+ final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
+ final ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.date.pattern",
+ "The parameter date (" + stringDate + ") is invalid w.r.t. pattern " + pattern, "date", stringDate, pattern);
+ dataValidationErrors.add(error);
+ throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
+ dataValidationErrors, e);
+ }
+ }
+ public static LocalDate parseLocalDate(final String stringDate, final String pattern, final ZoneId zoneId) {
try {
- final DateTimeFormatter dateStringFormat = DateTimeFormatter.ofPattern(pattern).withZone(getDateTimeZoneOfTenant());
+ DateTimeFormatter dateStringFormat;
+ if (zoneId != null) {
+ dateStringFormat = DateTimeFormatter.ofPattern(pattern).withZone(zoneId);
+ } else {
+ dateStringFormat = DateTimeFormatter.ofPattern(pattern);
+ }
final ZonedDateTime dateTime = ZonedDateTime.parse(stringDate, dateStringFormat);
return dateTime.toLocalDate();
} catch (final IllegalArgumentException e) {
@@ -113,6 +135,10 @@ public final class DateUtils {
}
}
+ public static LocalDate parseLocalDate(final String stringDate, final String pattern) {
+ return parseLocalDate(stringDate, pattern, getDateTimeZoneOfTenant());
+ }
+
public static String formatToSqlDate(final Date date) {
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
df.setTimeZone(getTimeZoneOfTenant());
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/StandingInstructionWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/StandingInstructionWritePlatformServiceImpl.java
index 64401dd26..94949b5f6 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/StandingInstructionWritePlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/StandingInstructionWritePlatformServiceImpl.java
@@ -199,11 +199,11 @@ public class StandingInstructionWritePlatformServiceImpl implements StandingInst
Collection<StandingInstructionData> instructionDatas = this.standingInstructionReadPlatformService
.retrieveAll(StandingInstructionStatus.ACTIVE.getValue());
List<Throwable> errors = new ArrayList<>();
+ LocalDate transactionDate = DateUtils.getLocalDateOfTenant();
for (StandingInstructionData data : instructionDatas) {
boolean isDueForTransfer = false;
AccountTransferRecurrenceType recurrenceType = data.recurrenceType();
StandingInstructionType instructionType = data.instructionType();
- LocalDate transactionDate = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
if (recurrenceType.isPeriodicRecurrence()) {
final ScheduledDateGenerator scheduledDateGenerator = new DefaultScheduledDateGenerator();
PeriodFrequencyType frequencyType = data.recurrenceFrequency();
diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AccountingScenarioIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AccountingScenarioIntegrationTest.java
index 6e0c2498e..1a0337f45 100644
--- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AccountingScenarioIntegrationTest.java
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AccountingScenarioIntegrationTest.java
@@ -33,12 +33,17 @@ import java.text.DecimalFormatSymbols;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
+import java.time.LocalTime;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Calendar;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import java.util.TimeZone;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
@@ -66,13 +71,11 @@ import org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
import org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({ "unchecked" })
-@Order(2)
public class AccountingScenarioIntegrationTest {
private static final Logger LOG = LoggerFactory.getLogger(AccountingScenarioIntegrationTest.class);
@@ -110,13 +113,13 @@ public class AccountingScenarioIntegrationTest {
private AccountHelper accountHelper;
private JournalEntryHelper journalEntryHelper;
private SavingsAccountHelper savingsAccountHelper;
- private FixedDepositProductHelper fixedDepositProductHelper;
private FixedDepositAccountHelper fixedDepositAccountHelper;
- private RecurringDepositProductHelper recurringDepositProductHelper;
private RecurringDepositAccountHelper recurringDepositAccountHelper;
private SchedulerJobHelper schedulerJobHelper;
private PeriodicAccrualAccountingHelper periodicAccrualAccountingHelper;
+ private TimeZone systemTimeZone;
+
@BeforeEach
public void setup() {
Utils.initializeRESTAssured();
@@ -129,6 +132,8 @@ public class AccountingScenarioIntegrationTest {
this.journalEntryHelper = new JournalEntryHelper(requestSpec, responseSpec);
this.schedulerJobHelper = new SchedulerJobHelper(requestSpec);
this.periodicAccrualAccountingHelper = new PeriodicAccrualAccountingHelper(requestSpec, responseSpec);
+
+ this.systemTimeZone = TimeZone.getTimeZone(Utils.TENANT_TIME_ZONE);
}
@Test
@@ -361,7 +366,6 @@ public class AccountingScenarioIntegrationTest {
@Test
public void testFixedDepositAccountingFlow() {
- this.fixedDepositProductHelper = new FixedDepositProductHelper(requestSpec, responseSpec);
this.accountHelper = new AccountHelper(requestSpec, responseSpec);
this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(requestSpec, responseSpec);
@@ -440,7 +444,6 @@ public class AccountingScenarioIntegrationTest {
@Test
public void testRecurringDepositAccountingFlow() {
- this.recurringDepositProductHelper = new RecurringDepositProductHelper(requestSpec, responseSpec);
this.accountHelper = new AccountHelper(requestSpec, responseSpec);
this.recurringDepositAccountHelper = new RecurringDepositAccountHelper(requestSpec, responseSpec);
@@ -806,20 +809,14 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
- DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
-
- Calendar todayDate = Calendar.getInstance();
- final String currentDate = dateFormat.format(todayDate.getTime());
+ final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US);
- todayDate.add(Calendar.DATE, -4);
-
- final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todayDate.getTime());
+ final LocalDate localDate = LocalDate.now(this.systemTimeZone.toZoneId());
+ final ZonedDateTime currentDate = ZonedDateTime.of(localDate, LocalTime.MIDNIGHT, this.systemTimeZone.toZoneId());
+ ZonedDateTime zonedDate = currentDate.minusDays(4);
+ final String LOAN_DISBURSEMENT_DATE = dateFormat.format(zonedDate);
- todayDate.add(Calendar.MONTH, 2);
- final String FIRST_REPAYMENT_DATE = dateFormat.format(todayDate.getTime());
-
- todayDate = Calendar.getInstance();
- todayDate.add(Calendar.DATE, -2);
+ zonedDate = currentDate.minusDays(2);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID,
@@ -827,10 +824,10 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
- String.valueOf(flatSpecifiedDueDate), dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
- todayDate.add(Calendar.DATE, 1);
- this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
- String.valueOf(flat), dateFormat.format(todayDate.getTime()), String.valueOf(FEE_PORTION)));
+ String.valueOf(flatSpecifiedDueDate), dateFormat.format(zonedDate), String.valueOf(PENALTY_PORTION)));
+ zonedDate = zonedDate.plusDays(1);
+ this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper
+ .getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flat), dateFormat.format(zonedDate), String.valueOf(FEE_PORTION)));
// CHECK ACCOUNT ENTRIES
LOG.info("Entries ......");
@@ -865,7 +862,7 @@ public class AccountingScenarioIntegrationTest {
float interest4Days = totalInterest / totalDaysInPeriod * 4;
interest4Days = Float.parseFloat(numberFormat.format(interest4Days));
- this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(currentDate), interest4Days, FEE_PORTION,
+ this.loanTransactionHelper.checkAccrualTransactionForRepayment(currentDate.toLocalDate(), interest4Days, FEE_PORTION,
PENALTY_PORTION, loanID);
}
@@ -916,17 +913,15 @@ public class AccountingScenarioIntegrationTest {
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
- Calendar todayDate = Calendar.getInstance();
- final String currentDate = dateFormat.format(todayDate.getTime());
+ Calendar todayDate = Calendar.getInstance(this.systemTimeZone);
todayDate.add(Calendar.DATE, -4);
final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todayDate.getTime());
todayDate.add(Calendar.MONTH, 2);
- final String FIRST_REPAYMENT_DATE = dateFormat.format(todayDate.getTime());
- todayDate = Calendar.getInstance();
+ todayDate = Calendar.getInstance(this.systemTimeZone);
todayDate.add(Calendar.DATE, -2);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
@@ -1123,10 +1118,8 @@ public class AccountingScenarioIntegrationTest {
}
private LocalDate getDateAsLocalDate(String dateAsString) throws ParseException {
- DateFormat df = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
- LocalDate date = LocalDate.ofInstant(df.parse(dateAsString).toInstant(), DateUtils.getDateTimeZoneOfTenant());
-
- return date;
+ final Date dateParsed = DateUtils.parseDate(dateAsString, "dd MMMM yyyy", null);
+ return DateUtils.convertToLocalDate(dateParsed, this.systemTimeZone.toZoneId());
}
}
diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java
index e3cf9eada..b1de74bba 100644
--- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java
@@ -32,14 +32,20 @@ import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
+import java.time.Duration;
import java.time.LocalDate;
+import java.time.LocalTime;
import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.TimeZone;
import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
@@ -94,6 +100,8 @@ public class SchedulerJobsTestResults {
private JournalEntryHelper journalEntryHelper;
private StandingInstructionsHelper standingInstructionsHelper;
+ private TimeZone systemTimeZone;
+
@BeforeEach
public void setup() {
Utils.initializeRESTAssured();
@@ -103,6 +111,8 @@ public class SchedulerJobsTestResults {
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.accountHelper = new AccountHelper(requestSpec, responseSpec);
this.journalEntryHelper = new JournalEntryHelper(requestSpec, responseSpec);
+
+ this.systemTimeZone = TimeZone.getTimeZone(Utils.TENANT_TIME_ZONE);
}
@AfterEach
@@ -459,18 +469,20 @@ public class SchedulerJobsTestResults {
this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
this.standingInstructionsHelper = new StandingInstructionsHelper(requestSpec, responseSpec);
- DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
- DateFormat monthDayFormat = new SimpleDateFormat("dd MMMM", Locale.US);
-
- Calendar todaysDate = Calendar.getInstance();
-
- final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
-
- todaysDate.add(Calendar.WEEK_OF_YEAR, -1);
- final String VALID_FROM = dateFormat.format(todaysDate.getTime());
-
- todaysDate.add(Calendar.YEAR, 1);
- final String VALID_TO = dateFormat.format(todaysDate.getTime());
+ final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.US);
+ final DateTimeFormatter monthDayFormat = DateTimeFormatter.ofPattern("dd MMMM", Locale.US);
+
+ // Create the LocalDate with the Zone used by default
+ final LocalDate localDate = LocalDate.now(this.systemTimeZone.toZoneId());
+ ZonedDateTime currentDate = ZonedDateTime.of(localDate, LocalTime.MIDNIGHT, this.systemTimeZone.toZoneId());
+ // When the Stanging Instruction will be applied
+ final String MONTH_DAY = monthDayFormat.format(currentDate.toLocalDate());
+ // Standing Instruction valid from (One week before today)
+ currentDate = currentDate.minus(Duration.ofDays(7));
+ final String VALID_FROM = dateFormat.format(currentDate);
+ // Standing Instruction valid to (One year after)
+ currentDate = currentDate.plus(1, ChronoUnit.YEARS);
+ final String VALID_TO = dateFormat.format(currentDate);
final Integer clientID = ClientHelper.createClient(requestSpec, responseSpec);
Assertions.assertNotNull(clientID);
diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java
index 7ac2b98d8..6307296f6 100644
--- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java
@@ -31,9 +31,9 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.ParseException;
-import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -70,7 +70,6 @@ public class LoanImportHandlerTest {
private static final Logger LOG = LoggerFactory.getLogger(LoanImportHandlerTest.class);
private static final String CREATE_CLIENT_URL = "/fineract-provider/api/v1/clients?" + Utils.TENANT_IDENTIFIER;
- private static final String CREATE_CHARGE_URL = "/fineract-provider/api/v1/charges?" + Utils.TENANT_IDENTIFIER;
public static final String DATE_FORMAT = "dd MMMM yyyy";
private ResponseSpecification responseSpec;
@@ -167,7 +166,7 @@ public class LoanImportHandlerTest {
Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type");
LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
- Workbook workbook = loanTransactionHelper.getLoanWorkbook("dd MMMM yyyy");
+ Workbook workbook = loanTransactionHelper.getLoanWorkbook(DATE_FORMAT);
// insert dummy data into loan Sheet
Sheet loanSheet = workbook.getSheet(TemplatePopulateImportConstants.LOANS_SHEET_NAME);
@@ -179,11 +178,13 @@ public class LoanImportHandlerTest {
firstLoanRow.createCell(LoanConstants.CLIENT_EXTERNAL_ID).setCellValue(externalId);
firstLoanRow.createCell(LoanConstants.PRODUCT_COL).setCellValue(loanProductJson.getString("name"));
firstLoanRow.createCell(LoanConstants.LOAN_OFFICER_NAME_COL).setCellValue((String) staffMap.get("displayName"));
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
- Date date = simpleDateFormat.parse("13 May 2017");
- firstLoanRow.createCell(LoanConstants.SUBMITTED_ON_DATE_COL).setCellValue(date);
- firstLoanRow.createCell(LoanConstants.APPROVED_DATE_COL).setCellValue(date);
- firstLoanRow.createCell(LoanConstants.DISBURSED_DATE_COL).setCellValue(date);
+
+ final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(DATE_FORMAT, Locale.US);
+ final LocalDate localDate = LocalDate.parse("17 May 2017", dateFormat);
+
+ firstLoanRow.createCell(LoanConstants.SUBMITTED_ON_DATE_COL).setCellValue(localDate);
+ firstLoanRow.createCell(LoanConstants.APPROVED_DATE_COL).setCellValue(localDate);
+ firstLoanRow.createCell(LoanConstants.DISBURSED_DATE_COL).setCellValue(localDate);
firstLoanRow.createCell(LoanConstants.DISBURSED_PAYMENT_TYPE_COL).setCellValue(paymentTypeName);
firstLoanRow.createCell(LoanConstants.FUND_NAME_COL).setCellValue(fundName);
firstLoanRow.createCell(LoanConstants.PRINCIPAL_COL).setCellValue(loanProductJson.getFloat("principal"));
@@ -208,9 +209,9 @@ public class LoanImportHandlerTest {
firstLoanRow.createCell(LoanConstants.GRACE_ON_PRINCIPAL_PAYMENT_COL).setCellValue(0);
firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_PAYMENT_COL).setCellValue(0);
firstLoanRow.createCell(LoanConstants.GRACE_ON_INTEREST_CHARGED_COL).setCellValue(0);
- firstLoanRow.createCell(LoanConstants.FIRST_REPAYMENT_COL).setCellValue(date);
+ firstLoanRow.createCell(LoanConstants.FIRST_REPAYMENT_COL).setCellValue(localDate);
firstLoanRow.createCell(LoanConstants.TOTAL_AMOUNT_REPAID_COL).setCellValue(6000);
- firstLoanRow.createCell(LoanConstants.LAST_REPAYMENT_DATE_COL).setCellValue(date);
+ firstLoanRow.createCell(LoanConstants.LAST_REPAYMENT_DATE_COL).setCellValue(localDate);
firstLoanRow.createCell(LoanConstants.REPAYMENT_TYPE_COL).setCellValue(paymentTypeName);
firstLoanRow.createCell(LoanConstants.LOAN_COLLATERAL_ID).setCellValue(collaterals.get(0).get("clientCollateralId").toString());
firstLoanRow.createCell(LoanConstants.LOAN_COLLATERAL_QUANTITY).setCellValue(collaterals.get(0).get("quantity").toString());
diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
index ca327255e..e2688f2da 100644
--- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
@@ -788,7 +788,7 @@ public class LoanTransactionHelper {
LocalDate accrualEntryDate = LocalDate.of(accrualEntryDateAsArray.get(0), accrualEntryDateAsArray.get(1),
accrualEntryDateAsArray.get(2));
- if (transactionDate.equals(accrualEntryDate)) {
+ if (transactionDate.isEqual(accrualEntryDate)) {
isTransactionFound = true;
assertEquals(interestPortion, Float.valueOf(String.valueOf(transactions.get(i).get("interestPortion"))),
"Mismatch in transaction amounts");