FINERACT-1996: Reporting should support query that includes json path for DB field in Postgres
This commit is contained in:
+13
-35
@@ -23,6 +23,7 @@ import static org.apache.fineract.infrastructure.core.domain.AuditableFieldsCons
|
||||
import static org.apache.fineract.infrastructure.core.domain.AuditableFieldsConstants.LAST_MODIFIED_BY;
|
||||
import static org.apache.fineract.infrastructure.core.domain.AuditableFieldsConstants.LAST_MODIFIED_DATE;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import io.restassured.builder.RequestSpecBuilder;
|
||||
import io.restassured.builder.ResponseSpecBuilder;
|
||||
@@ -30,9 +31,10 @@ import io.restassured.http.ContentType;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import io.restassured.specification.ResponseSpecification;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
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.organisation.StaffHelper;
|
||||
@@ -65,12 +67,7 @@ public class ClientAuditingIntegrationTest {
|
||||
String username = Utils.uniqueRandomStringGenerator("user", 8);
|
||||
final Integer userId = (Integer) UserHelper.createUser(this.requestSpec, this.responseSpec, 1, staffId, username, "password",
|
||||
"resourceId");
|
||||
OffsetDateTime now = OffsetDateTime.now(ZoneId.of("Asia/Kolkata"));
|
||||
// Testing in minutes precision, but still need to take care around the end of the actual minute
|
||||
if (now.getSecond() > 56) {
|
||||
Thread.sleep(5000);
|
||||
now = OffsetDateTime.now(ZoneId.of("Asia/Kolkata"));
|
||||
}
|
||||
OffsetDateTime now = Utils.getAuditDateTimeToCompare();
|
||||
LOG.info("-------------------------Creating Client---------------------------");
|
||||
|
||||
final Integer clientID = ClientHelper.createClientPending(requestSpec, responseSpec);
|
||||
@@ -79,55 +76,36 @@ public class ClientAuditingIntegrationTest {
|
||||
|
||||
OffsetDateTime createdDate = OffsetDateTime.parse((String) auditFieldsResponse.get(CREATED_DATE),
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
|
||||
OffsetDateTime lastModifiedDate = OffsetDateTime.parse((String) auditFieldsResponse.get(LAST_MODIFIED_DATE),
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
|
||||
LOG.info("-------------------------Check Audit dates---------------------------");
|
||||
assertEquals(1, auditFieldsResponse.get(CREATED_BY));
|
||||
assertEquals(1, auditFieldsResponse.get(LAST_MODIFIED_BY));
|
||||
assertEquals(now.getYear(), createdDate.getYear());
|
||||
assertEquals(now.getMonth(), createdDate.getMonth());
|
||||
assertEquals(now.getDayOfMonth(), createdDate.getDayOfMonth());
|
||||
assertEquals(now.getHour(), createdDate.getHour());
|
||||
assertEquals(now.getMinute(), createdDate.getMinute());
|
||||
|
||||
assertEquals(now.getYear(), lastModifiedDate.getYear());
|
||||
assertEquals(now.getMonth(), lastModifiedDate.getMonth());
|
||||
assertEquals(now.getDayOfMonth(), lastModifiedDate.getDayOfMonth());
|
||||
assertEquals(now.getHour(), lastModifiedDate.getHour());
|
||||
assertEquals(now.getMinute(), lastModifiedDate.getMinute());
|
||||
assertTrue(DateUtils.isEqual(now, createdDate, ChronoUnit.MINUTES));
|
||||
assertTrue(DateUtils.isEqual(now, lastModifiedDate, ChronoUnit.MINUTES));
|
||||
|
||||
LOG.info("-------------------------Modify Client with System user---------------------------");
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization",
|
||||
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey(username, "password"));
|
||||
|
||||
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
OffsetDateTime now2 = Utils.getAuditDateTimeToCompare();
|
||||
this.clientHelper.activateClient(clientID);
|
||||
auditFieldsResponse = ClientHelper.getClientAuditFields(requestSpec, responseSpec, clientID, "");
|
||||
|
||||
createdDate = OffsetDateTime.parse((String) auditFieldsResponse.get(CREATED_DATE), DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
|
||||
OffsetDateTime createdDate2 = OffsetDateTime.parse((String) auditFieldsResponse.get(CREATED_DATE),
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
lastModifiedDate = OffsetDateTime.parse((String) auditFieldsResponse.get(LAST_MODIFIED_DATE),
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
|
||||
LOG.info("-------------------------Check Audit dates---------------------------");
|
||||
assertEquals(1, auditFieldsResponse.get(CREATED_BY));
|
||||
assertEquals(now.getYear(), createdDate.getYear());
|
||||
assertEquals(now.getMonth(), createdDate.getMonth());
|
||||
assertEquals(now.getDayOfMonth(), createdDate.getDayOfMonth());
|
||||
assertEquals(now.getHour(), createdDate.getHour());
|
||||
assertEquals(now.getMinute(), createdDate.getMinute());
|
||||
|
||||
now = OffsetDateTime.now(ZoneId.of("Asia/Kolkata"));
|
||||
assertTrue(DateUtils.isEqual(now, createdDate2, ChronoUnit.MINUTES));
|
||||
assertTrue(DateUtils.isEqual(createdDate, createdDate2));
|
||||
|
||||
assertEquals(userId, auditFieldsResponse.get(LAST_MODIFIED_BY));
|
||||
assertEquals(now.getYear(), lastModifiedDate.getYear());
|
||||
assertEquals(now.getMonth(), lastModifiedDate.getMonth());
|
||||
assertEquals(now.getDayOfMonth(), lastModifiedDate.getDayOfMonth());
|
||||
assertEquals(now.getHour(), lastModifiedDate.getHour());
|
||||
assertEquals(now.getMinute(), lastModifiedDate.getMinute());
|
||||
assertTrue(DateUtils.isEqual(now2, lastModifiedDate, ChronoUnit.MINUTES));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+14
-34
@@ -23,6 +23,7 @@ import static org.apache.fineract.infrastructure.core.domain.AuditableFieldsCons
|
||||
import static org.apache.fineract.infrastructure.core.domain.AuditableFieldsConstants.LAST_MODIFIED_BY;
|
||||
import static org.apache.fineract.infrastructure.core.domain.AuditableFieldsConstants.LAST_MODIFIED_DATE;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import io.restassured.builder.RequestSpecBuilder;
|
||||
import io.restassured.builder.ResponseSpecBuilder;
|
||||
@@ -30,12 +31,13 @@ import io.restassured.http.ContentType;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import io.restassured.specification.ResponseSpecification;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Collections;
|
||||
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.accounting.Account;
|
||||
@@ -93,12 +95,8 @@ public class LoanAuditingIntegrationTest {
|
||||
|
||||
final Integer loanProductID = createLoanProduct("0", "0", LoanProductTestBuilder.DEFAULT_STRATEGY, "2", assetAccount, incomeAccount,
|
||||
expenseAccount, overpaymentAccount);
|
||||
OffsetDateTime now = OffsetDateTime.now(ZoneId.of("Asia/Kolkata"));
|
||||
// Testing in minutes precision, but still need to take care around the end of the actual minute
|
||||
if (now.getSecond() > 56) {
|
||||
Thread.sleep(5000);
|
||||
now = OffsetDateTime.now(ZoneId.of("Asia/Kolkata"));
|
||||
}
|
||||
OffsetDateTime now = Utils.getAuditDateTimeToCompare();
|
||||
|
||||
final Integer loanID = applyForLoanApplicationWithPaymentStrategyAndPastMonth(clientID, loanProductID, Collections.emptyList(),
|
||||
null, "10000", LoanApplicationTestBuilder.DEFAULT_STRATEGY, "10 July 2022");
|
||||
Assertions.assertNotNull(loanID);
|
||||
@@ -109,57 +107,39 @@ public class LoanAuditingIntegrationTest {
|
||||
|
||||
OffsetDateTime createdDate = OffsetDateTime.parse((String) auditFieldsResponse.get(CREATED_DATE),
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
|
||||
OffsetDateTime lastModifiedDate = OffsetDateTime.parse((String) auditFieldsResponse.get(LAST_MODIFIED_DATE),
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
|
||||
LOG.info("-------------------------Check Audit dates---------------------------");
|
||||
assertEquals(1, auditFieldsResponse.get(CREATED_BY));
|
||||
assertEquals(1, auditFieldsResponse.get(LAST_MODIFIED_BY));
|
||||
assertEquals(now.getYear(), createdDate.getYear());
|
||||
assertEquals(now.getMonth(), createdDate.getMonth());
|
||||
assertEquals(now.getDayOfMonth(), createdDate.getDayOfMonth());
|
||||
assertEquals(now.getHour(), createdDate.getHour());
|
||||
assertEquals(now.getMinute(), createdDate.getMinute());
|
||||
|
||||
assertEquals(now.getYear(), lastModifiedDate.getYear());
|
||||
assertEquals(now.getMonth(), lastModifiedDate.getMonth());
|
||||
assertEquals(now.getDayOfMonth(), lastModifiedDate.getDayOfMonth());
|
||||
assertEquals(now.getHour(), lastModifiedDate.getHour());
|
||||
assertEquals(now.getMinute(), lastModifiedDate.getMinute());
|
||||
assertTrue(DateUtils.isEqual(now, createdDate, ChronoUnit.MINUTES));
|
||||
assertTrue(DateUtils.isEqual(now, lastModifiedDate, ChronoUnit.MINUTES));
|
||||
|
||||
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
|
||||
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization",
|
||||
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey(username, "P4ssw0rd"));
|
||||
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
OffsetDateTime now2 = Utils.getAuditDateTimeToCompare();
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan("11 July 2022", loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
auditFieldsResponse = LoanTransactionHelper.getLoanAuditFields(requestSpec, responseSpec, loanID, "");
|
||||
|
||||
createdDate = OffsetDateTime.parse((String) auditFieldsResponse.get(CREATED_DATE), DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
|
||||
OffsetDateTime createdDate2 = OffsetDateTime.parse((String) auditFieldsResponse.get(CREATED_DATE),
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
lastModifiedDate = OffsetDateTime.parse((String) auditFieldsResponse.get(LAST_MODIFIED_DATE),
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
|
||||
LOG.info("-------------------------Check Audit dates---------------------------");
|
||||
assertEquals(1, auditFieldsResponse.get(CREATED_BY));
|
||||
assertEquals(now.getYear(), createdDate.getYear());
|
||||
assertEquals(now.getMonth(), createdDate.getMonth());
|
||||
assertEquals(now.getDayOfMonth(), createdDate.getDayOfMonth());
|
||||
assertEquals(now.getHour(), createdDate.getHour());
|
||||
assertEquals(now.getMinute(), createdDate.getMinute());
|
||||
|
||||
now = OffsetDateTime.now(ZoneId.of("Asia/Kolkata"));
|
||||
assertTrue(DateUtils.isEqual(now, createdDate2, ChronoUnit.MINUTES));
|
||||
assertTrue(DateUtils.isEqual(createdDate, createdDate2));
|
||||
|
||||
assertEquals(userId, auditFieldsResponse.get(LAST_MODIFIED_BY));
|
||||
assertEquals(now.getYear(), lastModifiedDate.getYear());
|
||||
assertEquals(now.getMonth(), lastModifiedDate.getMonth());
|
||||
assertEquals(now.getDayOfMonth(), lastModifiedDate.getDayOfMonth());
|
||||
assertEquals(now.getHour(), lastModifiedDate.getHour());
|
||||
assertEquals(now.getMinute(), lastModifiedDate.getMinute());
|
||||
assertTrue(DateUtils.isEqual(now2, lastModifiedDate, ChronoUnit.MINUTES));
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplicationWithPaymentStrategyAndPastMonth(final Integer clientID, final Integer loanProductID,
|
||||
|
||||
+13
-36
@@ -23,6 +23,7 @@ import static org.apache.fineract.infrastructure.core.domain.AuditableFieldsCons
|
||||
import static org.apache.fineract.infrastructure.core.domain.AuditableFieldsConstants.LAST_MODIFIED_BY;
|
||||
import static org.apache.fineract.infrastructure.core.domain.AuditableFieldsConstants.LAST_MODIFIED_DATE;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import io.restassured.builder.RequestSpecBuilder;
|
||||
import io.restassured.builder.ResponseSpecBuilder;
|
||||
@@ -30,11 +31,12 @@ import io.restassured.http.ContentType;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import io.restassured.specification.ResponseSpecification;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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.accounting.Account;
|
||||
@@ -105,12 +107,7 @@ public class LoanTransactionAuditingIntegrationTest {
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("11 July 2022", loanID, "10000");
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
OffsetDateTime now = OffsetDateTime.now(ZoneId.of("Asia/Kolkata"));
|
||||
// Testing in minutes precision, but still need to take care around the end of the actual minute
|
||||
if (now.getSecond() > 56) {
|
||||
Thread.sleep(5000);
|
||||
now = OffsetDateTime.now(ZoneId.of("Asia/Kolkata"));
|
||||
}
|
||||
OffsetDateTime now = Utils.getAuditDateTimeToCompare();
|
||||
HashMap repaymentDetails = this.loanTransactionHelper.makeRepayment("11 July 2022", 100.0f, loanID);
|
||||
Integer transactionId = (Integer) repaymentDetails.get("resourceId");
|
||||
HashMap auditFieldsResponse = LoanTransactionHelper.getLoanTransactionAuditFields(requestSpec, responseSpec, loanID, transactionId,
|
||||
@@ -118,59 +115,39 @@ public class LoanTransactionAuditingIntegrationTest {
|
||||
|
||||
OffsetDateTime createdDate = OffsetDateTime.parse((String) auditFieldsResponse.get(CREATED_DATE),
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
|
||||
OffsetDateTime lastModifiedDate = OffsetDateTime.parse((String) auditFieldsResponse.get(LAST_MODIFIED_DATE),
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
|
||||
LOG.info("-------------------------Check Audit dates---------------------------");
|
||||
assertEquals(1, auditFieldsResponse.get(CREATED_BY));
|
||||
assertEquals(now.getYear(), createdDate.getYear());
|
||||
assertEquals(now.getMonth(), createdDate.getMonth());
|
||||
assertEquals(now.getDayOfMonth(), createdDate.getDayOfMonth());
|
||||
assertEquals(now.getHour(), createdDate.getHour());
|
||||
assertEquals(now.getMinute(), createdDate.getMinute());
|
||||
|
||||
assertEquals(1, auditFieldsResponse.get(LAST_MODIFIED_BY));
|
||||
assertEquals(now.getYear(), lastModifiedDate.getYear());
|
||||
assertEquals(now.getMonth(), lastModifiedDate.getMonth());
|
||||
assertEquals(now.getDayOfMonth(), lastModifiedDate.getDayOfMonth());
|
||||
assertEquals(now.getHour(), lastModifiedDate.getHour());
|
||||
assertEquals(now.getMinute(), lastModifiedDate.getMinute());
|
||||
assertTrue(DateUtils.isEqual(now, createdDate, ChronoUnit.MINUTES));
|
||||
assertTrue(DateUtils.isEqual(now, lastModifiedDate, ChronoUnit.MINUTES));
|
||||
|
||||
Thread.sleep(2000);
|
||||
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization",
|
||||
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey(username, "P4ssw0rd"));
|
||||
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
this.loanTransactionHelper.reverseRepayment(loanID, transactionId, "11 July 2022");
|
||||
|
||||
now = OffsetDateTime.now(ZoneId.of("Asia/Kolkata"));
|
||||
OffsetDateTime now2 = Utils.getAuditDateTimeToCompare();
|
||||
this.loanTransactionHelper.reverseRepayment(loanID, transactionId, "11 July 2022");
|
||||
|
||||
auditFieldsResponse = LoanTransactionHelper.getLoanTransactionAuditFields(requestSpec, responseSpec, loanID, transactionId, "");
|
||||
|
||||
createdDate = OffsetDateTime.parse((String) auditFieldsResponse.get(CREATED_DATE), DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
|
||||
OffsetDateTime createdDate2 = OffsetDateTime.parse((String) auditFieldsResponse.get(CREATED_DATE),
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
lastModifiedDate = OffsetDateTime.parse((String) auditFieldsResponse.get(LAST_MODIFIED_DATE),
|
||||
DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
|
||||
LOG.info("-------------------------Check Audit dates---------------------------");
|
||||
assertEquals(1, auditFieldsResponse.get(CREATED_BY));
|
||||
assertEquals(now.getYear(), createdDate.getYear());
|
||||
assertEquals(now.getMonth(), createdDate.getMonth());
|
||||
assertEquals(now.getDayOfMonth(), createdDate.getDayOfMonth());
|
||||
assertEquals(now.getHour(), createdDate.getHour());
|
||||
assertEquals(now.getMinute(), createdDate.getMinute());
|
||||
|
||||
now = OffsetDateTime.now(ZoneId.of("Asia/Kolkata"));
|
||||
assertTrue(DateUtils.isEqual(now, createdDate2, ChronoUnit.MINUTES));
|
||||
assertTrue(DateUtils.isEqual(createdDate, createdDate2));
|
||||
|
||||
assertEquals(userId, auditFieldsResponse.get(LAST_MODIFIED_BY));
|
||||
assertEquals(now.getYear(), lastModifiedDate.getYear());
|
||||
assertEquals(now.getMonth(), lastModifiedDate.getMonth());
|
||||
assertEquals(now.getDayOfMonth(), lastModifiedDate.getDayOfMonth());
|
||||
assertEquals(now.getHour(), lastModifiedDate.getHour());
|
||||
assertEquals(now.getMinute(), lastModifiedDate.getMinute());
|
||||
assertTrue(DateUtils.isEqual(now2, lastModifiedDate, ChronoUnit.MINUTES));
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplicationWithPaymentStrategyAndPastMonth(final Integer clientID, final Integer loanProductID,
|
||||
|
||||
+11
-7
@@ -44,7 +44,6 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeFormatterBuilder;
|
||||
import java.time.temporal.ChronoField;
|
||||
@@ -63,7 +62,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.http.conn.HttpHostConnectException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -376,12 +377,15 @@ public final class Utils {
|
||||
return dateFormat.format(dateToBeConvert.getTime());
|
||||
}
|
||||
|
||||
public static OffsetDateTime getAuditOffsetDateTime() {
|
||||
return OffsetDateTime.now(ZoneOffset.UTC);
|
||||
}
|
||||
|
||||
public static LocalDateTime getLocalDateTimeOfSystem() {
|
||||
return LocalDateTime.now(ZoneId.systemDefault());
|
||||
@NotNull
|
||||
public static OffsetDateTime getAuditDateTimeToCompare() throws InterruptedException {
|
||||
OffsetDateTime now = DateUtils.getAuditOffsetDateTime();
|
||||
// Testing in minutes precision, but still need to take care around the end of the actual minute
|
||||
if (now.getSecond() > 56) {
|
||||
Thread.sleep(5000);
|
||||
now = DateUtils.getAuditOffsetDateTime();
|
||||
}
|
||||
return now;
|
||||
}
|
||||
|
||||
public static TimeZone getTimeZoneOfTenant() {
|
||||
|
||||
+66
-49
@@ -139,6 +139,7 @@ public class DatatableIntegrationTest extends IntegrationTest {
|
||||
String itsANumber = "itsanumber";
|
||||
String itsAString = "itsastring";
|
||||
String itsAText = "itsatext";
|
||||
String itsAJson = "itsajson";
|
||||
String tst_tst_tst_cd_itsADropdown = tst_tst_tst + "_cd_itsadropdown";
|
||||
String dateFormat = "dateFormat";
|
||||
|
||||
@@ -155,43 +156,45 @@ public class DatatableIntegrationTest extends IntegrationTest {
|
||||
columnMap.put("apptableName", null);
|
||||
String errorRequestJsonString = new Gson().toJson(columnMap);
|
||||
ResponseSpecification responseSpecError400 = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
this.datatableHelper = new DatatableHelper(this.requestSpec, responseSpecError400);
|
||||
HashMap<String, Object> errorResponse = this.datatableHelper.createDatatable(errorRequestJsonString, "");
|
||||
DatatableHelper error400Helper = new DatatableHelper(this.requestSpec, responseSpecError400);
|
||||
HashMap<String, Object> errorResponse = error400Helper.createDatatable(errorRequestJsonString, "");
|
||||
assertEquals("validation.msg.validation.errors.exist", ((Map) errorResponse).get("userMessageGlobalisationCode"));
|
||||
List errors = (List) ((Map) errorResponse).get("errors");
|
||||
assertEquals(2, errors.size());
|
||||
assertEquals("validation.msg.datatable.apptableName.cannot.be.blank", ((Map) errors.get(0)).get("userMessageGlobalisationCode"));
|
||||
assertEquals("validation.msg.datatable.apptableName.is.not.one.of.expected.enumerations",
|
||||
((Map) errors.get(1)).get("userMessageGlobalisationCode"));
|
||||
|
||||
// set valid apptable name
|
||||
columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
|
||||
|
||||
// try to create datatable with invalid column type
|
||||
HashMap<String, Object> textColumn = addDatatableColumn(datatableColumnsList, itsAText, "Invalid", true, null, null);
|
||||
errorRequestJsonString = new Gson().toJson(columnMap);
|
||||
errorResponse = this.datatableHelper.createDatatable(errorRequestJsonString, "");
|
||||
errorResponse = error400Helper.createDatatable(errorRequestJsonString, "");
|
||||
assertEquals("validation.msg.validation.errors.exist", ((Map) errorResponse).get("userMessageGlobalisationCode"));
|
||||
errors = (List) ((Map) errorResponse).get("errors");
|
||||
assertEquals(1, errors.size());
|
||||
Map error = (Map) errors.get(0);
|
||||
assertEquals("validation.msg.datatable.type.is.not.one.of.expected.enumerations", error.get("userMessageGlobalisationCode"));
|
||||
assertTrue(((String) error.get("defaultUserMessage")).contains("string, number, boolean, decimal, date, datetime, text, dropdown"));
|
||||
assertTrue(((String) error.get("defaultUserMessage"))
|
||||
.contains("string, number, boolean, decimal, date, datetime, text, json, dropdown"));
|
||||
|
||||
// set valid type
|
||||
textColumn.put("type", "Text");
|
||||
// add json type
|
||||
addDatatableColumn(datatableColumnsList, itsAJson, "Json", false, null, null);
|
||||
|
||||
String datatabelRequestJsonString = new Gson().toJson(columnMap);
|
||||
LOG.info("map : {}", datatabelRequestJsonString);
|
||||
this.datatableHelper = new DatatableHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
HashMap<String, Object> datatableResponse = this.datatableHelper.createDatatable(datatabelRequestJsonString, "");
|
||||
String datatableName = (String) datatableResponse.get("resourceIdentifier");
|
||||
DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, this.responseSpec, datatableName);
|
||||
|
||||
// try to create with the same name
|
||||
this.datatableHelper = new DatatableHelper(this.requestSpec, responseSpecError400);
|
||||
errorResponse = this.datatableHelper.createDatatable(datatabelRequestJsonString, "");
|
||||
errorResponse = error400Helper.createDatatable(datatabelRequestJsonString, "");
|
||||
assertEquals("validation.msg.validation.errors.exist", ((Map) errorResponse).get("userMessageGlobalisationCode"));
|
||||
this.datatableHelper = new DatatableHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
// creating client with datatables
|
||||
final Integer clientID = ClientHelper.createClientAsPerson(requestSpec, responseSpec);
|
||||
@@ -211,7 +214,19 @@ public class DatatableIntegrationTest extends IntegrationTest {
|
||||
datatableEntryMap.put("locale", "en");
|
||||
datatableEntryMap.put(dateFormat, "yyyy-MM-dd");
|
||||
|
||||
String json = "{\"testparam\": \"testvalue\"}";
|
||||
// add invalid json
|
||||
datatableEntryMap.put(itsAJson, '{' + json);
|
||||
|
||||
String datatabelEntryRequestJsonString = new Gson().toJson(datatableEntryMap);
|
||||
ResponseSpecification responseSpecError403 = new ResponseSpecBuilder().expectStatusCode(403).build();
|
||||
DatatableHelper error403Helper = new DatatableHelper(this.requestSpec, responseSpecError403);
|
||||
errorResponse = error403Helper.createDatatableEntry(datatableName, clientID, genericResultSet, datatabelEntryRequestJsonString);
|
||||
|
||||
// add valid json
|
||||
datatableEntryMap.put(itsAJson, json);
|
||||
|
||||
datatabelEntryRequestJsonString = new Gson().toJson(datatableEntryMap);
|
||||
LOG.info("map : {}", datatabelEntryRequestJsonString);
|
||||
|
||||
HashMap<String, Object> datatableEntryResponse = this.datatableHelper.createDatatableEntry(datatableName, clientID,
|
||||
@@ -222,37 +237,43 @@ public class DatatableIntegrationTest extends IntegrationTest {
|
||||
final HashMap<String, Object> items = this.datatableHelper.readDatatableEntry(datatableName, clientID, genericResultSet,
|
||||
(Integer) datatableEntryResponse.get("resourceId"), "");
|
||||
assertNotNull(items);
|
||||
assertEquals(1, ((List) items.get("data")).size());
|
||||
|
||||
assertEquals("client_id", ((Map) ((List) items.get("columnHeaders")).get(0)).get("columnName"));
|
||||
assertEquals(clientID, ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(0));
|
||||
List columnHeaders = (List) items.get("columnHeaders");
|
||||
List columnData = (List) items.get("data");
|
||||
assertEquals(1, columnData.size());
|
||||
|
||||
assertEquals(itsABoolean, ((Map) ((List) items.get("columnHeaders")).get(1)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsABoolean), ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(1));
|
||||
Map data = (Map) columnData.get(0);
|
||||
|
||||
assertEquals(itsADate, ((Map) ((List) items.get("columnHeaders")).get(2)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsADate),
|
||||
Utils.arrayDateToString((List) ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(2)));
|
||||
assertEquals("client_id", ((Map) columnHeaders.get(0)).get("columnName"));
|
||||
assertEquals(clientID, ((List) data.get("row")).get(0));
|
||||
|
||||
assertEquals(itsADatetime, ((Map) ((List) items.get("columnHeaders")).get(3)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsADatetime),
|
||||
Utils.arrayDateTimeToString((List) ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(3)));
|
||||
assertEquals(itsABoolean, ((Map) columnHeaders.get(1)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsABoolean), ((List) data.get("row")).get(1));
|
||||
|
||||
assertEquals(itsADecimal, ((Map) ((List) items.get("columnHeaders")).get(4)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsADecimal), ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(4));
|
||||
assertEquals(itsADate, ((Map) columnHeaders.get(2)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsADate), Utils.arrayDateToString((List) ((List) data.get("row")).get(2)));
|
||||
|
||||
assertEquals(tst_tst_tst_cd_itsADropdown, ((Map) ((List) items.get("columnHeaders")).get(5)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(tst_tst_tst_cd_itsADropdown),
|
||||
((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(5));
|
||||
assertEquals(itsADatetime, ((Map) columnHeaders.get(3)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsADatetime), Utils.arrayDateTimeToString((List) ((List) data.get("row")).get(3)));
|
||||
|
||||
assertEquals(itsANumber, ((Map) ((List) items.get("columnHeaders")).get(6)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsANumber), ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(6));
|
||||
assertEquals(itsADecimal, ((Map) columnHeaders.get(4)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsADecimal), ((List) data.get("row")).get(4));
|
||||
|
||||
assertEquals(itsAString, ((Map) ((List) items.get("columnHeaders")).get(7)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsAString), ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(7));
|
||||
assertEquals(tst_tst_tst_cd_itsADropdown, ((Map) columnHeaders.get(5)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(tst_tst_tst_cd_itsADropdown), ((List) data.get("row")).get(5));
|
||||
|
||||
assertEquals(itsAText, ((Map) ((List) items.get("columnHeaders")).get(8)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsAText), ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(8));
|
||||
assertEquals(itsANumber, ((Map) columnHeaders.get(6)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsANumber), ((List) data.get("row")).get(6));
|
||||
|
||||
assertEquals(itsAString, ((Map) columnHeaders.get(7)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsAString), ((List) data.get("row")).get(7));
|
||||
|
||||
assertEquals(itsAText, ((Map) columnHeaders.get(8)).get("columnName"));
|
||||
assertEquals(datatableEntryMap.get(itsAText), ((List) data.get("row")).get(8));
|
||||
|
||||
assertEquals(itsAJson, ((Map) columnHeaders.get(9)).get("columnName"));
|
||||
Object jsonResponse = ((List) data.get("row")).get(9);
|
||||
assertEquals(datatableEntryMap.get(itsAJson), jsonResponse instanceof Map ? ((Map) jsonResponse).get("value") : jsonResponse);
|
||||
|
||||
// Read the Datatable entry generated with genericResultSet in false
|
||||
List<HashMap<String, Object>> datatableEntryResponseNoGenericResult = this.datatableHelper.readDatatableEntry(datatableName,
|
||||
@@ -260,19 +281,17 @@ public class DatatableIntegrationTest extends IntegrationTest {
|
||||
assertNotNull(datatableEntryResponseNoGenericResult, "ERROR IN GETTING THE DATE VALUE FROM DATATABLE RECORD");
|
||||
assertEquals(1, datatableEntryResponseNoGenericResult.size());
|
||||
|
||||
assertEquals(clientID, datatableEntryResponseNoGenericResult.get(0).get("client_id"));
|
||||
assertEquals(datatableEntryMap.get(itsABoolean),
|
||||
Boolean.valueOf((String) datatableEntryResponseNoGenericResult.get(0).get(itsABoolean)));
|
||||
assertEquals(datatableEntryMap.get(itsADate),
|
||||
Utils.arrayDateToString((List) datatableEntryResponseNoGenericResult.get(0).get(itsADate)));
|
||||
assertEquals(datatableEntryMap.get(itsADecimal), datatableEntryResponseNoGenericResult.get(0).get(itsADecimal));
|
||||
assertEquals(datatableEntryMap.get(itsADatetime),
|
||||
Utils.arrayDateTimeToString((List<Integer>) datatableEntryResponseNoGenericResult.get(0).get(itsADatetime)));
|
||||
assertEquals(datatableEntryMap.get(tst_tst_tst_cd_itsADropdown),
|
||||
datatableEntryResponseNoGenericResult.get(0).get(tst_tst_tst_cd_itsADropdown));
|
||||
assertEquals(datatableEntryMap.get(itsANumber), datatableEntryResponseNoGenericResult.get(0).get(itsANumber));
|
||||
assertEquals(datatableEntryMap.get(itsAString), datatableEntryResponseNoGenericResult.get(0).get(itsAString));
|
||||
assertEquals(datatableEntryMap.get(itsAText), datatableEntryResponseNoGenericResult.get(0).get(itsAText));
|
||||
HashMap<String, Object> responseMap = datatableEntryResponseNoGenericResult.get(0);
|
||||
assertEquals(clientID, responseMap.get("client_id"));
|
||||
assertEquals(datatableEntryMap.get(itsABoolean), Boolean.valueOf((String) responseMap.get(itsABoolean)));
|
||||
assertEquals(datatableEntryMap.get(itsADate), Utils.arrayDateToString((List) responseMap.get(itsADate)));
|
||||
assertEquals(datatableEntryMap.get(itsADecimal), responseMap.get(itsADecimal));
|
||||
assertEquals(datatableEntryMap.get(itsADatetime), Utils.arrayDateTimeToString((List<Integer>) responseMap.get(itsADatetime)));
|
||||
assertEquals(datatableEntryMap.get(tst_tst_tst_cd_itsADropdown), responseMap.get(tst_tst_tst_cd_itsADropdown));
|
||||
assertEquals(datatableEntryMap.get(itsANumber), responseMap.get(itsANumber));
|
||||
assertEquals(datatableEntryMap.get(itsAString), responseMap.get(itsAString));
|
||||
assertEquals(datatableEntryMap.get(itsAText), responseMap.get(itsAText));
|
||||
assertEquals(datatableEntryMap.get(itsAJson), responseMap.get(itsAJson));
|
||||
|
||||
// Update datatable entry
|
||||
Boolean previousBoolean = (Boolean) datatableEntryMap.get(itsABoolean);
|
||||
@@ -475,10 +494,9 @@ public class DatatableIntegrationTest extends IntegrationTest {
|
||||
|
||||
// try to create with the same name
|
||||
ResponseSpecification responseSpecError400 = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
this.datatableHelper = new DatatableHelper(this.requestSpec, responseSpecError400);
|
||||
HashMap<String, Object> response = this.datatableHelper.createDatatable(datatabelRequestJsonString, "");
|
||||
DatatableHelper error400Helper = new DatatableHelper(this.requestSpec, responseSpecError400);
|
||||
HashMap<String, Object> response = error400Helper.createDatatable(datatabelRequestJsonString, "");
|
||||
assertEquals("validation.msg.validation.errors.exist", ((Map) response).get("userMessageGlobalisationCode"));
|
||||
this.datatableHelper = new DatatableHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
// creating client with datatables
|
||||
final Integer clientID = ClientHelper.createClientAsPerson(requestSpec, responseSpec);
|
||||
@@ -739,10 +757,9 @@ public class DatatableIntegrationTest extends IntegrationTest {
|
||||
|
||||
// try to create with the same name
|
||||
ResponseSpecification responseSpecError400 = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
this.datatableHelper = new DatatableHelper(this.requestSpec, responseSpecError400);
|
||||
HashMap<String, Object> response = this.datatableHelper.createDatatable(datatabelRequestJsonString, "");
|
||||
DatatableHelper error400Helper = new DatatableHelper(this.requestSpec, responseSpecError400);
|
||||
HashMap<String, Object> response = error400Helper.createDatatable(datatabelRequestJsonString, "");
|
||||
assertEquals("validation.msg.validation.errors.exist", ((Map) response).get("userMessageGlobalisationCode"));
|
||||
this.datatableHelper = new DatatableHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
// creating client with datatables
|
||||
final Integer clientID = ClientHelper.createClientAsPerson(requestSpec, responseSpec);
|
||||
|
||||
Reference in New Issue
Block a user