FINERACT-1047 Added integration test for limit param (audit trails)
This commit is contained in:
committed by
Michael Vorburger ⛑️
parent
acca72f83d
commit
44650034b1
+26
@@ -25,6 +25,7 @@ import io.restassured.specification.RequestSpecification;
|
|||||||
import io.restassured.specification.ResponseSpecification;
|
import io.restassured.specification.ResponseSpecification;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
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;
|
||||||
import org.apache.fineract.integrationtests.common.OfficeHelper;
|
import org.apache.fineract.integrationtests.common.OfficeHelper;
|
||||||
@@ -102,4 +103,29 @@ public class AuditIntegrationTest {
|
|||||||
auditHelper.verifyOneAuditOnly(auditsRecieved, officeId, "CREATE", "OFFICE");
|
auditHelper.verifyOneAuditOnly(auditsRecieved, officeId, "CREATE", "OFFICE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Here we test that audit request with limit x only returns x entries
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void checkAuditsWithLimit() {
|
||||||
|
// Create client
|
||||||
|
final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||||
|
|
||||||
|
// The following loop would ensure database have atleast 8 audits.
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
// Close client
|
||||||
|
this.clientHelper.closeClient(clientId);
|
||||||
|
// Activate client
|
||||||
|
this.clientHelper.reactivateClient(clientId);
|
||||||
|
}
|
||||||
|
|
||||||
|
Random rand = new Random();
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
// limit contains a number between 1-8
|
||||||
|
int limit = rand.nextInt(7) + 1;
|
||||||
|
auditHelper.verifyLimitParameterfor(limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+14
@@ -25,6 +25,7 @@ import io.restassured.specification.ResponseSpecification;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -55,6 +56,15 @@ public class AuditHelper {
|
|||||||
return responseAudits;
|
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;
|
||||||
|
LinkedHashMap responseAudits = Utils.performServerGet(requestSpec, responseSpec, AUDIT_URL, "");
|
||||||
|
return (List) responseAudits.get("pageItems");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some audit actions can only be done once Eg: Creation of a client with id 123, hence we verify number of audits
|
* Some audit actions can only be done once Eg: Creation of a client with id 123, hence we verify number of audits
|
||||||
* For such operations is "equal" to 1 always
|
* For such operations is "equal" to 1 always
|
||||||
@@ -86,4 +96,8 @@ public class AuditHelper {
|
|||||||
assertEquals(expected, actual, "Error in creating audit!");
|
assertEquals(expected, actual, "Error in creating audit!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void verifyLimitParameterfor(final int limit) {
|
||||||
|
assertEquals(limit, getAuditDetails(limit).size(), "Incorrect number of audits recieved for limit: " + Integer.toString(limit));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user