FINERACT-1040 Re-enabling and fixing CampaignTests
This commit is contained in:
committed by
Michael Vorburger ⛑️
parent
3c2f178180
commit
f3862bca8b
@@ -114,6 +114,7 @@ dependencyManagement {
|
|||||||
dependency 'org.awaitility:awaitility:4.0.3'
|
dependency 'org.awaitility:awaitility:4.0.3'
|
||||||
dependency 'com.github.spotbugs:spotbugs-annotations:4.0.4'
|
dependency 'com.github.spotbugs:spotbugs-annotations:4.0.4'
|
||||||
dependency 'javax.cache:cache-api:1.1.1'
|
dependency 'javax.cache:cache-api:1.1.1'
|
||||||
|
dependency 'org.mock-server:mockserver-junit-jupiter:5.10'
|
||||||
|
|
||||||
// If this is upgraded, you need to change path in WebFrontEndConfiguration
|
// If this is upgraded, you need to change path in WebFrontEndConfiguration
|
||||||
dependency 'org.webjars.npm:swagger-ui-dist:3.27.0'
|
dependency 'org.webjars.npm:swagger-ui-dist:3.27.0'
|
||||||
|
|||||||
@@ -124,6 +124,10 @@ dependencies {
|
|||||||
'io.github.classgraph:classgraph',
|
'io.github.classgraph:classgraph',
|
||||||
'org.awaitility:awaitility'
|
'org.awaitility:awaitility'
|
||||||
)
|
)
|
||||||
|
testImplementation('org.mock-server:mockserver-junit-jupiter') {
|
||||||
|
exclude group: 'com.sun.mail', module: 'mailapi'
|
||||||
|
exclude group: 'javax.servlet', module: 'javax.servlet-api'
|
||||||
|
}
|
||||||
testImplementation ('io.rest-assured:rest-assured') {
|
testImplementation ('io.rest-assured:rest-assured') {
|
||||||
exclude group: 'commons-logging'
|
exclude group: 'commons-logging'
|
||||||
exclude group: 'org.apache.sling'
|
exclude group: 'org.apache.sling'
|
||||||
|
|||||||
+4
-13
@@ -22,12 +22,9 @@ import static io.restassured.RestAssured.given;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import io.restassured.path.json.JsonPath;
|
import io.restassured.path.json.JsonPath;
|
||||||
import io.restassured.specification.RequestSpecification;
|
import io.restassured.specification.RequestSpecification;
|
||||||
import io.restassured.specification.ResponseSpecification;
|
import io.restassured.specification.ResponseSpecification;
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.fineract.integrationtests.common.Utils;
|
import org.apache.fineract.integrationtests.common.Utils;
|
||||||
@@ -166,28 +163,22 @@ public class CampaignsHelper {
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<ReportData> getReports() {
|
public List<ReportData> getReports() {
|
||||||
return getReports(BUSINESS_RULE_OPTIONS);
|
return getReports(BUSINESS_RULE_OPTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<ReportData> getReports(String jsonAttributeToGetBack) {
|
private List<ReportData> getReports(String jsonAttributeToGetBack) {
|
||||||
LOG.info("--------------------------------- GET REPORTS OPTIONS -------------------------------");
|
LOG.info("--------------------------------- GET REPORTS OPTIONS -------------------------------");
|
||||||
Assert.notNull(jsonAttributeToGetBack, "jsonAttributeToGetBack may not be null");
|
Assert.notNull(jsonAttributeToGetBack, "jsonAttributeToGetBack may not be null");
|
||||||
final String templateUrl = SMS_CAMPAIGNS_URL + "/template?" + Utils.TENANT_IDENTIFIER;
|
final String templateUrl = SMS_CAMPAIGNS_URL + "/template?" + Utils.TENANT_IDENTIFIER;
|
||||||
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(templateUrl).andReturn()
|
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(templateUrl).andReturn()
|
||||||
.asString();
|
.asString();
|
||||||
Assert.notNull(json, "json");
|
Assert.notNull(json, "json");
|
||||||
ArrayList<ReportData> reportsList = new ArrayList<>();
|
return JsonPath.from(json).getList(jsonAttributeToGetBack, ReportData.class);
|
||||||
String reportsString = new Gson().toJson(JsonPath.from(json).get(jsonAttributeToGetBack));
|
|
||||||
Assert.notNull(reportsString, "reportsString");
|
|
||||||
final Gson gson = new Gson();
|
|
||||||
final Type typeOfHashMap = new TypeToken<List<ReportData>>() {}.getType();
|
|
||||||
reportsList = gson.fromJson(reportsString, typeOfHashMap);
|
|
||||||
return reportsList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long getSelectedReportId(final String reportName) {
|
private Long getSelectedReportId(final String reportName) {
|
||||||
ArrayList<ReportData> reports = getReports();
|
List<ReportData> reports = getReports();
|
||||||
|
|
||||||
if (reports != null && !reports.isEmpty()) {
|
if (reports != null && !reports.isEmpty()) {
|
||||||
for (ReportData reportData : reports) {
|
for (ReportData reportData : reports) {
|
||||||
|
|||||||
+37
-10
@@ -19,6 +19,8 @@
|
|||||||
package org.apache.fineract.integrationtests.common.organisation;
|
package org.apache.fineract.integrationtests.common.organisation;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.mockserver.model.HttpRequest.request;
|
||||||
|
import static org.mockserver.model.HttpResponse.response;
|
||||||
|
|
||||||
import io.restassured.builder.RequestSpecBuilder;
|
import io.restassured.builder.RequestSpecBuilder;
|
||||||
import io.restassured.builder.ResponseSpecBuilder;
|
import io.restassured.builder.ResponseSpecBuilder;
|
||||||
@@ -30,10 +32,16 @@ import java.util.HashMap;
|
|||||||
import org.apache.fineract.integrationtests.common.CommonConstants;
|
import org.apache.fineract.integrationtests.common.CommonConstants;
|
||||||
import org.apache.fineract.integrationtests.common.Utils;
|
import org.apache.fineract.integrationtests.common.Utils;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockserver.integration.ClientAndServer;
|
||||||
|
import org.mockserver.junit.jupiter.MockServerExtension;
|
||||||
|
import org.mockserver.junit.jupiter.MockServerSettings;
|
||||||
|
import org.mockserver.model.MediaType;
|
||||||
|
|
||||||
|
@ExtendWith(MockServerExtension.class)
|
||||||
|
@MockServerSettings(ports = { 9191 })
|
||||||
|
|
||||||
@Disabled
|
|
||||||
public class CampaignsTest {
|
public class CampaignsTest {
|
||||||
|
|
||||||
private RequestSpecification requestSpec;
|
private RequestSpecification requestSpec;
|
||||||
@@ -53,6 +61,25 @@ public class CampaignsTest {
|
|||||||
|
|
||||||
public static final String DATE_FORMAT = "dd MMMM yyyy";
|
public static final String DATE_FORMAT = "dd MMMM yyyy";
|
||||||
|
|
||||||
|
private final ClientAndServer client;
|
||||||
|
|
||||||
|
public CampaignsTest(ClientAndServer client) {
|
||||||
|
this.client = client;
|
||||||
|
|
||||||
|
// Set up mock server for message-gateway
|
||||||
|
this.client.when(request().withMethod("GET").withPath("/smsbridges"))
|
||||||
|
.respond(response().withContentType(MediaType.APPLICATION_JSON).withBody("[\n" + //
|
||||||
|
" {\n" + //
|
||||||
|
" \"id\": 1,\n" + //
|
||||||
|
" \"tenantId\": 1,\n" + //
|
||||||
|
" \"phoneNo\": \"+1234567890\",\n" + //
|
||||||
|
" \"providerName\": \"Dummy SMS Provider - Testing\",\n" + //
|
||||||
|
" \"providerDescription\": \"Dummy, just for testing\"\n" + //
|
||||||
|
" }\n" + //
|
||||||
|
"]") //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
Utils.initializeRESTAssured();
|
Utils.initializeRESTAssured();
|
||||||
@@ -177,11 +204,11 @@ public class CampaignsTest {
|
|||||||
this.campaignsHelper.verifyCampaignCreatedOnServer(this.requestSpec, this.responseSpec, campaignId);
|
this.campaignsHelper.verifyCampaignCreatedOnServer(this.requestSpec, this.responseSpec, campaignId);
|
||||||
|
|
||||||
// activating campaign with failure
|
// activating campaign with failure
|
||||||
ArrayList<HashMap> campaignDateValidationData = (ArrayList<HashMap>) campaignsHelperWithError.performActionsOnCampaignWithFailure(
|
ArrayList<HashMap<String, Object>> campaignDateValidationData = (ArrayList<HashMap<String, Object>>) campaignsHelperWithError
|
||||||
campaignId, ACTIVATE_COMMAND, Utils.getLocalDateOfTenant().plusDays(1).toString(DATE_FORMAT),
|
.performActionsOnCampaignWithFailure(campaignId, ACTIVATE_COMMAND,
|
||||||
CommonConstants.RESPONSE_ERROR);
|
Utils.getLocalDateOfTenant().plusDays(1).toString(DATE_FORMAT), CommonConstants.RESPONSE_ERROR);
|
||||||
assertEquals("error.msg.campaign.activationDate.in.the.future",
|
assertEquals("error.msg.campaign.activationDate.in.the.future",
|
||||||
((HashMap<String, Object>) campaignDateValidationData.get(0)).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
campaignDateValidationData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||||
|
|
||||||
// activating campaign
|
// activating campaign
|
||||||
Integer activatedCampaignId = this.campaignsHelper.performActionsOnCampaign(this.requestSpec, this.responseSpec, campaignId,
|
Integer activatedCampaignId = this.campaignsHelper.performActionsOnCampaign(this.requestSpec, this.responseSpec, campaignId,
|
||||||
@@ -189,10 +216,10 @@ public class CampaignsTest {
|
|||||||
assertEquals(activatedCampaignId, campaignId);
|
assertEquals(activatedCampaignId, campaignId);
|
||||||
|
|
||||||
// activating campaign with failure
|
// activating campaign with failure
|
||||||
ArrayList<HashMap> campaignErrorData = (ArrayList<HashMap>) campaignsHelperWithError.performActionsOnCampaignWithFailure(
|
ArrayList<HashMap<String, Object>> campaignErrorData = (ArrayList<HashMap<String, Object>>) campaignsHelperWithError
|
||||||
activatedCampaignId, ACTIVATE_COMMAND, Utils.getLocalDateOfTenant().toString(DATE_FORMAT), CommonConstants.RESPONSE_ERROR);
|
.performActionsOnCampaignWithFailure(activatedCampaignId, ACTIVATE_COMMAND,
|
||||||
assertEquals("error.msg.campaign.already.active",
|
Utils.getLocalDateOfTenant().toString(DATE_FORMAT), CommonConstants.RESPONSE_ERROR);
|
||||||
((HashMap<String, Object>) campaignErrorData.get(0)).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
assertEquals("error.msg.campaign.already.active", campaignErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||||
|
|
||||||
// closing campaign again for deletion
|
// closing campaign again for deletion
|
||||||
Integer closedCampaignId = this.campaignsHelper.performActionsOnCampaign(this.requestSpec, this.responseSpec, campaignId,
|
Integer closedCampaignId = this.campaignsHelper.performActionsOnCampaign(this.requestSpec, this.responseSpec, campaignId,
|
||||||
|
|||||||
+8
-6
@@ -22,17 +22,19 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class ReportData {
|
public class ReportData {
|
||||||
|
|
||||||
private final Long reportId;
|
private Long reportId;
|
||||||
|
|
||||||
private final String reportName;
|
private String reportName;
|
||||||
|
|
||||||
private final String reportType;
|
private String reportType;
|
||||||
|
|
||||||
private final String reportSubType;
|
private String reportSubType;
|
||||||
|
|
||||||
private final String reportDescription;
|
private String reportDescription;
|
||||||
|
|
||||||
private final Map<String, Object> reportParamName;
|
private Map<String, Object> reportParamName;
|
||||||
|
|
||||||
|
public ReportData() {}
|
||||||
|
|
||||||
public ReportData(final Long reportId, final String reportName, final String reportType, final String reportSubType,
|
public ReportData(final Long reportId, final String reportName, final String reportType, final String reportSubType,
|
||||||
final Map<String, Object> reportParamName, final String reportDescription) {
|
final Map<String, Object> reportParamName, final String reportDescription) {
|
||||||
|
|||||||
+4
-14
@@ -89,20 +89,7 @@ public class ClasspathHellDuplicatesChecker {
|
|||||||
private boolean skipJAR(String jarPath) {
|
private boolean skipJAR(String jarPath) {
|
||||||
// ./gradlew test finds classes from the Gradle Wrapper (which don't
|
// ./gradlew test finds classes from the Gradle Wrapper (which don't
|
||||||
// show up in-IDE), exclude those
|
// show up in-IDE), exclude those
|
||||||
return jarPath.contains("/.gradle/wrapper/dists/") || jarPath.contains("/io.rest-assured/"); // TODO
|
return jarPath.contains("/.gradle/wrapper/dists/");
|
||||||
// FINERACT-884
|
|
||||||
// remove
|
|
||||||
// when
|
|
||||||
// RestAssured
|
|
||||||
// was
|
|
||||||
// bumped
|
|
||||||
// from
|
|
||||||
// 3.3.0
|
|
||||||
// to
|
|
||||||
// 4.3.0
|
|
||||||
// in
|
|
||||||
// Spring
|
|
||||||
// BOM
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isHarmlessDuplicate(String resourcePath) {
|
protected boolean isHarmlessDuplicate(String resourcePath) {
|
||||||
@@ -121,6 +108,9 @@ public class ClasspathHellDuplicatesChecker {
|
|||||||
|| resourcePath.startsWith("org/opendaylight/blueprint/") || resourcePath.endsWith("reference.conf") // in
|
|| resourcePath.startsWith("org/opendaylight/blueprint/") || resourcePath.endsWith("reference.conf") // in
|
||||||
// Akka's
|
// Akka's
|
||||||
// JARs
|
// JARs
|
||||||
|
// json-schema-core and json-schema-validator depend on each
|
||||||
|
// other and include these files
|
||||||
|
|| resourcePath.equals("draftv4/schema") || resourcePath.equals("draftv3/schema") //
|
||||||
|| resourcePath.equals("WEB-INF/web.xml") || resourcePath.equals("META-INF/web-fragment.xml")
|
|| resourcePath.equals("WEB-INF/web.xml") || resourcePath.equals("META-INF/web-fragment.xml")
|
||||||
|| resourcePath.equals("META-INF/eclipse.inf") || resourcePath.equals("META-INF/ECLIPSE_.SF")
|
|| resourcePath.equals("META-INF/eclipse.inf") || resourcePath.equals("META-INF/ECLIPSE_.SF")
|
||||||
|| resourcePath.equals("META-INF/ECLIPSE_.RSA") || resourcePath.equals("META-INF/BC2048KE.DSA")
|
|| resourcePath.equals("META-INF/ECLIPSE_.RSA") || resourcePath.equals("META-INF/BC2048KE.DSA")
|
||||||
|
|||||||
Reference in New Issue
Block a user