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;
|
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 edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import io.restassured.builder.RequestSpecBuilder;
|
import io.restassured.builder.RequestSpecBuilder;
|
||||||
import io.restassured.builder.ResponseSpecBuilder;
|
import io.restassured.builder.ResponseSpecBuilder;
|
||||||
@@ -27,6 +31,7 @@ import io.restassured.specification.ResponseSpecification;
|
|||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.fineract.integrationtests.common.AuditHelper;
|
import org.apache.fineract.integrationtests.common.AuditHelper;
|
||||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||||
@@ -62,6 +67,18 @@ public class AuditIntegrationTest {
|
|||||||
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
|
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
|
* 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.
|
* 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);
|
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||||
|
|
||||||
// Get repayments
|
// Get repayments Template for Repayment
|
||||||
final ArrayList<HashMap> installmentData = this.loanTransactionHelper.getRepayments(loanID);
|
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");
|
Assertions.assertNotNull(installmentData, "Empty Installment Data");
|
||||||
List<HashMap> postDatedChecks = new ArrayList<>();
|
List<HashMap> postDatedChecks = new ArrayList<>();
|
||||||
Gson gson = new Gson();
|
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 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 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) {
|
public AuditHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||||
this.requestSpec = requestSpec;
|
this.requestSpec = requestSpec;
|
||||||
@@ -50,19 +51,20 @@ public class AuditHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List getAuditDetails(final Integer resourceId, final String actionName, final String entityName) {
|
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
|
final String AUDIT_URL = AUDIT_BASE_URL + "&entityName=" + entityName + "&resourceId=" + resourceId + "&actionName=" + actionName
|
||||||
+ "&actionName=" + actionName + "&orderBy=id&sortBy=DSC&" + Utils.TENANT_IDENTIFIER;
|
+ "&orderBy=id&sortBy=DSC";
|
||||||
List<HashMap<String, Object>> responseAudits = Utils.performServerGet(requestSpec, responseSpec, AUDIT_URL, "");
|
List<HashMap<String, Object>> responseAudits = Utils.performServerGet(requestSpec, responseSpec, AUDIT_URL, "");
|
||||||
return responseAudits;
|
return responseAudits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getAuditDetails(final int limit) {
|
public List getAuditDetails(final int limit) {
|
||||||
|
final String AUDIT_URL = AUDIT_BASE_URL + "&paged=true&limit=" + Integer.toString(limit);
|
||||||
final String AUDIT_URL = "/fineract-provider/api/v1/audits?paged=true&limit=" + Integer.toString(limit) + "&"
|
|
||||||
+ Utils.TENANT_IDENTIFIER;
|
|
||||||
LinkedHashMap responseAudits = Utils.performServerGet(requestSpec, responseSpec, AUDIT_URL, "");
|
LinkedHashMap responseAudits = Utils.performServerGet(requestSpec, responseSpec, AUDIT_URL, "");
|
||||||
return (List) responseAudits.get("pageItems");
|
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) {
|
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, "");
|
Utils.performServerGet(requestSpec, responseSpec, AUDIT_URL, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
@@ -180,6 +180,12 @@ public class LoanTransactionHelper {
|
|||||||
return Utils.performServerGet(requestSpec, responseSpec, GET_LOAN_CHARGES_URL, "");
|
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) {
|
public ArrayList<HashMap> getRepayments(final Integer loanId) {
|
||||||
final String GET_REPAYMENTS_URL = "/fineract-provider/api/v1/loans/" + loanId + "/transactions/template?command=disburse&"
|
final String GET_REPAYMENTS_URL = "/fineract-provider/api/v1/loans/" + loanId + "/transactions/template?command=disburse&"
|
||||||
+ Utils.TENANT_IDENTIFIER;
|
+ Utils.TENANT_IDENTIFIER;
|
||||||
|
|||||||
Reference in New Issue
Block a user