This is an automated email from the ASF dual-hosted git repository.
arnold pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new ddc6a7668 Integration tests for auditing and loan templating
ddc6a7668 is described below
commit ddc6a7668970bc82f727071fe95e6bc5f3c101da
Author: Jose Alberto Hernandez <[email protected]>
AuthorDate: Sun Jun 19 14:32:53 2022 -0500
Integration tests for auditing and loan templating
---
.../fineract/integrationtests/AuditIntegrationTest.java | 17 +++++++++++++++++
.../RepaymentWithPostDatedChecksTest.java | 8 ++++++--
.../fineract/integrationtests/common/AuditHelper.java | 14 ++++++++------
.../common/loans/LoanTransactionHelper.java | 6 ++++++
4 files changed, 37 insertions(+), 8 deletions(-)
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AuditIntegrationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AuditIntegrationTest.java
index 8d2afa450..5c17dba4d 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AuditIntegrationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AuditIntegrationTest.java
@@ -18,6 +18,10 @@
*/
package org.apache.fineract.integrationtests;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.builder.ResponseSpecBuilder;
@@ -27,6 +31,7 @@ import io.restassured.specification.ResponseSpecification;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import org.apache.fineract.integrationtests.common.AuditHelper;
import org.apache.fineract.integrationtests.common.ClientHelper;
@@ -62,6 +67,18 @@ public class AuditIntegrationTest {
this.clientHelper = new ClientHelper(this.requestSpec,
this.responseSpec);
}
+ @Test
+ public void testAuditSearchTemplate() {
+ // given
+ // when
+ LinkedHashMap auditSearchTemplate =
this.auditHelper.getAuditSearchTemplate();
+
+ // then
+ assertNotNull(auditSearchTemplate);
+ assertEquals(4, auditSearchTemplate.size()); // appUsers, actionNames,
entityNames, processingResults
+ assertTrue(((List) auditSearchTemplate.get("actionNames")).size() > 0);
+ }
+
/**
* Here we Create/Update different Entities and verify an audit is
generated for each action. This can be further
* extened with more entities and actions in similiar way.
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java
index 0c33d2bde..2b24987a8 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java
@@ -90,8 +90,12 @@ public class RepaymentWithPostDatedChecksTest {
loanStatusHashMap =
LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
- // Get repayments
- final ArrayList<HashMap> installmentData =
this.loanTransactionHelper.getRepayments(loanID);
+ // Get repayments Template for Repayment
+ ArrayList<HashMap> installmentData =
this.loanTransactionHelper.getRepayments(loanID);
+ Assertions.assertNotNull(installmentData, "Empty Installment Data
Template");
+
+ // Get repayments for Disburse
+ installmentData = this.loanTransactionHelper.getRepayments(loanID);
Assertions.assertNotNull(installmentData, "Empty Installment Data");
List<HashMap> postDatedChecks = new ArrayList<>();
Gson gson = new Gson();
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/AuditHelper.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/AuditHelper.java
index b8c5db74d..48687b48e 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/AuditHelper.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/AuditHelper.java
@@ -43,6 +43,7 @@ public class AuditHelper {
private static final Logger LOG =
LoggerFactory.getLogger(AuditHelper.class);
private static final String AUDIT_BASE_URL =
"/fineract-provider/api/v1/audits?" + Utils.TENANT_IDENTIFIER;
+ private static final String AUDITSEARCH_BASE_URL =
"/fineract-provider/api/v1/audits/searchtemplate?" + Utils.TENANT_IDENTIFIER;
public AuditHelper(final RequestSpecification requestSpec, final
ResponseSpecification responseSpec) {
this.requestSpec = requestSpec;
@@ -50,19 +51,20 @@ public class AuditHelper {
}
public List getAuditDetails(final Integer resourceId, final String
actionName, final String entityName) {
- final String AUDIT_URL = "/fineract-provider/api/v1/audits/?" +
"entityName=" + entityName + "&resourceId=" + resourceId
- + "&actionName=" + actionName + "&orderBy=id&sortBy=DSC&" +
Utils.TENANT_IDENTIFIER;
+ final String AUDIT_URL = AUDIT_BASE_URL + "&entityName=" + entityName
+ "&resourceId=" + resourceId + "&actionName=" + actionName
+ + "&orderBy=id&sortBy=DSC";
List<HashMap<String, Object>> responseAudits =
Utils.performServerGet(requestSpec, responseSpec, AUDIT_URL, "");
return responseAudits;
}
public List getAuditDetails(final int limit) {
-
- final String AUDIT_URL =
"/fineract-provider/api/v1/audits?paged=true&limit=" + Integer.toString(limit)
+ "&"
- + Utils.TENANT_IDENTIFIER;
+ final String AUDIT_URL = AUDIT_BASE_URL + "&paged=true&limit=" +
Integer.toString(limit);
LinkedHashMap responseAudits = Utils.performServerGet(requestSpec,
responseSpec, AUDIT_URL, "");
return (List) responseAudits.get("pageItems");
+ }
+ public LinkedHashMap getAuditSearchTemplate() {
+ return Utils.performServerGet(requestSpec, responseSpec,
AUDITSEARCH_BASE_URL, "$");
}
/**
@@ -101,7 +103,7 @@ public class AuditHelper {
}
public void verifyOrderBysupported(final String orderByValue) {
- final String AUDIT_URL =
"/fineract-provider/api/v1/audits/?paged=true&orderBy=" + orderByValue + "&" +
Utils.TENANT_IDENTIFIER;
+ final String AUDIT_URL = AUDIT_BASE_URL + "&paged=true&orderBy=" +
orderByValue;
Utils.performServerGet(requestSpec, responseSpec, AUDIT_URL, "");
}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
index ad8626a29..ca327255e 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
@@ -180,6 +180,12 @@ public class LoanTransactionHelper {
return Utils.performServerGet(requestSpec, responseSpec,
GET_LOAN_CHARGES_URL, "");
}
+ public List getRepaymentTemplate(final Integer loanId) {
+ final String GET_REPAYMENTS_URL = "/fineract-provider/api/v1/loans/" +
loanId + "/transactions/template?command=repayment&"
+ + Utils.TENANT_IDENTIFIER;
+ return Utils.performServerGet(requestSpec, responseSpec,
GET_REPAYMENTS_URL, "$");
+ }
+
public ArrayList<HashMap> getRepayments(final Integer loanId) {
final String GET_REPAYMENTS_URL = "/fineract-provider/api/v1/loans/" +
loanId + "/transactions/template?command=disburse&"
+ Utils.TENANT_IDENTIFIER;