diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MojaloopStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MojaloopStepDef.java index 32dbf07d6..951211b60 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MojaloopStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MojaloopStepDef.java @@ -4,11 +4,14 @@ import static io.restassured.config.EncoderConfig.encoderConfig; import io.cucumber.core.internal.com.fasterxml.jackson.core.JsonProcessingException; +import io.cucumber.java.Before; +import io.cucumber.java.Scenario; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.restassured.RestAssured; import io.restassured.builder.ResponseSpecBuilder; import io.restassured.specification.RequestSpecification; +import org.junit.Assume; import org.mifos.integrationtest.common.Utils; import org.mifos.integrationtest.config.MojaloopConfig; import org.springframework.beans.factory.annotation.Autowired; @@ -100,4 +103,30 @@ public void mojaloopSetup() throws JsonProcessingException { } } + @Before("@ConditionalSkip") + public void beforeScenario(Scenario scenario) { + boolean shouldSkip = checkCondition(); + if (!shouldSkip) { + Assume.assumeTrue("Skipping scenario: " + scenario.getName(), false); + } + } + + private boolean checkCondition() { + RequestSpecification requestSpec = Utils.getDefaultSpec(); + String endpoint = mojaloopConfig.mojaloopHubAccount; + + String mojaloopBaseUrl = mojaloopConfig.mojaloopBaseurl; + + try { + int statusCode = RestAssured.given(requestSpec).baseUri(mojaloopBaseUrl).when().get("/actuator").then().extract().statusCode(); + + return statusCode == 200; + } catch (Exception e) { + + logger.error(e.getMessage()); + return false; + } + + } + } diff --git a/src/test/java/resources/mojaloop.feature b/src/test/java/resources/mojaloop.feature index 3cae45cf8..0d2f57b16 100644 --- a/src/test/java/resources/mojaloop.feature +++ b/src/test/java/resources/mojaloop.feature @@ -1,6 +1,6 @@ @gov @ext Feature: Mojaloop test - + @ConditionalSkip Scenario: ML connector partial payee party lookup test Given I am setting up Mojaloop Given I have Fineract-Platform-TenantId for "payee" @@ -17,7 +17,7 @@ Feature: Mojaloop test # Then I will sleep for 5000 millisecond Then I should be able to verify the callback for lookup Then I can stop mock server - + @ConditionalSkip Scenario: ML connector partial payee quotation test Given I am setting up Mojaloop Given I have Fineract-Platform-TenantId for "payee" @@ -34,7 +34,7 @@ Feature: Mojaloop test # Then I will sleep for 5000 millisecond Then I should be able to verify the callback for quotation Then I can stop mock server - + @ConditionalSkip Scenario: ML connector partial payee transfer test Given I am setting up Mojaloop Given I have Fineract-Platform-TenantId for "payee" @@ -55,7 +55,7 @@ Feature: Mojaloop test # Then I will sleep for 5000 millisecond Then I should be able to verify the callback for transfer Then I can stop mock server - + @ConditionalSkip Scenario: Payer Fund Transfer Flow test Given I am setting up Mojaloop Given I have Fineract-Platform-TenantId for "payer" @@ -100,7 +100,7 @@ Feature: Mojaloop test Then I assert "payer" balance to be 11 Then I assert "payee" balance to be 11 - + @ConditionalSkip Scenario: Bulk Transfer with Mojaloop Given I am setting up Mojaloop When I create and setup a "payer" with account balance of 12