Business date - part 2 (#2384)

Business date - part 2
This commit is contained in:
Adam Saghy
2022-06-29 15:56:31 +02:00
committed by GitHub
parent 63a3f56dd1
commit 632a08a5ce
147 changed files with 1059 additions and 917 deletions
@@ -125,6 +125,7 @@ public class AccountingScenarioIntegrationTest {
Utils.initializeRESTAssured();
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
requestSpec.header("Fineract-Platform-TenantId", "default");
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
@@ -844,13 +845,13 @@ public class AccountingScenarioIntegrationTest {
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, responseSpec, loanID);
// MAKE 1
List fromDateList = (List) loanSchedule.get(1).get("fromDate");
LocalDate fromDateLocal = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
LocalDate fromDateLocal = LocalDate.now(Utils.getZoneIdOfTenant());
fromDateLocal = fromDateLocal.withYear((int) fromDateList.get(0));
fromDateLocal = fromDateLocal.withMonth((int) fromDateList.get(1));
fromDateLocal = fromDateLocal.withDayOfMonth((int) fromDateList.get(2));
List dueDateList = (List) loanSchedule.get(1).get("dueDate");
LocalDate dueDateLocal = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
LocalDate dueDateLocal = LocalDate.now(Utils.getZoneIdOfTenant());
dueDateLocal = dueDateLocal.withYear((int) dueDateList.get(0));
dueDateLocal = dueDateLocal.withMonth((int) dueDateList.get(1));
dueDateLocal = dueDateLocal.withDayOfMonth((int) dueDateList.get(2));
@@ -957,13 +958,13 @@ public class AccountingScenarioIntegrationTest {
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, responseSpec, loanID);
// MAKE 1
List fromDateList = (List) loanSchedule.get(1).get("fromDate");
LocalDate fromDateLocal = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
LocalDate fromDateLocal = LocalDate.now(Utils.getZoneIdOfTenant());
fromDateLocal = fromDateLocal.withYear((int) fromDateList.get(0));
fromDateLocal = fromDateLocal.withMonth((int) fromDateList.get(1));
fromDateLocal = fromDateLocal.withDayOfMonth((int) fromDateList.get(2));
List dueDateList = (List) loanSchedule.get(1).get("dueDate");
LocalDate dueDateLocal = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
LocalDate dueDateLocal = LocalDate.now(Utils.getZoneIdOfTenant());
dueDateLocal = dueDateLocal.withYear((int) dueDateList.get(0));
dueDateLocal = dueDateLocal.withMonth((int) dueDateList.get(1));
dueDateLocal = dueDateLocal.withDayOfMonth((int) dueDateList.get(2));
@@ -42,7 +42,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
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.CollateralManagementHelper;
import org.apache.fineract.integrationtests.common.SchedulerJobHelper;
@@ -99,6 +98,7 @@ public class ClientLoanIntegrationTest {
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec);
@@ -4854,8 +4854,7 @@ public class ClientLoanIntegrationTest {
// FINERACT-885: As loan may not have started exactly four months ago,
// make final payment today and not four months from start (as that may be in the future)
fourMonthsfromNowCalendar
.setTime(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
fourMonthsfromNowCalendar.setTime(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant()));
final String now = Utils.convertDateToURLFormat(fourMonthsfromNowCalendar);
this.loanTransactionHelper.makeRefundByCash(now, Float.parseFloat("20"), loanID);
@@ -5035,8 +5034,7 @@ public class ClientLoanIntegrationTest {
// FINERACT-885: As loan may not have started exactly four months ago,
// make final payment today and not four months from start (as that may be in the future)
fourMonthsfromNowCalendar
.setTime(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
fourMonthsfromNowCalendar.setTime(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant()));
final String now = Utils.convertDateToURLFormat(fourMonthsfromNowCalendar);
this.loanTransactionHelper.makeRefundByCash(now, Float.parseFloat("20"), loanID);
@@ -5239,8 +5237,7 @@ public class ClientLoanIntegrationTest {
// FINERACT-885: As loan may not have started exactly four months ago,
// make final payment today and not four months from start (as that may be in the future)
fourMonthsfromNowCalendar
.setTime(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
fourMonthsfromNowCalendar.setTime(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant()));
final String now = Utils.convertDateToURLFormat(fourMonthsfromNowCalendar);
final String FROM_LOAN_ACCOUNT_TYPE = "1";
@@ -39,7 +39,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.GlobalConfigurationHelper;
@@ -82,6 +81,7 @@ public class ClientSavingsIntegrationTest {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@@ -1920,7 +1920,7 @@ public class ClientSavingsIntegrationTest {
savingsList.add(savingsId);
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd MMMM yyyy");
LocalDate transactionDate = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
LocalDate transactionDate = LocalDate.now(Utils.getZoneIdOfTenant());
for (int i = 0; i < 4; i++) {
String transactionDateValue = formatter.format(transactionDate);
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsList.get(i), DEPOSIT_AMOUNT,
@@ -1953,7 +1953,7 @@ public class ClientSavingsIntegrationTest {
balance -= chargeAmt;
assertEquals(balance, summary.get("accountBalance"), "Verifying account Balance");
String transactionDateValue = formatter.format(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()));
String transactionDateValue = formatter.format(LocalDate.now(Utils.getZoneIdOfTenant()));
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsList.get(1), DEPOSIT_AMOUNT,
transactionDateValue, CommonConstants.RESPONSE_RESOURCE_ID);
savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(1));
@@ -1972,7 +1972,7 @@ public class ClientSavingsIntegrationTest {
balance -= chargeAmt;
assertEquals(balance, summary.get("accountBalance"), "Verifying account Balance");
transactionDateValue = formatter.format(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()));
transactionDateValue = formatter.format(LocalDate.now(Utils.getZoneIdOfTenant()));
depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsList.get(2), DEPOSIT_AMOUNT,
transactionDateValue, CommonConstants.RESPONSE_RESOURCE_ID);
savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsList.get(2));
@@ -2225,7 +2225,7 @@ public class ClientSavingsIntegrationTest {
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
Integer releaseTransactionId = this.savingsAccountHelper.releaseAmount(savingsId, holdTransactionId);
Date today = Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
Date today = Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant());
String todayDate = today.toString();
SimpleDateFormat dt1 = new SimpleDateFormat("dd MMM yyyy");
todayDate = dt1.format(today).toString();
@@ -25,13 +25,9 @@ import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.ContentType;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
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.Utils;
@@ -55,6 +51,7 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
@@ -124,9 +121,8 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
ClientStatusChecker.verifyClientPending(status);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
Date todaysDate = Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
final String undoRejectDate = dateFormat.format(todaysDate);
LocalDate todaysDate = Utils.getLocalDateOfTenant();
final String undoRejectDate = todaysDate.format(Utils.dateFormatter);
ArrayList<HashMap<String, Object>> clientErrorData = validationErrorHelper.undoRejectedclient(clientId,
CommonConstants.RESPONSE_ERROR, undoRejectDate);
@@ -156,11 +152,9 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
status = this.clientHelper.rejectClient(clientId);
ClientStatusChecker.verifyClientRejected(status);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
Date tomorrowsDate = Date
.from(Utils.getLocalDateOfTenant().plusDays(1).atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
final String undoRejectDate = dateFormat.format(tomorrowsDate);
ArrayList<HashMap<String, Object>> clientErrorData = validationErrorHelper.undoWithdrawclient(clientId,
LocalDate tomorrowsDate = Utils.getLocalDateOfTenant().plusDays(1);
final String undoRejectDate = tomorrowsDate.format(Utils.dateFormatter);
ArrayList<HashMap<String, Object>> clientErrorData = validationErrorHelper.undoRejectedclient(clientId,
CommonConstants.RESPONSE_ERROR, undoRejectDate);
assertEquals("validation.msg.client.reopenedDate.is.greater.than.date",
clientErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
@@ -233,9 +227,8 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
// GET CLIENT STATUS
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
Date todaysDate = Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
final String undoWithdrawDate = dateFormat.format(todaysDate);
LocalDate todaysDate = Utils.getLocalDateOfTenant();
final String undoWithdrawDate = todaysDate.format(Utils.dateFormatter);
ArrayList<HashMap<String, Object>> clientErrorData = validationErrorHelper.undoWithdrawclient(clientId,
CommonConstants.RESPONSE_ERROR, undoWithdrawDate);
@@ -265,10 +258,8 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
status = this.clientHelper.withdrawClient(clientId);
ClientStatusChecker.verifyClientWithdrawn(status);
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
Date tomorrowsDate = Date
.from(Utils.getLocalDateOfTenant().plusDays(1).atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
final String undoWithdrawDate = dateFormat.format(tomorrowsDate);
LocalDate tomorrowsDate = Utils.getLocalDateOfTenant().plusDays(1);
final String undoWithdrawDate = tomorrowsDate.format(Utils.dateFormatter);
ArrayList<HashMap<String, Object>> clientErrorData = validationErrorHelper.undoWithdrawclient(clientId,
CommonConstants.RESPONSE_ERROR, undoWithdrawDate);
assertEquals("validation.msg.client.reopenedDate.is.greater.than.date",
@@ -276,7 +267,6 @@ public class ClientUndoRejectAndWithdrawalIntegrationTest {
status = this.clientHelper.undoWithdrawn(clientId);
ClientStatusChecker.verifyClientPending(status);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -39,7 +39,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
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;
@@ -1569,10 +1568,10 @@ public class FixedDepositTest {
Calendar activationDate = Calendar.getInstance();
activationDate.add(Calendar.MONTH, -1);
activationDate.add(Calendar.DAY_OF_MONTH, -1);
ZonedDateTime startDate = ZonedDateTime.ofInstant(activationDate.getTime().toInstant(), DateUtils.getDateTimeZoneOfTenant());
ZonedDateTime startDate = ZonedDateTime.ofInstant(activationDate.getTime().toInstant(), Utils.getZoneIdOfTenant());
Calendar prematureClosureDate = Calendar.getInstance();
ZonedDateTime endDate = ZonedDateTime.ofInstant(prematureClosureDate.getTime().toInstant(), DateUtils.getDateTimeZoneOfTenant());
ZonedDateTime endDate = ZonedDateTime.ofInstant(prematureClosureDate.getTime().toInstant(), Utils.getZoneIdOfTenant());
Integer depositedPeriod = Math.toIntExact(ChronoUnit.MONTHS.between(startDate.toLocalDate(), endDate.toLocalDate()));
@@ -1683,10 +1682,10 @@ public class FixedDepositTest {
Calendar activationDate = Calendar.getInstance();
activationDate.add(Calendar.MONTH, -1);
activationDate.add(Calendar.DAY_OF_MONTH, -1);
ZonedDateTime startDate = ZonedDateTime.ofInstant(activationDate.getTime().toInstant(), DateUtils.getDateTimeZoneOfTenant());
ZonedDateTime startDate = ZonedDateTime.ofInstant(activationDate.getTime().toInstant(), Utils.getZoneIdOfTenant());
Calendar prematureClosureDate = Calendar.getInstance();
ZonedDateTime endDate = ZonedDateTime.ofInstant(prematureClosureDate.getTime().toInstant(), DateUtils.getDateTimeZoneOfTenant());
ZonedDateTime endDate = ZonedDateTime.ofInstant(prematureClosureDate.getTime().toInstant(), Utils.getZoneIdOfTenant());
Integer depositedPeriod = Math.toIntExact(ChronoUnit.MONTHS.between(startDate.toLocalDate(), endDate.toLocalDate()));
@@ -31,12 +31,10 @@ import java.text.SimpleDateFormat;
import java.time.LocalDate;
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.Map;
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.GroupHelper;
@@ -74,6 +72,7 @@ public class GroupSavingsIntegrationTest {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@@ -771,7 +770,7 @@ public class GroupSavingsIntegrationTest {
assertEquals(expectedNextDueDate, nextDueDate);
this.savingsAccountHelper.closeSavingsAccountAndGetBackRequiredField(savingsId, "true", null,
sdf.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())));
Utils.getLocalDateOfTenant().format(Utils.dateFormatter));
}
@@ -52,6 +52,7 @@ public class InstanceModeIntegrationTest {
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
requestSpec.header("Fineract-Platform-TenantId", "default");
responseSpec200 = new ResponseSpecBuilder().expectStatusCode(200).build();
responseSpec405 = new ResponseSpecBuilder().expectStatusCode(405).build();
@@ -73,6 +73,7 @@ public class LoanReschedulingWithinCenterTest {
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.loanApplicationApprovalTest = new LoanApplicationApprovalTest();
this.generalResponseSpec = new ResponseSpecBuilder().build();
@@ -36,7 +36,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
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;
@@ -1920,10 +1919,10 @@ public class RecurringDepositTest {
Calendar activationDate = Calendar.getInstance();
activationDate.add(Calendar.MONTH, -1);
activationDate.add(Calendar.DAY_OF_MONTH, -1);
ZonedDateTime start = ZonedDateTime.ofInstant(activationDate.getTime().toInstant(), DateUtils.getDateTimeZoneOfTenant());
ZonedDateTime start = ZonedDateTime.ofInstant(activationDate.getTime().toInstant(), Utils.getZoneIdOfTenant());
Calendar prematureClosureDate = Calendar.getInstance();
ZonedDateTime end = ZonedDateTime.ofInstant(prematureClosureDate.getTime().toInstant(), DateUtils.getDateTimeZoneOfTenant());
ZonedDateTime end = ZonedDateTime.ofInstant(prematureClosureDate.getTime().toInstant(), Utils.getZoneIdOfTenant());
Integer depositedPeriod = Math.toIntExact(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate()));
@@ -2061,10 +2060,10 @@ public class RecurringDepositTest {
Calendar activationDate = Calendar.getInstance();
activationDate.add(Calendar.MONTH, -1);
activationDate.add(Calendar.DAY_OF_MONTH, -1);
ZonedDateTime start = ZonedDateTime.ofInstant(activationDate.getTime().toInstant(), DateUtils.getDateTimeZoneOfTenant());
ZonedDateTime start = ZonedDateTime.ofInstant(activationDate.getTime().toInstant(), Utils.getZoneIdOfTenant());
Calendar prematureClosureDate = Calendar.getInstance();
ZonedDateTime end = ZonedDateTime.ofInstant(prematureClosureDate.getTime().toInstant(), DateUtils.getDateTimeZoneOfTenant());
ZonedDateTime end = ZonedDateTime.ofInstant(prematureClosureDate.getTime().toInstant(), Utils.getZoneIdOfTenant());
Integer depositedPeriod = Math.toIntExact(ChronoUnit.MONTHS.between(start.toLocalDate(), end.toLocalDate()));
@@ -142,5 +142,6 @@ public class SchedulerJobsTest {
for (String jobName : schedulerJobHelper.getAllSchedulerJobNames()) {
schedulerJobHelper.executeAndAwaitJob(jobName);
}
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
}
}
@@ -22,7 +22,6 @@ import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -155,8 +154,7 @@ public class CenterDomain implements Comparable<CenterDomain> {
} else {
map.put("active", "false");
if (submittedDate == null) {
map.put("submittedOnDate",
Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
map.put("submittedOnDate", Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant()));
} else {
map.put("submittedOnDate", submittedDate);
}
@@ -61,16 +61,9 @@ public class ClientHelper {
private static final String UNDOREJECT_CLIENT_COMMAND = "undoRejection";
private static final String UNDOWITHDRAWN_CLIENT_COMMAND = "undoWithdrawal";
private static final Integer LEGALFORM_ID_PERSON = 1;
public static final String CREATED_DATE = "27 November 2014";
public static final String CREATED_DATE_PLUS_ONE = "28 November 2014";
public static final String CREATED_DATE_PLUS_TWO = "29 November 2014";
public static final String CREATED_DATE_MINUS_ONE = "27 November 2014";
public static final String TRANSACTION_DATE = "01 March 2013";
public static final String LAST_TRANSACTION_DATE = "01 March 2013";
public static final String DATE_FORMAT = "dd MMMM yyyy";
public static final String DATE_TIME_FORMAT = "dd MMMM yyyy HH:mm";
public static final String CREATED_DATE = Utils.getLocalDateOfTenant().minusDays(5).format(Utils.dateFormatter);
public static final String CREATED_DATE_PLUS_ONE = Utils.getLocalDateOfTenant().minusDays(4).format(Utils.dateFormatter);
public static final String CREATED_DATE_PLUS_TWO = Utils.getLocalDateOfTenant().minusDays(3).format(Utils.dateFormatter);
private static final Gson GSON = new JSON().getGson();
@@ -210,7 +203,7 @@ public class ClientHelper {
map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5));
map.put("lastname", Utils.randomNameGenerator("Client_LastName_", 4));
map.put("externalId", randomIDGenerator("ID_", 7));
map.put("dateFormat", DATE_FORMAT);
map.put("dateFormat", Utils.DATE_FORMAT);
map.put("locale", "en");
map.put("active", "true");
map.put("activationDate", dateOfJoining);
@@ -225,7 +218,7 @@ public class ClientHelper {
map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5));
map.put("lastname", Utils.randomNameGenerator("Client_LastName_", 4));
map.put("externalId", randomIDGenerator("ID_", 7));
map.put("dateFormat", DATE_FORMAT);
map.put("dateFormat", Utils.DATE_FORMAT);
map.put("locale", "en");
map.put("active", "false");
map.put("submittedOnDate", submittedOnDate);
@@ -240,7 +233,7 @@ public class ClientHelper {
map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5));
map.put("lastname", Utils.randomNameGenerator("Client_LastName_", 4));
map.put("externalId", randomIDGenerator("ID_", 7));
map.put("dateFormat", DATE_FORMAT);
map.put("dateFormat", Utils.DATE_FORMAT);
map.put("locale", "en");
map.put("active", "false");
map.put("submittedOnDate", "04 March 2014");
@@ -257,7 +250,7 @@ public class ClientHelper {
dataMap.put("Spouse Name", Utils.randomNameGenerator("Spouse_name", 4));
dataMap.put("Number of Dependents", 5);
dataMap.put("Time of Visit", "01 December 2016 04:03");
dataMap.put("dateFormat", DATE_TIME_FORMAT);
dataMap.put("dateFormat", Utils.DATE_TIME_FORMAT);
dataMap.put("Date of Approval", "02 December 2016 00:00");
datatableMap.put("registeredTableName", registeredTableName);
datatableMap.put("data", dataMap);
@@ -271,7 +264,7 @@ public class ClientHelper {
map.put("officeId", officeId);
map.put("fullname", Utils.randomNameGenerator("Client_FullName_", 5));
map.put("externalId", randomIDGenerator("ID_", 7));
map.put("dateFormat", DATE_FORMAT);
map.put("dateFormat", Utils.DATE_FORMAT);
map.put("locale", "en");
map.put("active", "true");
map.put("activationDate", dateOfJoining);
@@ -287,7 +280,7 @@ public class ClientHelper {
map.put("officeId", officeId);
map.put("fullname", Utils.randomNameGenerator("Client_FullName_", 5));
map.put("externalId", randomIDGenerator("ID_", 7));
map.put("dateFormat", DATE_FORMAT);
map.put("dateFormat", Utils.DATE_FORMAT);
map.put("locale", "en");
map.put("active", "true");
map.put("activationDate", dateOfJoining);
@@ -308,7 +301,7 @@ public class ClientHelper {
map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5));
map.put("lastname", Utils.randomNameGenerator("Client_LastName_", 4));
map.put("externalId", randomIDGenerator("ID_", 7));
map.put("dateFormat", DATE_FORMAT);
map.put("dateFormat", Utils.DATE_FORMAT);
map.put("locale", "en");
map.put("active", "true");
map.put("activationDate", dateOfJoining);
@@ -477,7 +470,7 @@ public class ClientHelper {
public static String getSpecifiedDueDateChargesClientAsJSON(final String chargeId, final String dueDate) {
final HashMap<String, String> map = new HashMap<>();
map.put("locale", "en_GB");
map.put("dateFormat", DATE_FORMAT);
map.put("dateFormat", Utils.DATE_FORMAT);
map.put("dueDate", dueDate);
map.put("chargeId", chargeId);
map.put("amount", "200");
@@ -488,7 +481,7 @@ public class ClientHelper {
public static String getPayChargeJSON(final String date, String amount) {
final HashMap<String, String> map = new HashMap<>();
map.put("locale", "en_GB");
map.put("dateFormat", DATE_FORMAT);
map.put("dateFormat", Utils.DATE_FORMAT);
map.put("transactionDate", date);
map.put("amount", amount);
String json = GSON.toJson(map);
@@ -674,6 +667,7 @@ public class ClientHelper {
public static PostClientsRequest defaultClientCreationRequest() {
return new PostClientsRequest().officeId(1).legalFormId(LEGALFORM_ID_PERSON)
.firstname(Utils.randomNameGenerator("Client_FirstName_", 5)).lastname(Utils.randomNameGenerator("Client_LastName_", 5))
.externalId(randomIDGenerator("ID_", 7)).dateFormat(DATE_FORMAT).locale("en").active(true).activationDate("04 March 2011");
.externalId(randomIDGenerator("ID_", 7)).dateFormat(Utils.DATE_FORMAT).locale("en").active(true)
.activationDate("04 March 2011");
}
}
@@ -444,7 +444,7 @@ public class GlobalConfigurationHelper {
isBusinessDateEnabled.put("id", 44);
isBusinessDateEnabled.put("name", "enable_business_date");
isBusinessDateEnabled.put("value", 0);
isBusinessDateEnabled.put("enabled", true);
isBusinessDateEnabled.put("enabled", false);
isBusinessDateEnabled.put("trapDoor", false);
defaults.add(isBusinessDateEnabled);
@@ -35,7 +35,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.integrationtests.common.accounting.Account;
import org.apache.fineract.integrationtests.common.accounting.AccountHelper;
import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
@@ -69,6 +68,7 @@ public class ProvisioningIntegrationTest {
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
Assumptions.assumeTrue(!isAlreadyProvisioningEntriesCreated());
@@ -261,7 +261,7 @@ public class ProvisioningIntegrationTest {
Date date1 = formatter.parse(date);
DateFormat simple = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
String formattedString = simple
.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant()));
Date currentDate = simple.parse(formattedString);
if (date1.getTime() == currentDate.getTime()) {
provisioningetryAlreadyCreated = true;
@@ -40,6 +40,8 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@@ -48,7 +50,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.http.conn.HttpHostConnectException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -77,6 +78,11 @@ public final class Utils {
private static final String HEALTH_URL = "/fineract-provider/actuator/health";
private static final String LOGIN_URL = "/fineract-provider/api/v1/authentication?" + TENANT_IDENTIFIER;
public static final String DATE_FORMAT = "dd MMMM yyyy";
public static final String DATE_TIME_FORMAT = "dd MMMM yyyy HH:mm";
public static final DateTimeFormatter dateFormatter = new DateTimeFormatterBuilder().appendPattern(DATE_FORMAT).toFormatter();
public static final DateTimeFormatter dateTimeFormatter = new DateTimeFormatterBuilder().appendPattern(DATE_TIME_FORMAT).toFormatter();
public static void initializeRESTAssured() {
RestAssured.baseURI = "https://localhost";
RestAssured.port = 8443;
@@ -287,19 +293,18 @@ public final class Utils {
return dateFormat.format(dateToBeConvert.getTime());
}
public static LocalDate getLocalDateOfTenant() {
LocalDate today = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
final ZoneId zone = ZoneId.of(TENANT_TIME_ZONE);
if (zone != null) {
today = LocalDate.now(zone);
}
return today;
}
public static TimeZone getTimeZoneOfTenant() {
return TimeZone.getTimeZone(TENANT_TIME_ZONE);
}
public static ZoneId getZoneIdOfTenant() {
return ZoneId.of(TENANT_TIME_ZONE);
}
public static LocalDate getLocalDateOfTenant() {
return LocalDate.now(getZoneIdOfTenant());
}
public static Date convertJsonElementAsDate(JsonElement jsonElement) {
if (jsonElement.isJsonArray()) {
JsonArray jsonArray = jsonElement.getAsJsonArray();
@@ -29,7 +29,6 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.report.ReportData;
import org.slf4j.Logger;
@@ -110,7 +109,7 @@ public class CampaignsHelper {
map.put("triggerType", triggerType);
if (2 == triggerType) {
map.put("recurrenceStartDate",
LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT)));
LocalDateTime.now(Utils.getZoneIdOfTenant()).format(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT)));
map.put("frequency", 1);
map.put("interval", "1");
}
@@ -138,7 +137,7 @@ public class CampaignsHelper {
map.put("triggerType", triggerType);
if (2 == triggerType) {
map.put("recurrenceStartDate",
LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()).format(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT)));
LocalDateTime.now(Utils.getZoneIdOfTenant()).format(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT)));
}
map.put("campaignName", Utils.randomNameGenerator("Campaign_Name_", 5));
map.put("campaignType", 1);
@@ -86,6 +86,7 @@ public class CampaignsTest {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.campaignsHelper = new CampaignsHelper(this.requestSpec, this.responseSpec);
}
@@ -28,7 +28,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.accounting.Account;
@@ -48,8 +47,7 @@ public final class ProvisioningHelper {
map.put("loanProducts", addLoanProducts(loanProducts));
map.put("definitions", addProvisioningCategories(categories, liability, expense));
DateFormat simple = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
String formattedString = simple
.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
String formattedString = simple.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant()));
String criteriaName = "General Provisioning Criteria" + formattedString + rand.nextLong();
map.put("criteriaName", criteriaName);
@@ -63,8 +61,7 @@ public final class ProvisioningHelper {
map.put("locale", "en");
map.put("dateFormat", "dd MMMM yyyy");
DateFormat simple = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
map.put("date",
simple.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())));
map.put("date", simple.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant())));
String provisioningEntryCreateJson = new Gson().toJson(map);
return provisioningEntryCreateJson;
}
@@ -75,8 +72,7 @@ public final class ProvisioningHelper {
map.put("locale", "en");
map.put("dateFormat", "dd MMMM yyyy");
DateFormat simple = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
map.put("date",
simple.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())));
map.put("date", simple.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant())));
String provisioningEntryCreateJson = new Gson().toJson(map);
return provisioningEntryCreateJson;
}
@@ -26,13 +26,13 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Calendar;
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;
@@ -55,6 +55,7 @@ public class ShareAccountIntegrationTests {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@@ -115,7 +116,7 @@ public class ShareAccountIntegrationTests {
Map<String, Object> shareAccountDataForUpdate = new HashMap<>();
shareAccountDataForUpdate.put("requestedShares", 30);
shareAccountDataForUpdate.put("applicationDate", "02 Mar 2016");
shareAccountDataForUpdate.put("applicationDate", "02 March 2016");
shareAccountDataForUpdate.put("dateFormat", "dd MMMM yyyy");
shareAccountDataForUpdate.put("locale", "en_GB");
String updateShareAccountJsonString = new Gson().toJson(shareAccountDataForUpdate);
@@ -132,14 +133,13 @@ public class ShareAccountIntegrationTests {
Calendar cal = Calendar.getInstance();
cal.set(dateList.get(0), dateList.get(1) - 1, dateList.get(2));
Date date = cal.getTime();
DateFormat simple = new SimpleDateFormat("dd MMM yyyy");
Assertions.assertEquals("02 Mar 2016", simple.format(date));
DateFormat simple = new SimpleDateFormat("dd MMMM yyyy");
Assertions.assertEquals("02 March 2016", simple.format(date));
}
@Test
@SuppressWarnings("unchecked")
public void testShareAccountApproval() {
DateFormat simple = new SimpleDateFormat("dd MMM yyyy");
shareProductHelper = new ShareProductHelper();
final Integer productId = createShareProduct();
Assertions.assertNotNull(productId);
@@ -167,7 +167,7 @@ public class ShareAccountIntegrationTests {
Map<String, Object> approveMap = new HashMap<>();
approveMap.put("note", "Share Account Approval Note");
approveMap.put("dateFormat", "dd MMMM yyyy");
approveMap.put("approvedDate", "01 Jan 2016");
approveMap.put("approvedDate", "01 January 2016");
approveMap.put("locale", "en");
String approve = new Gson().toJson(approveMap);
ShareAccountTransactionHelper.postCommand("approve", shareAccountId, approve, requestSpec, responseSpec);
@@ -176,10 +176,8 @@ public class ShareAccountIntegrationTests {
Assertions.assertEquals("shareAccountStatusType.approved", String.valueOf(statusMap.get("code")));
Map<String, Object> timelineMap = (Map<String, Object>) shareAccountData.get("timeline");
List<Integer> dateList = (List<Integer>) timelineMap.get("approvedDate");
Calendar cal = Calendar.getInstance();
cal.set(dateList.get(0), dateList.get(1) - 1, dateList.get(2));
Date approvedDate = cal.getTime();
Assertions.assertEquals("01 Jan 2016", simple.format(approvedDate));
LocalDate approvedDate = LocalDate.of(dateList.get(0), dateList.get(1), dateList.get(2));
Assertions.assertEquals("01 January 2016", approvedDate.format(Utils.dateFormatter));
List<Map<String, Object>> transactions = (List<Map<String, Object>>) shareAccountData.get("purchasedShares");
Assertions.assertNotNull(transactions);
Assertions.assertEquals(2, transactions.size());
@@ -187,9 +185,7 @@ public class ShareAccountIntegrationTests {
Map<String, Object> transaction = transactions.get(i);
Map<String, Object> transactionTypeMap = (Map<String, Object>) transaction.get("type");
dateList = (List<Integer>) transaction.get("purchasedDate");
cal = Calendar.getInstance();
cal.set(dateList.get(0), dateList.get(1) - 1, dateList.get(2));
Date date = cal.getTime();
LocalDate transactionDate = LocalDate.of(dateList.get(0), dateList.get(1), dateList.get(2));
String transactionType = (String) transactionTypeMap.get("code");
if (transactionType.equals("purchasedSharesType.purchased")) {
Assertions.assertEquals("25", String.valueOf(transaction.get("numberOfShares")));
@@ -197,14 +193,11 @@ public class ShareAccountIntegrationTests {
Assertions.assertEquals("52.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice")));
Assertions.assertEquals("01 Jan 2016", simple.format(date));
Assertions.assertEquals("01 January 2016", transactionDate.format(Utils.dateFormatter));
} else if (transactionType.equals("charge.payment")) {
Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals(
simple.format(
Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())),
simple.format(date));
Assertions.assertEquals(Utils.getLocalDateOfTenant(), transactionDate);
}
}
@@ -245,13 +238,12 @@ public class ShareAccountIntegrationTests {
String rejectJson = new Gson().toJson(rejectMap);
ShareAccountTransactionHelper.postCommand("reject", shareAccountId, rejectJson, requestSpec, responseSpec);
shareAccountData = ShareAccountTransactionHelper.retrieveShareAccount(shareAccountId, requestSpec, responseSpec);
DateFormat simple = new SimpleDateFormat("dd MMM yyyy");
Map<String, Object> statusMap = (Map<String, Object>) shareAccountData.get("status");
Assertions.assertEquals("shareAccountStatusType.rejected", String.valueOf(statusMap.get("code")));
Map<String, Object> timelineMap = (Map<String, Object>) shareAccountData.get("timeline");
List<Integer> dateList = (List<Integer>) timelineMap.get("rejectedDate");
Date rejectedDate = DateUtils.createDate(dateList.get(0), dateList.get(1), dateList.get(2));
Assertions.assertEquals(simple.format(DateUtils.convertLocalDateToDate(Utils.getLocalDateOfTenant())), simple.format(rejectedDate));
LocalDate rejectedDate = LocalDate.of(dateList.get(0), dateList.get(1), dateList.get(2));
Assertions.assertEquals(Utils.getLocalDateOfTenant(), rejectedDate);
List<Map<String, Object>> transactions = (List<Map<String, Object>>) shareAccountData.get("purchasedShares");
Assertions.assertNotNull(transactions);
@@ -260,7 +252,7 @@ public class ShareAccountIntegrationTests {
Map<String, Object> transaction = transactions.get(i);
Map<String, Object> transactionTypeMap = (Map<String, Object>) transaction.get("type");
dateList = (List<Integer>) transaction.get("purchasedDate");
Date date = DateUtils.createDate(dateList.get(0), dateList.get(1), dateList.get(2));
LocalDate date = LocalDate.of(dateList.get(0), dateList.get(1), dateList.get(2));
String transactionType = (String) transactionTypeMap.get("code");
if (transactionType.equals("purchasedSharesType.purchased")) {
Assertions.assertEquals("25", String.valueOf(transaction.get("numberOfShares")));
@@ -268,13 +260,12 @@ public class ShareAccountIntegrationTests {
Assertions.assertEquals("50.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice")));
Assertions.assertEquals("01 Jan 2016", simple.format(date));
Assertions.assertEquals("01 January 2016", date.format(Utils.dateFormatter));
} 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 = Date
.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
Assertions.assertEquals(simple.format(transactionDate), simple.format(date));
LocalDate transactionDate = Utils.getLocalDateOfTenant();
Assertions.assertEquals(transactionDate, date);
}
}
@@ -286,7 +277,6 @@ public class ShareAccountIntegrationTests {
@Test
@SuppressWarnings("unchecked")
public void testShareAccountUndoApproval() {
DateFormat simple = new SimpleDateFormat("dd MMM yyyy");
shareProductHelper = new ShareProductHelper();
final Integer productId = createShareProduct();
Assertions.assertNotNull(productId);
@@ -314,7 +304,7 @@ public class ShareAccountIntegrationTests {
Map<String, Object> approveMap = new HashMap<>();
approveMap.put("note", "Share Account Approval Note");
approveMap.put("dateFormat", "dd MMMM yyyy");
approveMap.put("approvedDate", "01 Jan 2016");
approveMap.put("approvedDate", "01 January 2016");
approveMap.put("locale", "en");
String approve = new Gson().toJson(approveMap);
ShareAccountTransactionHelper.postCommand("approve", shareAccountId, approve, requestSpec, responseSpec);
@@ -323,10 +313,9 @@ public class ShareAccountIntegrationTests {
Assertions.assertEquals("shareAccountStatusType.approved", String.valueOf(statusMap.get("code")));
Map<String, Object> timelineMap = (Map<String, Object>) shareAccountData.get("timeline");
List<Integer> dateList = (List<Integer>) timelineMap.get("approvedDate");
Calendar cal = Calendar.getInstance();
cal.set(dateList.get(0), dateList.get(1) - 1, dateList.get(2));
Date approvedDate = cal.getTime();
Assertions.assertEquals("01 Jan 2016", simple.format(approvedDate));
LocalDate approvedDate = LocalDate.of(dateList.get(0), dateList.get(1), dateList.get(2));
Assertions.assertEquals("01 January 2016", approvedDate.format(Utils.dateFormatter));
// Undo Approval share Account
Map<String, Object> undoApprovalMap = new HashMap<>();
@@ -345,9 +334,7 @@ public class ShareAccountIntegrationTests {
Map<String, Object> transaction = transactions.get(i);
Map<String, Object> transactionTypeMap = (Map<String, Object>) transaction.get("type");
dateList = (List<Integer>) transaction.get("purchasedDate");
cal = Calendar.getInstance();
cal.set(dateList.get(0), dateList.get(1) - 1, dateList.get(2));
Date date = cal.getTime();
LocalDate transactionDate = LocalDate.of(dateList.get(0), dateList.get(1), dateList.get(2));
String transactionType = (String) transactionTypeMap.get("code");
if (transactionType.equals("purchasedSharesType.purchased")) {
Assertions.assertEquals("25", String.valueOf(transaction.get("numberOfShares")));
@@ -355,14 +342,11 @@ public class ShareAccountIntegrationTests {
Assertions.assertEquals("0.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice")));
Assertions.assertEquals("01 Jan 2016", simple.format(date));
Assertions.assertEquals("01 January 2016", transactionDate.format(Utils.dateFormatter));
} else if (transactionType.equals("charge.payment")) {
Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals(
simple.format(
Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())),
simple.format(date));
Assertions.assertEquals(Utils.getLocalDateOfTenant(), transactionDate);
}
}
@@ -27,7 +27,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.integrationtests.common.Utils;
import org.junit.jupiter.api.Assertions;
import org.slf4j.Logger;
@@ -106,7 +105,7 @@ public class ShareProductHelper {
public ShareProductHelper withMarketPrice() {
this.marketPrices = new ArrayList<>();
LocalDate currentDate = DateUtils.getLocalDateOfTenant();
LocalDate currentDate = Utils.getLocalDateOfTenant();
String[] prices = { "3.0", "4.0", "5.0", "6.0", "7.0" };
DateFormat simple = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
for (int i = 0; i < prices.length; i++) {
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<configuration scan="false">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>false</resetJUL>
</contextListener>
<appender name="STDOUT" target="System.out" class="ch.qos.logback.core.ConsoleAppender">
<withJansi>true</withJansi>
<encoder>
<pattern>%green(%d{yyyy-MM-dd HH:mm:ss.SSS}) [%thread] %highlight(%-5level) %cyan(%logger{36}) - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.springframework.transaction" level="INFO" />
<logger name="org.springframework.data.convert" level="ERROR" />
<logger name="org.springframework.http.converter.json" level="ERROR" />
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>