From d3b6a3574ccd5cd42688d39452635f687450a5da Mon Sep 17 00:00:00 2001 From: Petri Tuomola Date: Mon, 15 Jun 2020 12:27:00 +0300 Subject: [PATCH] FINERACT-723: Fixed to use the right date in more tests --- .../ClientSavingsIntegrationTest.java | 3 +-- ...ndoRejectAndWithdrawalIntegrationTest.java | 20 +++++++++---------- .../GroupSavingsIntegrationTest.java | 4 ++-- .../integrationtests/common/CenterDomain.java | 3 +-- .../shares/ShareAccountIntegrationTests.java | 3 +-- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java index 8f0aff5bf..cbf168774 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java @@ -37,7 +37,6 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Locale; -import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; @@ -2070,7 +2069,7 @@ public class ClientSavingsIntegrationTest { error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); Integer releaseTransactionId = this.savingsAccountHelper.releaseAmount(savingsId, holdTransactionId); - Date today = DateUtils.getDateOfTenant(); + Date today = Utils.getLocalDateOfTenant().toDate(); String todayDate = today.toString(); SimpleDateFormat dt1 = new SimpleDateFormat("dd MMM yyyy"); todayDate = dt1.format(today).toString(); diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientUndoRejectAndWithdrawalIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientUndoRejectAndWithdrawalIntegrationTest.java index 4902dfbbe..024c710a2 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientUndoRejectAndWithdrawalIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientUndoRejectAndWithdrawalIntegrationTest.java @@ -28,7 +28,7 @@ import io.restassured.specification.ResponseSpecification; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Calendar; +import java.util.Date; import java.util.HashMap; import java.util.Locale; import org.apache.fineract.integrationtests.common.ClientHelper; @@ -123,8 +123,8 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest { ClientStatusChecker.verifyClientPending(status); DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); - Calendar todaysDate = Calendar.getInstance(); - final String undoRejectDate = dateFormat.format(todaysDate.getTime()); + Date todaysDate = Utils.getLocalDateOfTenant().toDate(); + final String undoRejectDate = dateFormat.format(todaysDate); ArrayList> clientErrorData = validationErrorHelper.undoRejectedclient(clientId, CommonConstants.RESPONSE_ERROR, undoRejectDate); @@ -155,9 +155,8 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest { status = this.clientHelper.rejectClient(clientId); ClientStatusChecker.verifyClientRejected(status); DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); - Calendar todaysDate = Calendar.getInstance(); - todaysDate.add(Calendar.DATE, 1); - final String undoRejectDate = dateFormat.format(todaysDate.getTime()); + Date tomorrowsDate = Utils.getLocalDateOfTenant().plusDays(1).toDate(); + final String undoRejectDate = dateFormat.format(tomorrowsDate); ArrayList> clientErrorData = validationErrorHelper.undoWithdrawclient(clientId, CommonConstants.RESPONSE_ERROR, undoRejectDate); assertEquals("validation.msg.client.reopenedDate.is.greater.than.date", @@ -232,8 +231,8 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest { HashMap status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId)); DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); - Calendar todaysDate = Calendar.getInstance(); - final String undoWithdrawDate = dateFormat.format(todaysDate.getTime()); + Date todaysDate = Utils.getLocalDateOfTenant().toDate(); + final String undoWithdrawDate = dateFormat.format(todaysDate); ArrayList> clientErrorData = validationErrorHelper.undoWithdrawclient(clientId, CommonConstants.RESPONSE_ERROR, undoWithdrawDate); @@ -264,9 +263,8 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest { status = this.clientHelper.withdrawClient(clientId); ClientStatusChecker.verifyClientWithdrawn(status); DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); - Calendar todaysDate = Calendar.getInstance(); - todaysDate.add(Calendar.DATE, 1); - final String undoWithdrawDate = dateFormat.format(todaysDate.getTime()); + Date tomorrowsDate = Utils.getLocalDateOfTenant().plusDays(1).toDate(); + final String undoWithdrawDate = dateFormat.format(tomorrowsDate); ArrayList> clientErrorData = validationErrorHelper.undoWithdrawclient(clientId, CommonConstants.RESPONSE_ERROR, undoWithdrawDate); assertEquals("validation.msg.client.reopenedDate.is.greater.than.date", diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java index cd984e813..613c872c1 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java @@ -758,9 +758,9 @@ public class GroupSavingsIntegrationTest { LocalDate expectedNextDueDate = new LocalDate((Integer) dates.get(0), (Integer) dates.get(1), (Integer) dates.get(2)) .plusWeeks((Integer) paidCharge.get("feeInterval")); assertEquals(expectedNextDueDate, nextDueDate); - cal = Calendar.getInstance(); - this.savingsAccountHelper.closeSavingsAccountAndGetBackRequiredField(savingsId, "true", null, sdf.format(cal.getTime())); + this.savingsAccountHelper.closeSavingsAccountAndGetBackRequiredField(savingsId, "true", null, + sdf.format(Utils.getLocalDateOfTenant().toDate())); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CenterDomain.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CenterDomain.java index 20fc3719f..22fc13906 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CenterDomain.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CenterDomain.java @@ -21,7 +21,6 @@ package org.apache.fineract.integrationtests.common; import com.google.gson.Gson; import java.util.ArrayList; import java.util.HashMap; -import org.apache.fineract.infrastructure.core.service.DateUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -154,7 +153,7 @@ public class CenterDomain implements Comparable { } else { map.put("active", "false"); if (submittedDate == null) { - map.put("submittedOnDate", DateUtils.getDateOfTenant()); + map.put("submittedOnDate", Utils.getLocalDateOfTenant().toDate()); } else { map.put("submittedOnDate", submittedDate); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountIntegrationTests.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountIntegrationTests.java index 0110a4a35..bfa5fd220 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountIntegrationTests.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountIntegrationTests.java @@ -32,7 +32,6 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.charges.ChargesHelper; @@ -273,7 +272,7 @@ public class ShareAccountIntegrationTests { } else if (transactionType.equals("charge.payment")) { Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("0", String.valueOf(transaction.get("amountPaid"))); - Date transactionDate = DateUtils.getDateOfTenant(); + Date transactionDate = Utils.getLocalDateOfTenant().toDate(); Assertions.assertEquals(simple.format(transactionDate), simple.format(date)); } }