Integration tests for auditing and loan templating
This commit is contained in:
committed by
Arnold Gálovics
parent
470ff9a745
commit
ddc6a76689
+17
@@ -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.
|
||||
|
||||
+6
-2
@@ -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();
|
||||
|
||||
+8
-6
@@ -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, "");
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user