From c5640da335389f6fa7796f440ea273c588c37467 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Sun, 3 Mar 2024 11:00:50 +0530 Subject: [PATCH 01/48] [PHEE-534] enable parallel execution --- .circleci/config.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index aa89477fd..fd7182f47 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -200,6 +200,7 @@ jobs: test-chart-gov: docker: - image: cimg/openjdk:17.0.0-node + parallelism: 2 steps: - checkout #- run: git clone https://github.com/openmf/ph-ee-integration-test @@ -237,6 +238,7 @@ jobs: test-chart-ams: docker: - image: cimg/openjdk:17.0.0 + parallelism: 2 steps: - checkout #- run: git clone https://github.com/openmf/ph-ee-integration-test @@ -327,7 +329,7 @@ workflows: - Ngrok - test-chart-gov: requires: - - test-chart-ams + - deploying-bpmns context: - AWS - Helm From be2b3ebc3b4b5cfdcc8be411f58dba9a3ff3f6d6 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Mon, 4 Mar 2024 18:24:43 +0530 Subject: [PATCH 02/48] Updated the test runner class to run with multi threads --- .circleci/config.yml | 2 +- build.gradle | 62 +++++++------------ .../org/mifos/integrationtest/TestRunner.java | 37 +++++++++-- .../batch_demo_csv/batchTransactionGsma.csv | 2 +- 4 files changed, 56 insertions(+), 47 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fd7182f47..4dd489a1e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -266,7 +266,7 @@ jobs: export CALLBACK_URL="https://$NGROK_PUBLIC_URL" echo -n "Public url ." echo $CALLBACK_URL - ./gradlew test -Dcucumber.filter.tags="@amsIntegration" + ./gradlew test -Dcucumber.tags="@amsIntegration" echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: diff --git a/build.gradle b/build.gradle index bf35aa029..15db6e261 100644 --- a/build.gradle +++ b/build.gradle @@ -171,50 +171,32 @@ dependencies { implementation 'com.opencsv:opencsv:5.5.2' testImplementation 'org.apache.commons:commons-csv:1.5' testImplementation 'org.awaitility:awaitility:4.2.0' -} + implementation 'io.github.prashant-ramcharan:courgette-jvm:6.12.0' -tasks.named('test') { - useJUnitPlatform() } +//tasks.named('test') { +// useJUnitPlatform() +//} -configurations { - cucumberRuntime { - extendsFrom testImplementation - } - testlogger { - // pick a theme - mocha, standard, plain, mocha-parallel, standard-parallel or plain-parallel - theme 'mocha' - showSkipped false - showStackTraces true - } -} +// +//configurations { +// cucumberRuntime { +// extendsFrom testImplementation +// } +// testlogger { +// // pick a theme - mocha, standard, plain, mocha-parallel, standard-parallel or plain-parallel +// theme 'mocha' +// showSkipped false +// showStackTraces true +// } +//} -test { - systemProperty "cucumber.filter.tags", System.getProperty("cucumber.filter.tags") - systemProperty "cucumber.filter.name", System.getProperty("cucumber.filter.name") +tasks.withType(Test) { + systemProperties = System.getProperties() } -task cucumberCli() { - dependsOn assemble, testClasses - doLast { - javaexec { - main = "io.cucumber.core.cli.Main" - classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output - args = [ - '--plugin', - 'html:cucumber-report', - '--plugin', - 'json:cucumber.json', - '--plugin', - 'pretty', - '--plugin', - 'html:build/cucumber-report.html', - '--plugin', - 'json:build/cucumber-report.json', - '--glue', - 'org.mifos.integrationtest.cucumber', - 'src/test/java/resources' - ] - } - } + +task regressionSuite(type: Test) { + include '**/TestRunner.class' + outputs.upToDateWhen { false } } diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index d6cbae096..43eabf1f4 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -1,11 +1,38 @@ package org.mifos.integrationtest; +import courgette.api.CourgetteOptions; +import courgette.api.CourgetteRunLevel; +import courgette.api.CourgetteTestOutput; +import courgette.api.CucumberOptions; +import courgette.api.junit.Courgette; import io.cucumber.junit.Cucumber; -import io.cucumber.junit.CucumberOptions; import org.junit.runner.RunWith; -@RunWith(Cucumber.class) -@CucumberOptions(features = { "src/test/java/resources" }, glue = { "org.mifos.integrationtest.cucumber" }, plugin = { - "html:cucumber-report", "json:cucumber.json", "pretty", "html:build/cucumber-report.html", "json:build/cucumber-report.json", - "junit:build/cucumber.xml" }) +//@RunWith(Cucumber.class) +//@CucumberOptions(features = { "src/test/java/resources" }, glue = { "org.mifos.integrationtest.cucumber" }, plugin = { +// "html:cucumber-report", "json:cucumber.json", "pretty", "html:build/cucumber-report.html", "json:build/cucumber-report.json", +// "junit:build/cucumber.xml" }) + +@RunWith(Courgette.class) +@CourgetteOptions( + threads = 3, + runLevel = CourgetteRunLevel.FEATURE, + rerunFailedScenarios = false, +// rerunAttempts = , + testOutput = CourgetteTestOutput.CONSOLE, + + reportTitle = "Courgette-JVM Example", + reportTargetDir = "build", + environmentInfo = "browser=chrome; git_branch=master", + cucumberOptions = @CucumberOptions ( + features = "src/test/java/resources", + glue = "org.mifos.integrationtest.cucumber", + tags = "@gov", + publish = true, + plugin = { + "pretty", + "json:build/cucumber-report/cucumber.json", + "html:build/cucumber-report/cucumber.html", + "junit:build/cucumber-report/cucumber.xml"} + )) public class TestRunner {} diff --git a/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv b/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv index 951c21f5f..f37856808 100644 --- a/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv +++ b/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv @@ -1,4 +1,4 @@ id,request_id,payment_mode,payer_identifier_type,payer_identifier,payee_identifier_type,payee_identifier,amount,currency,note 0,b82610db-769e-45b3-a473-e35c4a8ffbfe,gsma,msisdn,164,msisdn,201,10,USD,Test Payee Payment 1,1e8a9b02-894b-4db2-9966-ad28427c4f33,gsma,msisdn,165,msisdn,202,5,USD,Test Payee Payment -2,a23b0448-97c7-46a8-a525-7c80bded8f09,gsma,msisdn,166,msisdn,203,1,USD,Test Payee Payment \ No newline at end of file +2,a23b0448-97c7-46a8-a525-7c80bded8f09,gsma,msisdn,166,msisdn,203,1,USD,Test Payee Payment From 1be96140db5ea898fa1a6819a4c7df7ed3f81931 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Mon, 4 Mar 2024 18:31:30 +0530 Subject: [PATCH 03/48] Reverted the workflow --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4dd489a1e..0af93531b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -329,7 +329,7 @@ workflows: - Ngrok - test-chart-gov: requires: - - deploying-bpmns + - test-chart-ams context: - AWS - Helm From 330f7f3da85d2f04d7c14b0cff3b040d81736cd0 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Mon, 4 Mar 2024 18:36:21 +0530 Subject: [PATCH 04/48] Resolved checkstyle errors --- build.gradle | 1 - .../org/mifos/integrationtest/TestRunner.java | 25 ++++--------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/build.gradle b/build.gradle index 15db6e261..cdda1bde6 100644 --- a/build.gradle +++ b/build.gradle @@ -172,7 +172,6 @@ dependencies { testImplementation 'org.apache.commons:commons-csv:1.5' testImplementation 'org.awaitility:awaitility:4.2.0' implementation 'io.github.prashant-ramcharan:courgette-jvm:6.12.0' - } //tasks.named('test') { diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index 43eabf1f4..19f97432c 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -5,7 +5,6 @@ import courgette.api.CourgetteTestOutput; import courgette.api.CucumberOptions; import courgette.api.junit.Courgette; -import io.cucumber.junit.Cucumber; import org.junit.runner.RunWith; //@RunWith(Cucumber.class) @@ -14,25 +13,11 @@ // "junit:build/cucumber.xml" }) @RunWith(Courgette.class) -@CourgetteOptions( - threads = 3, - runLevel = CourgetteRunLevel.FEATURE, - rerunFailedScenarios = false, -// rerunAttempts = , +@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, + // rerunAttempts = , testOutput = CourgetteTestOutput.CONSOLE, - reportTitle = "Courgette-JVM Example", - reportTargetDir = "build", - environmentInfo = "browser=chrome; git_branch=master", - cucumberOptions = @CucumberOptions ( - features = "src/test/java/resources", - glue = "org.mifos.integrationtest.cucumber", - tags = "@gov", - publish = true, - plugin = { - "pretty", - "json:build/cucumber-report/cucumber.json", - "html:build/cucumber-report/cucumber.html", - "junit:build/cucumber-report/cucumber.xml"} - )) + reportTitle = "Courgette-JVM Example", reportTargetDir = "build", environmentInfo = "browser=chrome; git_branch=master", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { + "pretty", "json:build/cucumber-report/cucumber.json", "html:build/cucumber-report/cucumber.html", + "junit:build/cucumber-report/cucumber.xml" })) public class TestRunner {} From 21680421e8ee165d49c80f1afce655f74fd61c6a Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Mon, 4 Mar 2024 19:07:33 +0530 Subject: [PATCH 05/48] updated the docker image --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0af93531b..02ad6c7e4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -156,7 +156,7 @@ jobs: NAMESPACE: paymenthub steps: - setup_remote_docker: - version: 20.10.14 + version: 20.10.24 - kubernetes/install-kubectl - run: git clone https://github.com/openmf/ph-ee-env-labs - aws-eks/update-kubeconfig-with-authenticator: From f9d959a13dff18d75407eee0742965fd04798b82 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Mon, 4 Mar 2024 22:29:45 +0530 Subject: [PATCH 06/48] removed the unwanted paralellism from the circle CI config --- .circleci/config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 02ad6c7e4..4b2accd9c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -200,7 +200,6 @@ jobs: test-chart-gov: docker: - image: cimg/openjdk:17.0.0-node - parallelism: 2 steps: - checkout #- run: git clone https://github.com/openmf/ph-ee-integration-test @@ -238,7 +237,6 @@ jobs: test-chart-ams: docker: - image: cimg/openjdk:17.0.0 - parallelism: 2 steps: - checkout #- run: git clone https://github.com/openmf/ph-ee-integration-test From fb2524f4d56e5c54fff4206c1ce29d823d455cbf Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Tue, 5 Mar 2024 11:28:54 +0530 Subject: [PATCH 07/48] Updating the result path for multi threads --- .circleci/config.yml | 4 ++-- build.gradle | 2 +- .../java/resources/batch_demo_csv/batchTransactionGsma.csv | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4b2accd9c..06335d43c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -231,7 +231,7 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/test-results/test/TEST-org.mifos.integrationtest.TestRunner.xml + path: build/test-results/parallelRun/TEST-org.mifos.integrationtest.TestRunner.xml - store_artifacts: path: build/test-results test-chart-ams: @@ -268,7 +268,7 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/test-results/test/TEST-org.mifos.integrationtest.TestRunner.xml + path: build/test-results/parallelRun/TEST-org.mifos.integrationtest.TestRunner.xml - store_artifacts: path: build/test-results workflows: diff --git a/build.gradle b/build.gradle index cdda1bde6..20572a67b 100644 --- a/build.gradle +++ b/build.gradle @@ -195,7 +195,7 @@ tasks.withType(Test) { systemProperties = System.getProperties() } -task regressionSuite(type: Test) { +task parallelRun(type: Test) { include '**/TestRunner.class' outputs.upToDateWhen { false } } diff --git a/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv b/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv index f37856808..f06e11281 100644 --- a/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv +++ b/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv @@ -1,4 +1,4 @@ id,request_id,payment_mode,payer_identifier_type,payer_identifier,payee_identifier_type,payee_identifier,amount,currency,note -0,b82610db-769e-45b3-a473-e35c4a8ffbfe,gsma,msisdn,164,msisdn,201,10,USD,Test Payee Payment -1,1e8a9b02-894b-4db2-9966-ad28427c4f33,gsma,msisdn,165,msisdn,202,5,USD,Test Payee Payment -2,a23b0448-97c7-46a8-a525-7c80bded8f09,gsma,msisdn,166,msisdn,203,1,USD,Test Payee Payment +0,8e2869fb-3244-4c73-9921-c2c34995279a,gsma,msisdn,400,msisdn,418,10,USD,Test Payee Payment +1,ec564f92-4a77-4bfe-b7ee-ce6cd702d526,gsma,msisdn,401,msisdn,419,5,USD,Test Payee Payment +2,a5b23868-d64a-4104-bfb7-32cbe6b652df,gsma,msisdn,402,msisdn,420,1,USD,Test Payee Payment \ No newline at end of file From 50f1934470a22aad3108841cd00689214dd14b95 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Wed, 6 Mar 2024 14:21:36 +0530 Subject: [PATCH 08/48] Testing the new path and updated the readme with new changes --- README.md | 66 +++++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 91ce83b07..4f8fd47ba 100644 --- a/README.md +++ b/README.md @@ -73,54 +73,42 @@ Now we can run respective feature file directly form the intellij. ## Adding runner configuration Below java class will make sure to run cucumber test using JUnit test command. -Where the `glue` property is for defining the package which contains the step definitions, `feature` refers to the path where feature file is located and `plugin` is for providing different plugin configuration supported by cucumber. +Where the `glue` property is for defining the package which contains the step definitions and `plugin` is for providing different plugin configuration supported by cucumber. ```java -@RunWith(Cucumber.class) -@CucumberOptions( - features = {"src/test/java/resources"}, - glue = {"org.mifos.integrationtest.cucumber"}, - plugin = { - "html:cucumber-report", - "json:cucumber.json", - "pretty", - "html:build/cucumber-report.html", - "json:build/cucumber-report.json" -## Adding gradle configuration -Adding gradle configuration will allow us to run all the cucumber feature file at using using a CLI. -```gradle -configurations { - cucumberRuntime { - extendsFrom testImplementation - } -} +@RunWith(Courgette.class) +@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, + testOutput = CourgetteTestOutput.CONSOLE, + + reportTitle = "Courgette-JVM Example", + reportTargetDir = "build", + environmentInfo = "browser=chrome; git_branch=master", + cucumberOptions = @CucumberOptions(features = "src/test/java/resources", + glue = "org.mifos.integrationtest.cucumber", + tags = "@gov", + publish = true, + plugin = { + "pretty", "json:build/cucumber-report/cucumber.json", + "html:build/cucumber-report/cucumber.html", + "junit:build/cucumber-report/cucumber.xml" + })) -task cucumberCli() { - dependsOn assemble, testClasses - doLast { - javaexec { - main = "io.cucumber.core.cli.Main" - classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output - args = [ - '--plugin', 'pretty', - '--plugin', 'html:target/cucumber-report.html', - '--glue', 'org.mifos.connector.slcb.cucumber', - 'src/test/java/resources'] - } -) -public class TestRunner { +## Adding gradle configuration +Adding gradle configuration will allow us to run all the cucumber feature file at using a CLI. + +tasks.withType(Test) { + systemProperties = System.getProperties() } -``` -Adding below configuration will allow us to wire the CLI arguments be passed in the actual runner configuration while running the cucumber test using JUnit. -```groovy -test { - systemProperty "cucumber.filter.tags", System.getProperty("cucumber.filter.tags") + +task parallelRun(type: Test) { + include '**/TestRunner.class' + outputs.upToDateWhen { false } } ``` ## Running an integration test Use below command to execute the integration test. ```shell -./gradlew test -Dcucumber.filter.tags="" +./gradlew test -Dcucumber.tags="" ``` Where `` has to be replaced with valid tag, for example if you are willing to run test cases related to g2p scenario then pass the tag `@gov`. If `-Dcucumber.filter.tags` flag is omitted then all the test cases would be triggered independent of the tag. ```shell From 3f1265042986a25cb17d8f0feaa4e60b4a7696e0 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Wed, 6 Mar 2024 14:38:06 +0530 Subject: [PATCH 09/48] Testing with new path for results --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 06335d43c..4b2accd9c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -231,7 +231,7 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/test-results/parallelRun/TEST-org.mifos.integrationtest.TestRunner.xml + path: build/test-results/test/TEST-org.mifos.integrationtest.TestRunner.xml - store_artifacts: path: build/test-results test-chart-ams: @@ -268,7 +268,7 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/test-results/parallelRun/TEST-org.mifos.integrationtest.TestRunner.xml + path: build/test-results/test/TEST-org.mifos.integrationtest.TestRunner.xml - store_artifacts: path: build/test-results workflows: From 49c84f9ca36a0b09e7a46aa29b6952415e2dab61 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Wed, 6 Mar 2024 14:50:07 +0530 Subject: [PATCH 10/48] updated the path with courgette --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4b2accd9c..e29928bdf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -231,7 +231,7 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/test-results/test/TEST-org.mifos.integrationtest.TestRunner.xml + path: build/test-results/test/TEST-courgette.api.junit.Courgette.xml - store_artifacts: path: build/test-results test-chart-ams: @@ -268,7 +268,7 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/test-results/test/TEST-org.mifos.integrationtest.TestRunner.xml + path: build/test-results/test/TEST-courgette.api.junit.Courgette.xml - store_artifacts: path: build/test-results workflows: From 86ec30896d9afb1d3371e2528394c5cef3dda844 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Wed, 6 Mar 2024 15:06:55 +0530 Subject: [PATCH 11/48] instead of running feature as run level running scenarios --- README.md | 20 +++++++++---------- .../org/mifos/integrationtest/TestRunner.java | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4f8fd47ba..279aea786 100644 --- a/README.md +++ b/README.md @@ -80,22 +80,22 @@ Where the `glue` property is for defining the package which contains the step de @CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, testOutput = CourgetteTestOutput.CONSOLE, - reportTitle = "Courgette-JVM Example", - reportTargetDir = "build", - environmentInfo = "browser=chrome; git_branch=master", - cucumberOptions = @CucumberOptions(features = "src/test/java/resources", - glue = "org.mifos.integrationtest.cucumber", - tags = "@gov", - publish = true, + reportTitle = "Courgette-JVM Example", + reportTargetDir = "build", + environmentInfo = "browser=chrome; git_branch=master", + cucumberOptions = @CucumberOptions(features = "src/test/java/resources", + glue = "org.mifos.integrationtest.cucumber", + tags = "@gov", + publish = true, plugin = { - "pretty", "json:build/cucumber-report/cucumber.json", + "pretty", "json:build/cucumber-report/cucumber.json", "html:build/cucumber-report/cucumber.html", - "junit:build/cucumber-report/cucumber.xml" + "junit:build/cucumber-report/cucumber.xml" })) ## Adding gradle configuration Adding gradle configuration will allow us to run all the cucumber feature file at using a CLI. - + tasks.withType(Test) { systemProperties = System.getProperties() } diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index 19f97432c..ac8124e70 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -13,7 +13,7 @@ // "junit:build/cucumber.xml" }) @RunWith(Courgette.class) -@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, +@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.SCENARIO, rerunFailedScenarios = false, // rerunAttempts = , testOutput = CourgetteTestOutput.CONSOLE, From a714de51f4e72284a430bbe88f22a48701653d97 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Wed, 6 Mar 2024 15:27:02 +0530 Subject: [PATCH 12/48] adding the new plugins for the run --- build.gradle | 24 +++++++++---------- .../org/mifos/integrationtest/TestRunner.java | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 20572a67b..860959ae9 100644 --- a/build.gradle +++ b/build.gradle @@ -178,18 +178,18 @@ dependencies { // useJUnitPlatform() //} -// -//configurations { -// cucumberRuntime { -// extendsFrom testImplementation -// } -// testlogger { -// // pick a theme - mocha, standard, plain, mocha-parallel, standard-parallel or plain-parallel -// theme 'mocha' -// showSkipped false -// showStackTraces true -// } -//} + +configurations { + cucumberRuntime { + extendsFrom testImplementation + } + testlogger { + // pick a theme - mocha, standard, plain, mocha-parallel, standard-parallel or plain-parallel + theme 'mocha' + showSkipped false + showStackTraces true + } +} tasks.withType(Test) { systemProperties = System.getProperties() diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index ac8124e70..61ce538af 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -18,6 +18,6 @@ testOutput = CourgetteTestOutput.CONSOLE, reportTitle = "Courgette-JVM Example", reportTargetDir = "build", environmentInfo = "browser=chrome; git_branch=master", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { - "pretty", "json:build/cucumber-report/cucumber.json", "html:build/cucumber-report/cucumber.html", - "junit:build/cucumber-report/cucumber.xml" })) + "html:cucumber-report", "json:cucumber.json", "pretty", "html:build/cucumber-report.html", + "json:build/cucumber-report.json", "junit:build/cucumber.xml" })) public class TestRunner {} From a8e5608479e148474b11029e0d5828453a493ab5 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Wed, 6 Mar 2024 16:04:27 +0530 Subject: [PATCH 13/48] updated the test results --- build.gradle | 11 ----------- .../java/org/mifos/integrationtest/TestRunner.java | 3 +-- .../resources/batch_demo_csv/batchTransactionGsma.csv | 2 +- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 860959ae9..b23a4a1c4 100644 --- a/build.gradle +++ b/build.gradle @@ -179,17 +179,6 @@ dependencies { //} -configurations { - cucumberRuntime { - extendsFrom testImplementation - } - testlogger { - // pick a theme - mocha, standard, plain, mocha-parallel, standard-parallel or plain-parallel - theme 'mocha' - showSkipped false - showStackTraces true - } -} tasks.withType(Test) { systemProperties = System.getProperties() diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index 61ce538af..fd72909d8 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -14,10 +14,9 @@ @RunWith(Courgette.class) @CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.SCENARIO, rerunFailedScenarios = false, - // rerunAttempts = , testOutput = CourgetteTestOutput.CONSOLE, - reportTitle = "Courgette-JVM Example", reportTargetDir = "build", environmentInfo = "browser=chrome; git_branch=master", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { + reportTitle = "Courgette-JVM Example", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { "html:cucumber-report", "json:cucumber.json", "pretty", "html:build/cucumber-report.html", "json:build/cucumber-report.json", "junit:build/cucumber.xml" })) public class TestRunner {} diff --git a/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv b/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv index f06e11281..c2cc81a31 100644 --- a/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv +++ b/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv @@ -1,4 +1,4 @@ id,request_id,payment_mode,payer_identifier_type,payer_identifier,payee_identifier_type,payee_identifier,amount,currency,note 0,8e2869fb-3244-4c73-9921-c2c34995279a,gsma,msisdn,400,msisdn,418,10,USD,Test Payee Payment 1,ec564f92-4a77-4bfe-b7ee-ce6cd702d526,gsma,msisdn,401,msisdn,419,5,USD,Test Payee Payment -2,a5b23868-d64a-4104-bfb7-32cbe6b652df,gsma,msisdn,402,msisdn,420,1,USD,Test Payee Payment \ No newline at end of file +2,a5b23868-d64a-4104-bfb7-32cbe6b652df,gsma,msisdn,402,msisdn,420,1,USD,Test Payee Payment From d3bc990a1d52c642f16ace764686bee43aaf926b Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Wed, 6 Mar 2024 16:59:08 +0530 Subject: [PATCH 14/48] Updated the path and fetching report with info --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e29928bdf..4497c95cf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -231,9 +231,9 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/test-results/test/TEST-courgette.api.junit.Courgette.xml + path: build/cucumber-report/cucumber.xml - store_artifacts: - path: build/test-results + path: build/cucumber-report test-chart-ams: docker: - image: cimg/openjdk:17.0.0 @@ -268,9 +268,9 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/test-results/test/TEST-courgette.api.junit.Courgette.xml + path: build/cucumber-report/cucumber.xml - store_artifacts: - path: build/test-results + path: build/cucumber-report workflows: deploy: jobs: From 8c0be04582f37bfbf1a7e3deac9a5103f900a6f9 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Wed, 6 Mar 2024 17:28:33 +0530 Subject: [PATCH 15/48] Trying to host html for test results --- .circleci/config.yml | 4 ++-- .../java/resources/batch_demo_csv/batchTransactionGsma.csv | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4497c95cf..c0fcfdb1a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -231,7 +231,7 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/cucumber-report/cucumber.xml + path: build/cucumber-report/index.html - store_artifacts: path: build/cucumber-report test-chart-ams: @@ -268,7 +268,7 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/cucumber-report/cucumber.xml + path: build/cucumber-report/index.html - store_artifacts: path: build/cucumber-report workflows: diff --git a/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv b/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv index c2cc81a31..92c3b3126 100644 --- a/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv +++ b/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv @@ -1,4 +1,4 @@ id,request_id,payment_mode,payer_identifier_type,payer_identifier,payee_identifier_type,payee_identifier,amount,currency,note -0,8e2869fb-3244-4c73-9921-c2c34995279a,gsma,msisdn,400,msisdn,418,10,USD,Test Payee Payment -1,ec564f92-4a77-4bfe-b7ee-ce6cd702d526,gsma,msisdn,401,msisdn,419,5,USD,Test Payee Payment -2,a5b23868-d64a-4104-bfb7-32cbe6b652df,gsma,msisdn,402,msisdn,420,1,USD,Test Payee Payment +0,6f2581f3-6fb6-419c-b55d-118cf85ebc84,gsma,msisdn,739,msisdn,714,10,USD,Test Payee Payment +1,b0500c84-4448-4c14-bfec-825bdabf952e,gsma,msisdn,742,msisdn,716,5,USD,Test Payee Payment +2,339fcfce-4ddc-42f0-bcc9-3e75452b6aeb,gsma,msisdn,743,msisdn,717,1,USD,Test Payee Payment \ No newline at end of file From bd85c972204cb2b6c1c97278abd67ef8fff2ccb2 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Wed, 6 Mar 2024 17:46:36 +0530 Subject: [PATCH 16/48] Trying to host html for test results --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c0fcfdb1a..c46d0a962 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -231,9 +231,9 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/cucumber-report/index.html + path: build/courgette-report/index.html - store_artifacts: - path: build/cucumber-report + path: build/courgette-report test-chart-ams: docker: - image: cimg/openjdk:17.0.0 @@ -268,9 +268,9 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/cucumber-report/index.html + path: build/courgette-report/index.html - store_artifacts: - path: build/cucumber-report + path: build/courgette-report workflows: deploy: jobs: From 86375860889aa62b5baf1d4f7506b05d0733a684 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Wed, 6 Mar 2024 18:28:16 +0530 Subject: [PATCH 17/48] Updated the results path and artifacts --- .circleci/config.yml | 4 ++-- src/test/java/org/mifos/integrationtest/TestRunner.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c46d0a962..f61b2e25d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -231,7 +231,7 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/courgette-report/index.html + path: build/test-results/test/TEST-courgette.api.junit.Courgette.xml - store_artifacts: path: build/courgette-report test-chart-ams: @@ -268,7 +268,7 @@ jobs: echo -n "Test execution is completed, kill ngrok" pkill ngrok - store_test_results: - path: build/courgette-report/index.html + path: build/test-results/test/TEST-courgette.api.junit.Courgette.xml - store_artifacts: path: build/courgette-report workflows: diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index fd72909d8..482a20c08 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -16,7 +16,7 @@ @CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.SCENARIO, rerunFailedScenarios = false, testOutput = CourgetteTestOutput.CONSOLE, - reportTitle = "Courgette-JVM Example", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { + reportTitle = "Paymenthub Test results", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { "html:cucumber-report", "json:cucumber.json", "pretty", "html:build/cucumber-report.html", "json:build/cucumber-report.json", "junit:build/cucumber.xml" })) public class TestRunner {} From 4b73b6f040f6a138eb15ec48808db6e8dc2870b2 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Wed, 6 Mar 2024 19:04:05 +0530 Subject: [PATCH 18/48] Removed the unnescessary sleep for the AMS test cases --- src/main/resources/application.yaml | 2 +- src/test/java/resources/gsmaTxn.feature | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 2df866732..34cc7ebd6 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -91,7 +91,7 @@ savings: mock-server: port: 53013 -callback_url: ${CALLBACK_URL:localhost} +callback_url: https://89a4-2406-7400-51-3b8c-cc4-1deb-2402-7031.ngrok-free.app json-web-signature: privateKey: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC07fxdEQlsvWvggBgrork401cdyZ9MqV6FF/RgX6+Om23gP/rME5sE5//OoG61KU3dEj9phcHH845TuyNEyc4Vhqxe1gzl4VIZkOj+/2qxYvCsP1Sv3twTs+fDfFv5NA1ZXqiswTlgjR2Lpf1tevFQEOzB9WYvH/Bu9kgr2AlHMPV6+b7gcJij/7W1hndiCk2ahbi7oXjjODF4yEU9yNAhopibe4zzMX+FO4eFYpUmrjS5wvv6aAanfoeIMTwhF81Gj9V3rHf4UsD3VEx773q7GPuXlZSLyiNrUCdvxITh+dW8Y9ICuCTy3bFbp1/HzoPdzkkUlzPNKLlLiV2w4EcxAgMBAAECggEAMjqHfwbFyQxlMHQfQa3xIdd6LejVcqDqfqSB0Wd/A2YfAMyCQbmHpbsKh0B+u4h191OjixX5EBuLfa9MQUKNFejHXaSq+/6rnjFenbwm0IwZKJiEWDbUfhvJ0blqhypuMktXJG6YETfb5fL1AjnJWGL6d3Y7IgYJ56QzsQhOuxZidSqw468xc4sIF0CoTeJdrSC2yDCVuVlLNifm/2SXBJD8mgc1WCz0rkJhvvpW4k5G9rRSkS5f0013ZNfsfiDXoqiKkafoYNEbk7TZQNInqSuONm/UECn5GLm6IXdXSGfm1O2Lt0Kk7uxW/3W00mIPeZD+hiOObheRm/2HoOEKiQKBgQDreVFQihXAEDviIB2s6fphvPcMw/IonE8tX565i3303ubQMDIyZmsi3apN5pqSjm1TKq1KIgY2D4vYTu6vO5x9MhEO2CCZWNwC+awrIYa32FwiT8D8eZ9g+DJ4/IwXyz1fG38RCz/eIsJ0NsS9z8RKBIbfMmM+WnXRez3Fq+cbRwKBgQDEs35qXThbbFUYo1QkO0vIo85iczu9NllRxo1nAqQkfu1oTYQQobxcGk/aZk0B02r9kt2eob8zfG+X3LadIhQ0/LalnGNKI9jWLkdW4dxi7xMU99MYc3NRXmR49xGxgOVkLzKyGMisUvkTnE5v/S1nhu5uFr3JPkWcCScLOTjVxwKBgHNWsDq3+GFkUkC3pHF/BhJ7wbLyA5pavfmmnZOavO6FhB8zjFLdkdq5IuMXcl0ZAHm9LLZkJhCy2rfwKb+RflxgerR/rrAOM24Np4RU3q0MgEyaLhg85pFT4T0bzu8UsRH14O6TSQxgkEjmTsX+j9IFl56aCryPCKi8Kgy53/CfAoGAdV2kUFLPDb3WCJ1r1zKKRW1398ZKHtwO73xJYu1wg1Y40cNuyX23pj0M6IOh7zT24dZ/5ecc7tuQukw3qgprhDJFyQtHMzWwbBuw9WZO2blM6XX1vuEkLajkykihhggi12RSG3IuSqQ3ejwJkUi/jsYz/fwTwcAmSLQtV8UM5IECgYEAh4h1EkMx3NXzVFmLsb4QLMXw8+Rnn9oG+NGObldQ+nmknUPu7iz5kl9lTJy+jWtqHlHL8ZtV1cZZSZnFxX5WQH5/lcz/UD+GqWoSlWuTU34PPTJqLKSYgkoOJQDEZVMVphLySS9tuo+K/h10lRS1r9KDm3RZASa1JnnWopBZIz4=" diff --git a/src/test/java/resources/gsmaTxn.feature b/src/test/java/resources/gsmaTxn.feature index 9b12e4417..e4f1d17cd 100644 --- a/src/test/java/resources/gsmaTxn.feature +++ b/src/test/java/resources/gsmaTxn.feature @@ -18,7 +18,6 @@ Feature: GSMA Transfer API Test for Account Identifier Worker # Savings account deposit using BPMN workflow. When I have amsName as "mifos" and acccountHoldingInstitutionId as "wakanda" and amount as 11 Then I call the channel connector API for savings account with expected status of 200 and stub "/depositCallback" - Then I will sleep for 3000 millisecond Then I should be able to verify that the "POST" method to "/depositCallback" endpoint received 1 request @@ -32,7 +31,6 @@ Feature: GSMA Transfer API Test for Account Identifier Worker # Loan account repayment using BPMN workflow. When I have amsName as "mifos" and acccountHoldingInstitutionId as "wakanda" and amount as 11 Then I call the channel connector API for loan account with expected status of 200 and stub "/loanCallback" - Then I will sleep for 3000 millisecond Then I should be able to verify that the "POST" method to "/loanCallback" endpoint received 1 request # AMS Mock API call integration test From 4ba683af63bea9467574ec739494d3588d00cb70 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Wed, 6 Mar 2024 19:06:33 +0530 Subject: [PATCH 19/48] Reverted the unnescessary changes --- src/main/resources/application.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 34cc7ebd6..2df866732 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -91,7 +91,7 @@ savings: mock-server: port: 53013 -callback_url: https://89a4-2406-7400-51-3b8c-cc4-1deb-2402-7031.ngrok-free.app +callback_url: ${CALLBACK_URL:localhost} json-web-signature: privateKey: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC07fxdEQlsvWvggBgrork401cdyZ9MqV6FF/RgX6+Om23gP/rME5sE5//OoG61KU3dEj9phcHH845TuyNEyc4Vhqxe1gzl4VIZkOj+/2qxYvCsP1Sv3twTs+fDfFv5NA1ZXqiswTlgjR2Lpf1tevFQEOzB9WYvH/Bu9kgr2AlHMPV6+b7gcJij/7W1hndiCk2ahbi7oXjjODF4yEU9yNAhopibe4zzMX+FO4eFYpUmrjS5wvv6aAanfoeIMTwhF81Gj9V3rHf4UsD3VEx773q7GPuXlZSLyiNrUCdvxITh+dW8Y9ICuCTy3bFbp1/HzoPdzkkUlzPNKLlLiV2w4EcxAgMBAAECggEAMjqHfwbFyQxlMHQfQa3xIdd6LejVcqDqfqSB0Wd/A2YfAMyCQbmHpbsKh0B+u4h191OjixX5EBuLfa9MQUKNFejHXaSq+/6rnjFenbwm0IwZKJiEWDbUfhvJ0blqhypuMktXJG6YETfb5fL1AjnJWGL6d3Y7IgYJ56QzsQhOuxZidSqw468xc4sIF0CoTeJdrSC2yDCVuVlLNifm/2SXBJD8mgc1WCz0rkJhvvpW4k5G9rRSkS5f0013ZNfsfiDXoqiKkafoYNEbk7TZQNInqSuONm/UECn5GLm6IXdXSGfm1O2Lt0Kk7uxW/3W00mIPeZD+hiOObheRm/2HoOEKiQKBgQDreVFQihXAEDviIB2s6fphvPcMw/IonE8tX565i3303ubQMDIyZmsi3apN5pqSjm1TKq1KIgY2D4vYTu6vO5x9MhEO2CCZWNwC+awrIYa32FwiT8D8eZ9g+DJ4/IwXyz1fG38RCz/eIsJ0NsS9z8RKBIbfMmM+WnXRez3Fq+cbRwKBgQDEs35qXThbbFUYo1QkO0vIo85iczu9NllRxo1nAqQkfu1oTYQQobxcGk/aZk0B02r9kt2eob8zfG+X3LadIhQ0/LalnGNKI9jWLkdW4dxi7xMU99MYc3NRXmR49xGxgOVkLzKyGMisUvkTnE5v/S1nhu5uFr3JPkWcCScLOTjVxwKBgHNWsDq3+GFkUkC3pHF/BhJ7wbLyA5pavfmmnZOavO6FhB8zjFLdkdq5IuMXcl0ZAHm9LLZkJhCy2rfwKb+RflxgerR/rrAOM24Np4RU3q0MgEyaLhg85pFT4T0bzu8UsRH14O6TSQxgkEjmTsX+j9IFl56aCryPCKi8Kgy53/CfAoGAdV2kUFLPDb3WCJ1r1zKKRW1398ZKHtwO73xJYu1wg1Y40cNuyX23pj0M6IOh7zT24dZ/5ecc7tuQukw3qgprhDJFyQtHMzWwbBuw9WZO2blM6XX1vuEkLajkykihhggi12RSG3IuSqQ3ejwJkUi/jsYz/fwTwcAmSLQtV8UM5IECgYEAh4h1EkMx3NXzVFmLsb4QLMXw8+Rnn9oG+NGObldQ+nmknUPu7iz5kl9lTJy+jWtqHlHL8ZtV1cZZSZnFxX5WQH5/lcz/UD+GqWoSlWuTU34PPTJqLKSYgkoOJQDEZVMVphLySS9tuo+K/h10lRS1r9KDm3RZASa1JnnWopBZIz4=" From 3242921a2171661e61c5f3270a56b2c07808d227 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Fri, 8 Mar 2024 12:12:33 +0530 Subject: [PATCH 20/48] Updated the run leavel from runner --- src/main/resources/application.yaml | 2 +- src/test/java/org/mifos/integrationtest/TestRunner.java | 2 +- .../java/resources/batch_demo_csv/batchTransactionGsma.csv | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 2df866732..13ddd4686 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -91,7 +91,7 @@ savings: mock-server: port: 53013 -callback_url: ${CALLBACK_URL:localhost} +callback_url: https://52bf-2406-7400-51-aeac-8c53-583-8442-2b4.ngrok-free.app json-web-signature: privateKey: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC07fxdEQlsvWvggBgrork401cdyZ9MqV6FF/RgX6+Om23gP/rME5sE5//OoG61KU3dEj9phcHH845TuyNEyc4Vhqxe1gzl4VIZkOj+/2qxYvCsP1Sv3twTs+fDfFv5NA1ZXqiswTlgjR2Lpf1tevFQEOzB9WYvH/Bu9kgr2AlHMPV6+b7gcJij/7W1hndiCk2ahbi7oXjjODF4yEU9yNAhopibe4zzMX+FO4eFYpUmrjS5wvv6aAanfoeIMTwhF81Gj9V3rHf4UsD3VEx773q7GPuXlZSLyiNrUCdvxITh+dW8Y9ICuCTy3bFbp1/HzoPdzkkUlzPNKLlLiV2w4EcxAgMBAAECggEAMjqHfwbFyQxlMHQfQa3xIdd6LejVcqDqfqSB0Wd/A2YfAMyCQbmHpbsKh0B+u4h191OjixX5EBuLfa9MQUKNFejHXaSq+/6rnjFenbwm0IwZKJiEWDbUfhvJ0blqhypuMktXJG6YETfb5fL1AjnJWGL6d3Y7IgYJ56QzsQhOuxZidSqw468xc4sIF0CoTeJdrSC2yDCVuVlLNifm/2SXBJD8mgc1WCz0rkJhvvpW4k5G9rRSkS5f0013ZNfsfiDXoqiKkafoYNEbk7TZQNInqSuONm/UECn5GLm6IXdXSGfm1O2Lt0Kk7uxW/3W00mIPeZD+hiOObheRm/2HoOEKiQKBgQDreVFQihXAEDviIB2s6fphvPcMw/IonE8tX565i3303ubQMDIyZmsi3apN5pqSjm1TKq1KIgY2D4vYTu6vO5x9MhEO2CCZWNwC+awrIYa32FwiT8D8eZ9g+DJ4/IwXyz1fG38RCz/eIsJ0NsS9z8RKBIbfMmM+WnXRez3Fq+cbRwKBgQDEs35qXThbbFUYo1QkO0vIo85iczu9NllRxo1nAqQkfu1oTYQQobxcGk/aZk0B02r9kt2eob8zfG+X3LadIhQ0/LalnGNKI9jWLkdW4dxi7xMU99MYc3NRXmR49xGxgOVkLzKyGMisUvkTnE5v/S1nhu5uFr3JPkWcCScLOTjVxwKBgHNWsDq3+GFkUkC3pHF/BhJ7wbLyA5pavfmmnZOavO6FhB8zjFLdkdq5IuMXcl0ZAHm9LLZkJhCy2rfwKb+RflxgerR/rrAOM24Np4RU3q0MgEyaLhg85pFT4T0bzu8UsRH14O6TSQxgkEjmTsX+j9IFl56aCryPCKi8Kgy53/CfAoGAdV2kUFLPDb3WCJ1r1zKKRW1398ZKHtwO73xJYu1wg1Y40cNuyX23pj0M6IOh7zT24dZ/5ecc7tuQukw3qgprhDJFyQtHMzWwbBuw9WZO2blM6XX1vuEkLajkykihhggi12RSG3IuSqQ3ejwJkUi/jsYz/fwTwcAmSLQtV8UM5IECgYEAh4h1EkMx3NXzVFmLsb4QLMXw8+Rnn9oG+NGObldQ+nmknUPu7iz5kl9lTJy+jWtqHlHL8ZtV1cZZSZnFxX5WQH5/lcz/UD+GqWoSlWuTU34PPTJqLKSYgkoOJQDEZVMVphLySS9tuo+K/h10lRS1r9KDm3RZASa1JnnWopBZIz4=" diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index 482a20c08..d0043e2e6 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -13,7 +13,7 @@ // "junit:build/cucumber.xml" }) @RunWith(Courgette.class) -@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.SCENARIO, rerunFailedScenarios = false, +@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, testOutput = CourgetteTestOutput.CONSOLE, reportTitle = "Paymenthub Test results", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { diff --git a/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv b/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv index 92c3b3126..f61dc32c3 100644 --- a/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv +++ b/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv @@ -1,4 +1,4 @@ id,request_id,payment_mode,payer_identifier_type,payer_identifier,payee_identifier_type,payee_identifier,amount,currency,note -0,6f2581f3-6fb6-419c-b55d-118cf85ebc84,gsma,msisdn,739,msisdn,714,10,USD,Test Payee Payment -1,b0500c84-4448-4c14-bfec-825bdabf952e,gsma,msisdn,742,msisdn,716,5,USD,Test Payee Payment -2,339fcfce-4ddc-42f0-bcc9-3e75452b6aeb,gsma,msisdn,743,msisdn,717,1,USD,Test Payee Payment \ No newline at end of file +0,f039f13f-43f2-4fad-bcdf-4a550fd29e2b,gsma,msisdn,856,msisdn,810,10,USD,Test Payee Payment +1,93748d2b-86e8-494f-87c2-af095e75a60d,gsma,msisdn,858,msisdn,811,5,USD,Test Payee Payment +2,f36664db-0fe7-4e58-b2ad-bf257dfee4dd,gsma,msisdn,859,msisdn,813,1,USD,Test Payee Payment \ No newline at end of file From 4fd7b626935565613a45e621855b54ef22276b74 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Fri, 8 Mar 2024 12:13:06 +0530 Subject: [PATCH 21/48] Updated the threads and run --- src/main/resources/application.yaml | 2 +- src/test/java/org/mifos/integrationtest/TestRunner.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 13ddd4686..2df866732 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -91,7 +91,7 @@ savings: mock-server: port: 53013 -callback_url: https://52bf-2406-7400-51-aeac-8c53-583-8442-2b4.ngrok-free.app +callback_url: ${CALLBACK_URL:localhost} json-web-signature: privateKey: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC07fxdEQlsvWvggBgrork401cdyZ9MqV6FF/RgX6+Om23gP/rME5sE5//OoG61KU3dEj9phcHH845TuyNEyc4Vhqxe1gzl4VIZkOj+/2qxYvCsP1Sv3twTs+fDfFv5NA1ZXqiswTlgjR2Lpf1tevFQEOzB9WYvH/Bu9kgr2AlHMPV6+b7gcJij/7W1hndiCk2ahbi7oXjjODF4yEU9yNAhopibe4zzMX+FO4eFYpUmrjS5wvv6aAanfoeIMTwhF81Gj9V3rHf4UsD3VEx773q7GPuXlZSLyiNrUCdvxITh+dW8Y9ICuCTy3bFbp1/HzoPdzkkUlzPNKLlLiV2w4EcxAgMBAAECggEAMjqHfwbFyQxlMHQfQa3xIdd6LejVcqDqfqSB0Wd/A2YfAMyCQbmHpbsKh0B+u4h191OjixX5EBuLfa9MQUKNFejHXaSq+/6rnjFenbwm0IwZKJiEWDbUfhvJ0blqhypuMktXJG6YETfb5fL1AjnJWGL6d3Y7IgYJ56QzsQhOuxZidSqw468xc4sIF0CoTeJdrSC2yDCVuVlLNifm/2SXBJD8mgc1WCz0rkJhvvpW4k5G9rRSkS5f0013ZNfsfiDXoqiKkafoYNEbk7TZQNInqSuONm/UECn5GLm6IXdXSGfm1O2Lt0Kk7uxW/3W00mIPeZD+hiOObheRm/2HoOEKiQKBgQDreVFQihXAEDviIB2s6fphvPcMw/IonE8tX565i3303ubQMDIyZmsi3apN5pqSjm1TKq1KIgY2D4vYTu6vO5x9MhEO2CCZWNwC+awrIYa32FwiT8D8eZ9g+DJ4/IwXyz1fG38RCz/eIsJ0NsS9z8RKBIbfMmM+WnXRez3Fq+cbRwKBgQDEs35qXThbbFUYo1QkO0vIo85iczu9NllRxo1nAqQkfu1oTYQQobxcGk/aZk0B02r9kt2eob8zfG+X3LadIhQ0/LalnGNKI9jWLkdW4dxi7xMU99MYc3NRXmR49xGxgOVkLzKyGMisUvkTnE5v/S1nhu5uFr3JPkWcCScLOTjVxwKBgHNWsDq3+GFkUkC3pHF/BhJ7wbLyA5pavfmmnZOavO6FhB8zjFLdkdq5IuMXcl0ZAHm9LLZkJhCy2rfwKb+RflxgerR/rrAOM24Np4RU3q0MgEyaLhg85pFT4T0bzu8UsRH14O6TSQxgkEjmTsX+j9IFl56aCryPCKi8Kgy53/CfAoGAdV2kUFLPDb3WCJ1r1zKKRW1398ZKHtwO73xJYu1wg1Y40cNuyX23pj0M6IOh7zT24dZ/5ecc7tuQukw3qgprhDJFyQtHMzWwbBuw9WZO2blM6XX1vuEkLajkykihhggi12RSG3IuSqQ3ejwJkUi/jsYz/fwTwcAmSLQtV8UM5IECgYEAh4h1EkMx3NXzVFmLsb4QLMXw8+Rnn9oG+NGObldQ+nmknUPu7iz5kl9lTJy+jWtqHlHL8ZtV1cZZSZnFxX5WQH5/lcz/UD+GqWoSlWuTU34PPTJqLKSYgkoOJQDEZVMVphLySS9tuo+K/h10lRS1r9KDm3RZASa1JnnWopBZIz4=" diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index d0043e2e6..8687b9d5b 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -13,7 +13,7 @@ // "junit:build/cucumber.xml" }) @RunWith(Courgette.class) -@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, +@CourgetteOptions(threads = 4, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, testOutput = CourgetteTestOutput.CONSOLE, reportTitle = "Paymenthub Test results", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { From 6e6fca96ae01b330f4433ecc0fc0f6ae3244d867 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Fri, 8 Mar 2024 16:16:38 +0530 Subject: [PATCH 22/48] Testing with 3 threads --- src/test/java/org/mifos/integrationtest/TestRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index 8687b9d5b..d0043e2e6 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -13,7 +13,7 @@ // "junit:build/cucumber.xml" }) @RunWith(Courgette.class) -@CourgetteOptions(threads = 4, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, +@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, testOutput = CourgetteTestOutput.CONSOLE, reportTitle = "Paymenthub Test results", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { From d7bc3ae613bb99becbb9050fd2978c985716ff77 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Fri, 8 Mar 2024 16:58:08 +0530 Subject: [PATCH 23/48] Testing with 4 threads --- src/test/java/org/mifos/integrationtest/TestRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index d0043e2e6..8687b9d5b 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -13,7 +13,7 @@ // "junit:build/cucumber.xml" }) @RunWith(Courgette.class) -@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, +@CourgetteOptions(threads = 4, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, testOutput = CourgetteTestOutput.CONSOLE, reportTitle = "Paymenthub Test results", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { From 73cf1d869165586762169ac5ee123278d9b4daf1 Mon Sep 17 00:00:00 2001 From: dhruvsonagara Date: Mon, 25 Mar 2024 17:26:43 +0530 Subject: [PATCH 24/48] Updated the thread to 3 --- src/test/java/org/mifos/integrationtest/TestRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index 8687b9d5b..d0043e2e6 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -13,7 +13,7 @@ // "junit:build/cucumber.xml" }) @RunWith(Courgette.class) -@CourgetteOptions(threads = 4, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, +@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, testOutput = CourgetteTestOutput.CONSOLE, reportTitle = "Paymenthub Test results", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { From 2404a16653e16dcb5f589688cc143a708c4e90b7 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Mon, 1 Apr 2024 08:47:51 +0530 Subject: [PATCH 25/48] dynamic port allocation --- .../config/MockServerConfig.java | 13 ++++--- .../cucumber/stepdef/BillPayStepDef.java | 20 +++++------ .../stepdef/IdentityMapperStepDef.java | 10 +++--- .../cucumber/stepdef/MockServerStepDef.java | 36 ++++++++++++------- .../cucumber/stepdef/ScenarioScopeState.java | 1 + src/test/java/resources/batch.feature | 1 + src/test/java/resources/billPay.feature | 29 ++------------- src/test/java/resources/bulkPayment.feature | 1 + src/test/java/resources/gsmaTxn.feature | 1 + .../java/resources/identityMapperTest.feature | 1 + src/test/java/resources/inbound.feature | 1 + src/test/java/resources/mockserver.feature | 4 ++- src/test/java/resources/mojaloop.feature | 1 + .../resources/voucherManagementTest.feature | 7 ++-- 14 files changed, 63 insertions(+), 63 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/config/MockServerConfig.java b/src/test/java/org/mifos/integrationtest/config/MockServerConfig.java index d8514b9e8..ad1a074cd 100644 --- a/src/test/java/org/mifos/integrationtest/config/MockServerConfig.java +++ b/src/test/java/org/mifos/integrationtest/config/MockServerConfig.java @@ -4,22 +4,25 @@ import com.github.tomakehurst.wiremock.WireMockServer; import lombok.extern.slf4j.Slf4j; +import org.mifos.integrationtest.cucumber.stepdef.ScenarioScopeState; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; @Configuration @Slf4j public class MockServerConfig implements MockServer { + @Autowired + ScenarioScopeState scenarioScopeState; private static WireMockServer singleInstance = null; - @Value("${mock-server.port}") - private int port; + public WireMockServer getMockServer() { if (MockServerConfig.singleInstance == null) { - MockServerConfig.singleInstance = new WireMockServer(wireMockConfig().port(this.port)); - log.debug("PORT {}", port); + MockServerConfig.singleInstance = new WireMockServer(wireMockConfig().port(scenarioScopeState.mockServerPort)); + //log.debug("PORT {}", port); } return MockServerConfig.singleInstance; @@ -27,7 +30,7 @@ public WireMockServer getMockServer() { @Override public String getBaseUri() { - return "http://localhost:" + getMockServer().port(); + return "http://localhost:" + "4040"; } } diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java index 8c57aa5a8..d650805bd 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java @@ -189,7 +189,7 @@ public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedRequestWithASpec public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillPay() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -229,7 +229,7 @@ public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillPay() { public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillNotification() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -291,7 +291,7 @@ public void iHaveABillerIdAs(String biller) { public void iCanExtractTheCallbackBodyAndAssertTheRtpStatus() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -336,7 +336,7 @@ public void iCanExtractTheCallbackBodyAndAssertTheRtpStatus() { public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillerUnidentified() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -372,7 +372,7 @@ public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillerUnidentified( public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillInvalid() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -415,7 +415,7 @@ public void iShouldGetDataInResponse() throws JSONException { public void iShouldBeAbleToExtractResponseBodyFromCallbackForEmptyBillId() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -465,7 +465,7 @@ public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillNotificationWit public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillAlreadyPaid() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -512,7 +512,7 @@ public void iShouldNotBeAbleToRemoveAllServerEvents() { public void iShouldNotBeAbleToExtractResponseBodyFromCallbackForBill() { await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); if (allServeEvents.isEmpty()) { flag = true; } else { @@ -532,7 +532,7 @@ public void iShouldNotBeAbleToExtractResponseBodyFromCallbackForBill() { public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillPaidAfterTimeout() { await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -623,7 +623,7 @@ public void iCanExtractTheErrorFromResponseBodyAndAssertTheErrorInformationAs(St public void iCanExtractTheErrorFromCallbackBodyAndAssertErrorMessageAs(String errorMessage) { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java index a88ee17e1..2d7b3f9fc 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java @@ -173,8 +173,8 @@ public void iCallTheAccountLookupAPITimesWithExpectedStatusOf(int count, int exp public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedRequestWithASpecificBody(String httpmethod, String endpoint) { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { try { - verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.registerRequestID", equalTo(requestId)))); - verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.numberFailedCases", equalTo("0")))); + mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.registerRequestID", equalTo(requestId)))); + mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.numberFailedCases", equalTo("0")))); assertTrue(true); } catch (VerificationException e) { assertTrue(false);// failure @@ -186,7 +186,7 @@ public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedRequestWithASpec public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithSamePayeeIdentity(String httpmethod, String endpoint) { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { try { - verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.payeeIdentity", equalTo(payeeIdentity)))); + mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.payeeIdentity", equalTo(payeeIdentity)))); assertTrue(true); } catch (VerificationException e) { assertTrue(false); @@ -356,7 +356,7 @@ public void iShouldBeAbleToVerifyThatTheMethodToReceiveRequest(String httpMethod throws JsonProcessingException { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); for (int i = 0; i < allServeEvents.size(); i++) { ServeEvent request = allServeEvents.get(i); @@ -530,7 +530,7 @@ public void iCreateAIdentityMapperDTOForRegisteringBeneficiary() { public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithSuccessfullRegistration(String httpMethod, String stub) { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); for (int i = 0; i < allServeEvents.size(); i++) { ServeEvent request = allServeEvents.get(i); diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java index 55bd7288a..d15ec7e09 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java @@ -14,11 +14,14 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; import static com.github.tomakehurst.wiremock.client.WireMock.verify; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; import static com.google.common.truth.Truth.assertThat; import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; import static org.mifos.integrationtest.common.Utils.getDefaultSpec; +import com.github.tomakehurst.wiremock.WireMockServer; +import com.github.tomakehurst.wiremock.client.WireMock; import io.cucumber.java.ParameterType; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; @@ -30,12 +33,13 @@ import org.mifos.integrationtest.common.HttpMethod; import org.springframework.beans.factory.annotation.Value; +import java.util.concurrent.atomic.AtomicInteger; + public class MockServerStepDef extends BaseStepDef { private static Boolean wiremockStarted = false; + private static final AtomicInteger portCounter = new AtomicInteger(53013); - @Value("${mock-server.port}") - private int mockServerPortFromConfig; @Given("I can inject MockServer") public void checkIfMockServerIsInjected() { @@ -45,7 +49,7 @@ public void checkIfMockServerIsInjected() { @Then("I should be able to get instance of mock server") public void getInstanceOfMockServer() throws InterruptedException { assertThat(mockServer.getMockServer()).isNotNull(); - assertThat(mockServer.getMockServer().port()).isEqualTo(mockServerPortFromConfig); + assertThat(mockServer.getMockServer().port()).isEqualTo(scenarioScopeState.mockServerPort); } @ParameterType(name = "httpMethod", value = ".*") @@ -59,16 +63,17 @@ public HttpMethod httpMethod(String httpMethod) { public void startStub(String endpoint, HttpMethod httpMethod, int status) { switch (httpMethod) { case GET -> { - stubFor(get(urlPathMatching(endpoint)).willReturn(status(status))); + mockServer.getMockServer().stubFor(get(urlPathMatching(endpoint)).willReturn(status(status))); } case POST -> { - stubFor(post(urlPathMatching(endpoint)).willReturn(status(status))); + mockServer.getMockServer().stubFor(post(urlPathMatching(endpoint)).willReturn(status(status))); + //configureFor("localhost",4040); } case PUT -> { - stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); + mockServer.getMockServer().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); } case DELETE -> { - stubFor(delete(urlPathMatching(endpoint)).willReturn(status(status))); + mockServer.getMockServer().stubFor(delete(urlPathMatching(endpoint)).willReturn(status(status))); } } } @@ -99,16 +104,16 @@ public void verifyStub(HttpMethod httpMethod, String endpoint, int numberOfReque await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { switch (httpMethod) { case GET -> { - verify(numberOfRequest, getRequestedFor(urlEqualTo(endpoint))); + mockServer.getMockServer().verify(numberOfRequest, getRequestedFor(urlEqualTo(endpoint))); } case POST -> { - verify(numberOfRequest, postRequestedFor(urlEqualTo(endpoint))); + mockServer.getMockServer().verify(numberOfRequest, postRequestedFor(urlEqualTo(endpoint))); } case PUT -> { - verify(numberOfRequest, putRequestedFor(urlEqualTo(endpoint))); + mockServer.getMockServer().verify(numberOfRequest, putRequestedFor(urlEqualTo(endpoint))); } case DELETE -> { - verify(numberOfRequest, deleteRequestedFor(urlEqualTo(endpoint))); + mockServer.getMockServer().verify(numberOfRequest, deleteRequestedFor(urlEqualTo(endpoint))); } } }); @@ -117,7 +122,7 @@ public void verifyStub(HttpMethod httpMethod, String endpoint, int numberOfReque @And("I can start mock server") public void startMockServer() { mockServer.getMockServer().start(); - configureFor("localhost", mockServer.getMockServer().port()); + configureFor( scenarioScopeState.mockServerPort); } @And("I can stop mock server") @@ -145,4 +150,11 @@ public void iWillRegisterTheStubWithEndpointForRequestWithStatusOf(String endpoi public void iWillUpdateTheMockServerAndRegisterStubAsDone() { wiremockStarted = true; } + + @Given("I will assign a port to mock server") + public void iWillAssignAPortToMockServer() { + int port = portCounter.getAndIncrement(); + scenarioScopeState.mockServerPort = port; + } + } diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/ScenarioScopeState.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/ScenarioScopeState.java index 41dc2a11b..eea5999f1 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/ScenarioScopeState.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/ScenarioScopeState.java @@ -116,4 +116,5 @@ public class ScenarioScopeState { protected String registeringInstitutionId; protected String agentId; protected String fetchVoucherResponseBody; + public int mockServerPort; } diff --git a/src/test/java/resources/batch.feature b/src/test/java/resources/batch.feature index 323f54e7e..a477bb68e 100644 --- a/src/test/java/resources/batch.feature +++ b/src/test/java/resources/batch.feature @@ -274,6 +274,7 @@ Feature: Batch Details API test @gov Scenario: BD-018 Batch with callback + Given I will assign a port to mock server Given I can inject MockServer And I can start mock server And I can register the stub with "/callback" endpoint for "POST" request with status of 200 diff --git a/src/test/java/resources/billPay.feature b/src/test/java/resources/billPay.feature index ae60d72bf..1c7ce61c6 100644 --- a/src/test/java/resources/billPay.feature +++ b/src/test/java/resources/billPay.feature @@ -4,6 +4,7 @@ Feature: Bill Payment P2G Test @gov #this is an integration for bill inquiry stage w/o rtp, includes bill inquiry api only from PFI to PBB to Bill Agg and back Scenario: BI-001 Bill Inquiry API for orchestration (PFI to PBB) + Given I will assign a port to mock server Given I can inject MockServer And I can start mock server And I can register the stub with "/billInquiry" endpoint for "POST" request with status of 200 @@ -19,8 +20,6 @@ Feature: Bill Payment P2G Test @gov #this is an integration for payment notification, includes api calls from PFI to PBB to Bill Agg and back (tests full flow) Scenario: BP-001 Bill Payments API for orchestration (PFI to PBB) - Given I can inject MockServer - And I can start mock server And I can register the stub with "/billNotification" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I have bill id as "001" @@ -35,8 +34,7 @@ Feature: Bill Payment P2G Test #this is an integration for bill inquiry stage w/o rtp, includes bill inquiry api and payment notification from PFI to PBB to Bill Agg and back Scenario: Bill Inquiry API for orchestration (PFI to PBB) - Given I can inject MockServer - And I can start mock server + And I can register the stub with "/billInquiry" endpoint for "POST" request with status of 200 And I can register the stub with "/billNotification" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" @@ -80,8 +78,6 @@ Feature: Bill Payment P2G Test @gov Scenario: RTP-001 RTP Integration test - Given I can inject MockServer - And I can start mock server And I can register the stub with "/test" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I have a billerId as "GovBill" @@ -94,8 +90,6 @@ Feature: Bill Payment P2G Test @gov Scenario: BI-002 Bill Inquiry API for orchestration fails due to invalid prefix (PFI to PBB) - Given I can inject MockServer - And I can start mock server And I can register the stub with "/billInquiry" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I create a new clientCorrelationId @@ -108,8 +102,6 @@ Feature: Bill Payment P2G Test @gov Scenario: BI-003A: Bill Inquiry API for orchestration fails due to invalid bill (PBB TO BA) - Given I can inject MockServer - And I can start mock server And I can register the stub with "/billInquiry" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I create a new clientCorrelationId @@ -122,8 +114,6 @@ Feature: Bill Payment P2G Test @gov Scenario: BI-003B: Bill Inquiry API for orchestration fails due to payer fsp not onboarded (PFI TO PBB) - Given I can inject MockServer - And I can start mock server And I can register the stub with "/billInquiryInvalid" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I create a new clientCorrelationId @@ -134,8 +124,6 @@ Feature: Bill Payment P2G Test @gov Scenario: BI-004: Bill Inquiry API for orchestration fails due to empty bill (PBB TO BA) - Given I can inject MockServer - And I can start mock server And I can register the stub with "/billInquiryEmpty" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I create a new clientCorrelationId @@ -148,8 +136,6 @@ Feature: Bill Payment P2G Test @gov Scenario: BP-003 Bill Payments API fails due to mandatory fields missing (PFI to PBB) - Given I can inject MockServer - And I can start mock server And I can register the stub with "/billNotificationMissing" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I have bill id as "001" @@ -163,8 +149,6 @@ Feature: Bill Payment P2G Test Scenario: BP-003A Bill Payments API fails due to empty bill id (PFI to PBB) - Given I can inject MockServer - And I can start mock server And I can register the stub with "/billNotificationIdMissing" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I generate clientCorrelationId @@ -177,8 +161,6 @@ Feature: Bill Payment P2G Test @gov Scenario: BP-004A Bill Payments API fails due to bill already marked paid (PFI to PBB) - Given I can inject MockServer - And I can start mock server And I can register the stub with "/billNotificationPaid" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I have bill id as "003" @@ -193,8 +175,6 @@ Feature: Bill Payment P2G Test @gov Scenario: BP-004B Bill Payments API fails due to bill marked as paid after a timeout (PFI to PBB) - Given I can inject MockServer - And I can start mock server And I can register the stub with "/billNotificationsTimeout" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I have bill id as "005" @@ -262,9 +242,6 @@ Feature: Bill Payment P2G Test @gov Scenario: RTP-008 Request to Pay is unsuccessful because the specified account of the Payer FI was unreachable - did not respond (Txn timed out) - - Given I can inject MockServer - And I can start mock server And I can register the stub with "/payerUnreachable" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I have a billerId as "GovBill" @@ -278,8 +255,6 @@ Feature: Bill Payment P2G Test @gov Scenario: RTP-009 Request to Pay is unsuccessful because the Payer FSP is unable to debit amount (insufficient amount/ blocked account/ account hold etc) (Payer FSP declines) - Given I can inject MockServer - And I can start mock server And I can register the stub with "/debitFailed" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I have a billerId as "GovBill" diff --git a/src/test/java/resources/bulkPayment.feature b/src/test/java/resources/bulkPayment.feature index 418ad4235..02b7ac5ba 100644 --- a/src/test/java/resources/bulkPayment.feature +++ b/src/test/java/resources/bulkPayment.feature @@ -5,6 +5,7 @@ Feature: Test ability to make payment to individual with bank account Given I have tenant as "paymentbb1" And I have the demo csv file "bulk_payment.csv" And I create a list of payee identifiers from csv file + Given I will assign a port to mock server When I can inject MockServer Then I can start mock server And I can register the stub with "/registerBeneficiary" endpoint for "PUT" request with status of 200 diff --git a/src/test/java/resources/gsmaTxn.feature b/src/test/java/resources/gsmaTxn.feature index e4f1d17cd..fd5f4b81f 100644 --- a/src/test/java/resources/gsmaTxn.feature +++ b/src/test/java/resources/gsmaTxn.feature @@ -2,6 +2,7 @@ Feature: GSMA Transfer API Test for Account Identifier Worker Background: I will start mock server and register stub + Given I will assign a port to mock server Given I will start the mock server And I can register the stub with "/depositCallback" endpoint for "POST" request with status of 200 And I can register the stub with "/loanCallback" endpoint for "POST" request with status of 200 diff --git a/src/test/java/resources/identityMapperTest.feature b/src/test/java/resources/identityMapperTest.feature index 2aa335510..111a351e1 100644 --- a/src/test/java/resources/identityMapperTest.feature +++ b/src/test/java/resources/identityMapperTest.feature @@ -2,6 +2,7 @@ Feature: Identity Account Mapper Api Test Background: I will start mock server and register stub + Given I will assign a port to mock server Given I will start the mock server And I can register the stub with "/registerBeneficiaryApiTest" endpoint for "PUT" request with status of 200 And I can register the stub with "/addPaymentModalityApiTest" endpoint for "PUT" request with status of 200 diff --git a/src/test/java/resources/inbound.feature b/src/test/java/resources/inbound.feature index 14fdb7281..af48f7690 100644 --- a/src/test/java/resources/inbound.feature +++ b/src/test/java/resources/inbound.feature @@ -9,6 +9,7 @@ Feature: Inbound transaction test Scenario: IAM-005 Bulk Processor Inbound Integration Test When I create an IdentityMapperDTO for registering beneficiary with "gorilla" as DFSPID + Given I will assign a port to mock server Then I can inject MockServer And I can start mock server When I call the register beneficiary API with expected status of 202 diff --git a/src/test/java/resources/mockserver.feature b/src/test/java/resources/mockserver.feature index c68b0a722..7ed22a04d 100644 --- a/src/test/java/resources/mockserver.feature +++ b/src/test/java/resources/mockserver.feature @@ -1,13 +1,15 @@ -@gov + @gov Feature: Testing the startup and working of mockserver Scenario: MS-001 Mockserver config test + Given I will assign a port to mock server Given I can inject MockServer And I can start mock server Then I should be able to get instance of mock server And I can stop mock server Scenario: MS-002 Mockserver stub test + Given I will assign a port to mock server Given I can inject MockServer And I can start mock server And I can register the stub with "/testMockServer" endpoint for "POST" request with status of 200 diff --git a/src/test/java/resources/mojaloop.feature b/src/test/java/resources/mojaloop.feature index 3cae45cf8..8f31e9d32 100644 --- a/src/test/java/resources/mojaloop.feature +++ b/src/test/java/resources/mojaloop.feature @@ -44,6 +44,7 @@ Feature: Mojaloop test Then I call the interop identifier endpoint for "payee" Then I approve the deposit with command "approve" for "payee" When I activate the account with command "activate" for "payee" + Given I will assign a port to mock server When I can inject MockServer Then I can start mock server Then I can register the stub for callback endpoint of quotation diff --git a/src/test/java/resources/voucherManagementTest.feature b/src/test/java/resources/voucherManagementTest.feature index 4c28d1dd3..0151a0a34 100644 --- a/src/test/java/resources/voucherManagementTest.feature +++ b/src/test/java/resources/voucherManagementTest.feature @@ -2,6 +2,7 @@ Feature: Voucher Management Api Test Scenario: Create Voucher Api Test + Given I will assign a port to mock server When I can inject MockServer Then I can start mock server And I can register the stub with "/createVoucher" endpoint for "PUT" request with status of 200 @@ -60,7 +61,7 @@ Feature: Voucher Management Api Test # When I will sleep for 3000 millisecond Then I will call the fetch voucher API with expected status of 200 And I will assert the fields from fetch voucher response - And I can stop mock server + Scenario: VC-001,002,003,004,005 Error Validity check for Create Voucher API for negative request body Given I can create an negative VoucherRequestDTO for voucher creation @@ -79,8 +80,8 @@ Feature: Voucher Management Api Test @Ignore Scenario: Create a csv file for voucher number and voucher serial number - When I can inject MockServer - Then I can start mock server + And I can register the stub with "/createVoucher" endpoint for "PUT" request with status of 200 And I can register the stub with "/activateVoucher" endpoint for "PUT" request with status of 200 When I call the create, Activate voucher API and store it in "vouchertest/loadTest_demo.csv" + And I can stop mock server From f07af5770db1c30cd2ede344b3ccc6272ceb4d3d Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Mon, 1 Apr 2024 08:54:45 +0530 Subject: [PATCH 26/48] checkstyle --- .../java/org/mifos/integrationtest/TestRunner.java | 3 +-- .../integrationtest/config/MockServerConfig.java | 6 ++---- .../cucumber/stepdef/IdentityMapperStepDef.java | 10 ++++++---- .../cucumber/stepdef/MockServerStepDef.java | 14 +++----------- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index d0043e2e6..0b4ac5566 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -13,8 +13,7 @@ // "junit:build/cucumber.xml" }) @RunWith(Courgette.class) -@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, - testOutput = CourgetteTestOutput.CONSOLE, +@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, testOutput = CourgetteTestOutput.CONSOLE, reportTitle = "Paymenthub Test results", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { "html:cucumber-report", "json:cucumber.json", "pretty", "html:build/cucumber-report.html", diff --git a/src/test/java/org/mifos/integrationtest/config/MockServerConfig.java b/src/test/java/org/mifos/integrationtest/config/MockServerConfig.java index ad1a074cd..ecf49713e 100644 --- a/src/test/java/org/mifos/integrationtest/config/MockServerConfig.java +++ b/src/test/java/org/mifos/integrationtest/config/MockServerConfig.java @@ -6,23 +6,21 @@ import lombok.extern.slf4j.Slf4j; import org.mifos.integrationtest.cucumber.stepdef.ScenarioScopeState; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; @Configuration @Slf4j public class MockServerConfig implements MockServer { + @Autowired ScenarioScopeState scenarioScopeState; private static WireMockServer singleInstance = null; - - public WireMockServer getMockServer() { if (MockServerConfig.singleInstance == null) { MockServerConfig.singleInstance = new WireMockServer(wireMockConfig().port(scenarioScopeState.mockServerPort)); - //log.debug("PORT {}", port); + // log.debug("PORT {}", port); } return MockServerConfig.singleInstance; diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java index 2d7b3f9fc..dc2052d62 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java @@ -1,7 +1,6 @@ package org.mifos.integrationtest.cucumber.stepdef; import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; -import static com.github.tomakehurst.wiremock.client.WireMock.getAllServeEvents; import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath; import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; @@ -173,8 +172,10 @@ public void iCallTheAccountLookupAPITimesWithExpectedStatusOf(int count, int exp public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedRequestWithASpecificBody(String httpmethod, String endpoint) { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { try { - mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.registerRequestID", equalTo(requestId)))); - mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.numberFailedCases", equalTo("0")))); + mockServer.getMockServer().verify( + putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.registerRequestID", equalTo(requestId)))); + mockServer.getMockServer().verify( + putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.numberFailedCases", equalTo("0")))); assertTrue(true); } catch (VerificationException e) { assertTrue(false);// failure @@ -186,7 +187,8 @@ public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedRequestWithASpec public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithSamePayeeIdentity(String httpmethod, String endpoint) { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { try { - mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.payeeIdentity", equalTo(payeeIdentity)))); + mockServer.getMockServer().verify( + putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.payeeIdentity", equalTo(payeeIdentity)))); assertTrue(true); } catch (VerificationException e) { assertTrue(false); diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java index d15ec7e09..afdf02a28 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java @@ -10,18 +10,13 @@ import static com.github.tomakehurst.wiremock.client.WireMock.put; import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.status; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static com.github.tomakehurst.wiremock.client.WireMock.verify; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; import static com.google.common.truth.Truth.assertThat; import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; import static org.mifos.integrationtest.common.Utils.getDefaultSpec; -import com.github.tomakehurst.wiremock.WireMockServer; -import com.github.tomakehurst.wiremock.client.WireMock; import io.cucumber.java.ParameterType; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; @@ -30,17 +25,14 @@ import io.restassured.RestAssured; import io.restassured.builder.ResponseSpecBuilder; import io.restassured.specification.RequestSender; -import org.mifos.integrationtest.common.HttpMethod; -import org.springframework.beans.factory.annotation.Value; - import java.util.concurrent.atomic.AtomicInteger; +import org.mifos.integrationtest.common.HttpMethod; public class MockServerStepDef extends BaseStepDef { private static Boolean wiremockStarted = false; private static final AtomicInteger portCounter = new AtomicInteger(53013); - @Given("I can inject MockServer") public void checkIfMockServerIsInjected() { assertThat(mockServer).isNotNull(); @@ -67,7 +59,7 @@ public void startStub(String endpoint, HttpMethod httpMethod, int status) { } case POST -> { mockServer.getMockServer().stubFor(post(urlPathMatching(endpoint)).willReturn(status(status))); - //configureFor("localhost",4040); + // configureFor("localhost",4040); } case PUT -> { mockServer.getMockServer().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); @@ -122,7 +114,7 @@ public void verifyStub(HttpMethod httpMethod, String endpoint, int numberOfReque @And("I can start mock server") public void startMockServer() { mockServer.getMockServer().start(); - configureFor( scenarioScopeState.mockServerPort); + configureFor(scenarioScopeState.mockServerPort); } @And("I can stop mock server") From a295bcfe7c255f71a785b25a44e301c22b3d45a4 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Mon, 1 Apr 2024 12:50:17 +0530 Subject: [PATCH 27/48] log port --- .../integrationtest/cucumber/stepdef/MockServerStepDef.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java index afdf02a28..9d4b79bde 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java @@ -114,6 +114,7 @@ public void verifyStub(HttpMethod httpMethod, String endpoint, int numberOfReque @And("I can start mock server") public void startMockServer() { mockServer.getMockServer().start(); + logger.info("PORT {}", scenarioScopeState.mockServerPort); configureFor(scenarioScopeState.mockServerPort); } From 4e344032ee1c555ee214125b4def9e0c9b297cdc Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Mon, 1 Apr 2024 14:14:43 +0530 Subject: [PATCH 28/48] fix --- src/test/java/resources/mockserver.feature | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/test/java/resources/mockserver.feature b/src/test/java/resources/mockserver.feature index 7ed22a04d..4548a1087 100644 --- a/src/test/java/resources/mockserver.feature +++ b/src/test/java/resources/mockserver.feature @@ -6,12 +6,8 @@ Feature: Testing the startup and working of mockserver Given I can inject MockServer And I can start mock server Then I should be able to get instance of mock server - And I can stop mock server Scenario: MS-002 Mockserver stub test - Given I will assign a port to mock server - Given I can inject MockServer - And I can start mock server And I can register the stub with "/testMockServer" endpoint for "POST" request with status of 200 When I make the "POST" request to "/testMockServer" endpoint with expected status of 200 Then I should be able to verify that the "POST" method to "/testMockServer" endpoint received 1 request From c2a1ff12fc3bce60c3f5b983c04f0cede19fef12 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:29:53 +0530 Subject: [PATCH 29/48] annotate --- .../org/mifos/integrationtest/TestRunner.java | 20 +++++++++++- .../cucumber/stepdef/MockServerStepDef.java | 32 ++++++++++++++----- src/test/java/resources/batch.feature | 6 ++-- src/test/java/resources/billPay.feature | 6 ++-- src/test/java/resources/bulkPayment.feature | 6 ++-- src/test/java/resources/gsmaTxn.feature | 4 +-- .../java/resources/identityMapperTest.feature | 6 ++-- src/test/java/resources/inbound.feature | 6 ++-- src/test/java/resources/mockserver.feature | 8 ++--- src/test/java/resources/mojaloop.feature | 8 ++--- .../resources/voucherManagementTest.feature | 8 ++--- 11 files changed, 72 insertions(+), 38 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index 0b4ac5566..3a7ae47f0 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -1,10 +1,13 @@ package org.mifos.integrationtest; +import com.github.tomakehurst.wiremock.WireMockServer; import courgette.api.CourgetteOptions; import courgette.api.CourgetteRunLevel; import courgette.api.CourgetteTestOutput; import courgette.api.CucumberOptions; import courgette.api.junit.Courgette; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.runner.RunWith; //@RunWith(Cucumber.class) @@ -18,4 +21,19 @@ reportTitle = "Paymenthub Test results", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { "html:cucumber-report", "json:cucumber.json", "pretty", "html:build/cucumber-report.html", "json:build/cucumber-report.json", "junit:build/cucumber.xml" })) -public class TestRunner {} +public class TestRunner { + private static WireMockServer wireMockServer; + + @BeforeClass + public static void setup() { + // Start WireMock server + wireMockServer = new WireMockServer(53013); + wireMockServer.start(); + } + + @AfterClass + public static void teardown() { + // Stop WireMock server + wireMockServer.stop(); + } +} diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java index 9d4b79bde..052d77b8f 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java @@ -17,6 +17,8 @@ import static org.awaitility.Awaitility.await; import static org.mifos.integrationtest.common.Utils.getDefaultSpec; +import com.github.tomakehurst.wiremock.WireMockServer; +import com.github.tomakehurst.wiremock.client.WireMock; import io.cucumber.java.ParameterType; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; @@ -32,6 +34,7 @@ public class MockServerStepDef extends BaseStepDef { private static Boolean wiremockStarted = false; private static final AtomicInteger portCounter = new AtomicInteger(53013); + private static WireMockServer wireMockServer; @Given("I can inject MockServer") public void checkIfMockServerIsInjected() { @@ -55,17 +58,30 @@ public HttpMethod httpMethod(String httpMethod) { public void startStub(String endpoint, HttpMethod httpMethod, int status) { switch (httpMethod) { case GET -> { - mockServer.getMockServer().stubFor(get(urlPathMatching(endpoint)).willReturn(status(status))); + wireMockServer.stubFor(WireMock.get(WireMock.urlEqualTo(endpoint)) + .willReturn(WireMock.aResponse() + .withStatus(200))); + //mockServer.getMockServer().stubFor(get(urlPathMatching(endpoint)).willReturn(status(status))); + } case POST -> { - mockServer.getMockServer().stubFor(post(urlPathMatching(endpoint)).willReturn(status(status))); + wireMockServer.stubFor(WireMock.post(WireMock.urlEqualTo(endpoint)) + .willReturn(WireMock.aResponse() + .withStatus(200))); + //mockServer.getMockServer().stubFor(post(urlPathMatching(endpoint)).willReturn(status(status))); // configureFor("localhost",4040); } case PUT -> { - mockServer.getMockServer().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); + wireMockServer.stubFor(WireMock.put(WireMock.urlEqualTo(endpoint)) + .willReturn(WireMock.aResponse() + .withStatus(200))); + //mockServer.getMockServer().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); } case DELETE -> { - mockServer.getMockServer().stubFor(delete(urlPathMatching(endpoint)).willReturn(status(status))); + wireMockServer.stubFor(WireMock.delete(WireMock.urlEqualTo(endpoint)) + .willReturn(WireMock.aResponse() + .withStatus(200))); + //mockServer.getMockServer().stubFor(delete(urlPathMatching(endpoint)).willReturn(status(status))); } } } @@ -96,16 +112,16 @@ public void verifyStub(HttpMethod httpMethod, String endpoint, int numberOfReque await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { switch (httpMethod) { case GET -> { - mockServer.getMockServer().verify(numberOfRequest, getRequestedFor(urlEqualTo(endpoint))); + wireMockServer.verify(numberOfRequest, getRequestedFor(urlEqualTo(endpoint))); } case POST -> { - mockServer.getMockServer().verify(numberOfRequest, postRequestedFor(urlEqualTo(endpoint))); + wireMockServer.verify(numberOfRequest, postRequestedFor(urlEqualTo(endpoint))); } case PUT -> { - mockServer.getMockServer().verify(numberOfRequest, putRequestedFor(urlEqualTo(endpoint))); + wireMockServer.verify(numberOfRequest, putRequestedFor(urlEqualTo(endpoint))); } case DELETE -> { - mockServer.getMockServer().verify(numberOfRequest, deleteRequestedFor(urlEqualTo(endpoint))); + wireMockServer.verify(numberOfRequest, deleteRequestedFor(urlEqualTo(endpoint))); } } }); diff --git a/src/test/java/resources/batch.feature b/src/test/java/resources/batch.feature index a477bb68e..cc505065c 100644 --- a/src/test/java/resources/batch.feature +++ b/src/test/java/resources/batch.feature @@ -274,9 +274,9 @@ Feature: Batch Details API test @gov Scenario: BD-018 Batch with callback - Given I will assign a port to mock server - Given I can inject MockServer - And I can start mock server + //Given I will assign a port to mock server + //Given I can inject MockServer + //And I can start mock server And I can register the stub with "/callback" endpoint for "POST" request with status of 200 Then I will update the mock server and register stub as done Given I have tenant as "paymentBB1" diff --git a/src/test/java/resources/billPay.feature b/src/test/java/resources/billPay.feature index 1c7ce61c6..b47ee21cd 100644 --- a/src/test/java/resources/billPay.feature +++ b/src/test/java/resources/billPay.feature @@ -4,9 +4,9 @@ Feature: Bill Payment P2G Test @gov #this is an integration for bill inquiry stage w/o rtp, includes bill inquiry api only from PFI to PBB to Bill Agg and back Scenario: BI-001 Bill Inquiry API for orchestration (PFI to PBB) - Given I will assign a port to mock server - Given I can inject MockServer - And I can start mock server + // Given I will assign a port to mock server + // Given I can inject MockServer + //And I can start mock server And I can register the stub with "/billInquiry" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I create a new clientCorrelationId diff --git a/src/test/java/resources/bulkPayment.feature b/src/test/java/resources/bulkPayment.feature index 02b7ac5ba..6c27a9169 100644 --- a/src/test/java/resources/bulkPayment.feature +++ b/src/test/java/resources/bulkPayment.feature @@ -5,9 +5,9 @@ Feature: Test ability to make payment to individual with bank account Given I have tenant as "paymentbb1" And I have the demo csv file "bulk_payment.csv" And I create a list of payee identifiers from csv file - Given I will assign a port to mock server - When I can inject MockServer - Then I can start mock server + //Given I will assign a port to mock server + //When I can inject MockServer + //Then I can start mock server And I can register the stub with "/registerBeneficiary" endpoint for "PUT" request with status of 200 And I create a IdentityMapperDTO for registering beneficiary Then I call the register beneficiary API with expected status of 202 and stub "/registerBeneficiary" diff --git a/src/test/java/resources/gsmaTxn.feature b/src/test/java/resources/gsmaTxn.feature index fd5f4b81f..49edefc3e 100644 --- a/src/test/java/resources/gsmaTxn.feature +++ b/src/test/java/resources/gsmaTxn.feature @@ -2,8 +2,8 @@ Feature: GSMA Transfer API Test for Account Identifier Worker Background: I will start mock server and register stub - Given I will assign a port to mock server - Given I will start the mock server + //Given I will assign a port to mock server + //Given I will start the mock server And I can register the stub with "/depositCallback" endpoint for "POST" request with status of 200 And I can register the stub with "/loanCallback" endpoint for "POST" request with status of 200 diff --git a/src/test/java/resources/identityMapperTest.feature b/src/test/java/resources/identityMapperTest.feature index 111a351e1..d53c915d4 100644 --- a/src/test/java/resources/identityMapperTest.feature +++ b/src/test/java/resources/identityMapperTest.feature @@ -2,8 +2,8 @@ Feature: Identity Account Mapper Api Test Background: I will start mock server and register stub - Given I will assign a port to mock server - Given I will start the mock server + //Given I will assign a port to mock server + // Given I will start the mock server And I can register the stub with "/registerBeneficiaryApiTest" endpoint for "PUT" request with status of 200 And I can register the stub with "/addPaymentModalityApiTest" endpoint for "PUT" request with status of 200 And I can register the stub with "/updatePaymentModalityApiTest" endpoint for "PUT" request with status of 200 @@ -298,7 +298,7 @@ Feature: Identity Account Mapper Api Test When I call the update beneficiary API with expected status of 202 and stub "/updateBeneficiaryApiTest" # Then I will sleep for 3000 millisecond Then I should be able to verify that the "PUT" method to "/updateBeneficiaryApiTest" endpoint received a request with no of failed cases as 2 - And I can stop mock server + //And I can stop mock server diff --git a/src/test/java/resources/inbound.feature b/src/test/java/resources/inbound.feature index af48f7690..1f80c74cc 100644 --- a/src/test/java/resources/inbound.feature +++ b/src/test/java/resources/inbound.feature @@ -9,9 +9,9 @@ Feature: Inbound transaction test Scenario: IAM-005 Bulk Processor Inbound Integration Test When I create an IdentityMapperDTO for registering beneficiary with "gorilla" as DFSPID - Given I will assign a port to mock server - Then I can inject MockServer - And I can start mock server + // Given I will assign a port to mock server + //Then I can inject MockServer + // And I can start mock server When I call the register beneficiary API with expected status of 202 Given I have the demo csv file "ph-ee-bulk-demo-7.csv" And I have tenant as "rhino" diff --git a/src/test/java/resources/mockserver.feature b/src/test/java/resources/mockserver.feature index 4548a1087..c792f196a 100644 --- a/src/test/java/resources/mockserver.feature +++ b/src/test/java/resources/mockserver.feature @@ -2,13 +2,13 @@ Feature: Testing the startup and working of mockserver Scenario: MS-001 Mockserver config test - Given I will assign a port to mock server - Given I can inject MockServer - And I can start mock server + // Given I will assign a port to mock server + //Given I can inject MockServer + //And I can start mock server Then I should be able to get instance of mock server Scenario: MS-002 Mockserver stub test And I can register the stub with "/testMockServer" endpoint for "POST" request with status of 200 When I make the "POST" request to "/testMockServer" endpoint with expected status of 200 Then I should be able to verify that the "POST" method to "/testMockServer" endpoint received 1 request - And I can stop mock server + //And I can stop mock server diff --git a/src/test/java/resources/mojaloop.feature b/src/test/java/resources/mojaloop.feature index 8f31e9d32..d00e280ca 100644 --- a/src/test/java/resources/mojaloop.feature +++ b/src/test/java/resources/mojaloop.feature @@ -16,7 +16,7 @@ Feature: Mojaloop test Then I call the get parties api in ml connector for "payee" # Then I will sleep for 5000 millisecond Then I should be able to verify the callback for lookup - Then I can stop mock server + //Then I can stop mock server Scenario: ML connector partial payee quotation test Given I am setting up Mojaloop @@ -27,13 +27,13 @@ Feature: Mojaloop test Then I call the interop identifier endpoint for "payee" Then I approve the deposit with command "approve" for "payee" When I activate the account with command "activate" for "payee" - When I can inject MockServer - Then I can start mock server + //When I can inject MockServer + //Then I can start mock server Then I can register the stub for callback endpoint of quotation Then I call the get quotation api in ml connector for "payee" # Then I will sleep for 5000 millisecond Then I should be able to verify the callback for quotation - Then I can stop mock server + //Then I can stop mock server Scenario: ML connector partial payee transfer test Given I am setting up Mojaloop diff --git a/src/test/java/resources/voucherManagementTest.feature b/src/test/java/resources/voucherManagementTest.feature index 0151a0a34..5aeeb7e10 100644 --- a/src/test/java/resources/voucherManagementTest.feature +++ b/src/test/java/resources/voucherManagementTest.feature @@ -2,9 +2,9 @@ Feature: Voucher Management Api Test Scenario: Create Voucher Api Test - Given I will assign a port to mock server - When I can inject MockServer - Then I can start mock server + //Given I will assign a port to mock server + // When I can inject MockServer + // Then I can start mock server And I can register the stub with "/createVoucher" endpoint for "PUT" request with status of 200 Given I can create an VoucherRequestDTO for voucher creation When I call the create voucher API with expected status of 202 and stub "/createVoucher" @@ -84,4 +84,4 @@ Feature: Voucher Management Api Test And I can register the stub with "/createVoucher" endpoint for "PUT" request with status of 200 And I can register the stub with "/activateVoucher" endpoint for "PUT" request with status of 200 When I call the create, Activate voucher API and store it in "vouchertest/loadTest_demo.csv" - And I can stop mock server + //And I can stop mock server From cd1938387ca1c1c492b78d732b424eb77f690b24 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:33:29 +0530 Subject: [PATCH 30/48] fix --- .../org/mifos/integrationtest/TestRunner.java | 1 + .../cucumber/stepdef/MockServerStepDef.java | 29 +++++-------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index 3a7ae47f0..68bca8604 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -22,6 +22,7 @@ "html:cucumber-report", "json:cucumber.json", "pretty", "html:build/cucumber-report.html", "json:build/cucumber-report.json", "junit:build/cucumber.xml" })) public class TestRunner { + private static WireMockServer wireMockServer; @BeforeClass diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java index 052d77b8f..d079c0064 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java @@ -1,17 +1,12 @@ package org.mifos.integrationtest.cucumber.stepdef; import static com.github.tomakehurst.wiremock.client.WireMock.configureFor; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; import static com.github.tomakehurst.wiremock.client.WireMock.deleteRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.put; import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.status; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; import static com.google.common.truth.Truth.assertThat; import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; @@ -58,30 +53,22 @@ public HttpMethod httpMethod(String httpMethod) { public void startStub(String endpoint, HttpMethod httpMethod, int status) { switch (httpMethod) { case GET -> { - wireMockServer.stubFor(WireMock.get(WireMock.urlEqualTo(endpoint)) - .willReturn(WireMock.aResponse() - .withStatus(200))); - //mockServer.getMockServer().stubFor(get(urlPathMatching(endpoint)).willReturn(status(status))); + wireMockServer.stubFor(WireMock.get(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); + // mockServer.getMockServer().stubFor(get(urlPathMatching(endpoint)).willReturn(status(status))); } case POST -> { - wireMockServer.stubFor(WireMock.post(WireMock.urlEqualTo(endpoint)) - .willReturn(WireMock.aResponse() - .withStatus(200))); - //mockServer.getMockServer().stubFor(post(urlPathMatching(endpoint)).willReturn(status(status))); + wireMockServer.stubFor(WireMock.post(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); + // mockServer.getMockServer().stubFor(post(urlPathMatching(endpoint)).willReturn(status(status))); // configureFor("localhost",4040); } case PUT -> { - wireMockServer.stubFor(WireMock.put(WireMock.urlEqualTo(endpoint)) - .willReturn(WireMock.aResponse() - .withStatus(200))); - //mockServer.getMockServer().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); + wireMockServer.stubFor(WireMock.put(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); + // mockServer.getMockServer().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); } case DELETE -> { - wireMockServer.stubFor(WireMock.delete(WireMock.urlEqualTo(endpoint)) - .willReturn(WireMock.aResponse() - .withStatus(200))); - //mockServer.getMockServer().stubFor(delete(urlPathMatching(endpoint)).willReturn(status(status))); + wireMockServer.stubFor(WireMock.delete(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); + // mockServer.getMockServer().stubFor(delete(urlPathMatching(endpoint)).willReturn(status(status))); } } } From 79c9ad4f512a0fd6b88d40d707b01b2e6010e14e Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:40:59 +0530 Subject: [PATCH 31/48] test --- src/test/java/org/mifos/integrationtest/TestRunner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index 68bca8604..76fb62e20 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -26,14 +26,14 @@ public class TestRunner { private static WireMockServer wireMockServer; @BeforeClass - public static void setup() { + private static void setup() { // Start WireMock server wireMockServer = new WireMockServer(53013); wireMockServer.start(); } @AfterClass - public static void teardown() { + private static void teardown() { // Stop WireMock server wireMockServer.stop(); } From 36a6bf3bb30dbc2b38cf451c12111aa37569ac4f Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:57:33 +0530 Subject: [PATCH 32/48] puv --- src/test/java/org/mifos/integrationtest/TestRunner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index 76fb62e20..68bca8604 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -26,14 +26,14 @@ public class TestRunner { private static WireMockServer wireMockServer; @BeforeClass - private static void setup() { + public static void setup() { // Start WireMock server wireMockServer = new WireMockServer(53013); wireMockServer.start(); } @AfterClass - private static void teardown() { + public static void teardown() { // Stop WireMock server wireMockServer.stop(); } From 772632aef653f15917741f20d0f67d8ab67418b3 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Wed, 3 Apr 2024 17:09:13 +0530 Subject: [PATCH 33/48] test --- src/test/java/org/mifos/integrationtest/TestRunner.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index 68bca8604..88b2b9304 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -6,6 +6,8 @@ import courgette.api.CourgetteTestOutput; import courgette.api.CucumberOptions; import courgette.api.junit.Courgette; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runner.RunWith; @@ -21,6 +23,7 @@ reportTitle = "Paymenthub Test results", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { "html:cucumber-report", "json:cucumber.json", "pretty", "html:build/cucumber-report.html", "json:build/cucumber-report.json", "junit:build/cucumber.xml" })) +@SuppressWarnings({ "FinalClass","HideUtilityClassConstructor" }) public class TestRunner { private static WireMockServer wireMockServer; From 079798412dbbe9d250bde00da0635bc329f73957 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Wed, 3 Apr 2024 17:11:41 +0530 Subject: [PATCH 34/48] ps --- src/test/java/org/mifos/integrationtest/TestRunner.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index 88b2b9304..26c617fcd 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -6,8 +6,6 @@ import courgette.api.CourgetteTestOutput; import courgette.api.CucumberOptions; import courgette.api.junit.Courgette; -import lombok.AllArgsConstructor; -import lombok.NoArgsConstructor; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runner.RunWith; @@ -23,7 +21,7 @@ reportTitle = "Paymenthub Test results", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { "html:cucumber-report", "json:cucumber.json", "pretty", "html:build/cucumber-report.html", "json:build/cucumber-report.json", "junit:build/cucumber.xml" })) -@SuppressWarnings({ "FinalClass","HideUtilityClassConstructor" }) +@SuppressWarnings({ "FinalClass", "HideUtilityClassConstructor" }) public class TestRunner { private static WireMockServer wireMockServer; From 9e59c414f7e9e4cf728d5d0a4c06b5cbd02c566c Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:04:11 +0530 Subject: [PATCH 35/48] comment --- src/test/java/resources/batch.feature | 6 +++--- src/test/java/resources/billPay.feature | 6 +++--- src/test/java/resources/bulkPayment.feature | 6 +++--- src/test/java/resources/gsmaTxn.feature | 4 ++-- .../java/resources/identityMapperTest.feature | 6 +++--- src/test/java/resources/inbound.feature | 6 +++--- src/test/java/resources/mockserver.feature | 8 ++++---- src/test/java/resources/mojaloop.feature | 16 ++++++++-------- .../java/resources/voucherManagementTest.feature | 8 ++++---- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/test/java/resources/batch.feature b/src/test/java/resources/batch.feature index cc505065c..77a9767e4 100644 --- a/src/test/java/resources/batch.feature +++ b/src/test/java/resources/batch.feature @@ -274,9 +274,9 @@ Feature: Batch Details API test @gov Scenario: BD-018 Batch with callback - //Given I will assign a port to mock server - //Given I can inject MockServer - //And I can start mock server + #Given I will assign a port to mock server + #Given I can inject MockServer + #And I can start mock server And I can register the stub with "/callback" endpoint for "POST" request with status of 200 Then I will update the mock server and register stub as done Given I have tenant as "paymentBB1" diff --git a/src/test/java/resources/billPay.feature b/src/test/java/resources/billPay.feature index b47ee21cd..e339d3b21 100644 --- a/src/test/java/resources/billPay.feature +++ b/src/test/java/resources/billPay.feature @@ -4,9 +4,9 @@ Feature: Bill Payment P2G Test @gov #this is an integration for bill inquiry stage w/o rtp, includes bill inquiry api only from PFI to PBB to Bill Agg and back Scenario: BI-001 Bill Inquiry API for orchestration (PFI to PBB) - // Given I will assign a port to mock server - // Given I can inject MockServer - //And I can start mock server + #Given I will assign a port to mock server + #Given I can inject MockServer + # And I can start mock server And I can register the stub with "/billInquiry" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I create a new clientCorrelationId diff --git a/src/test/java/resources/bulkPayment.feature b/src/test/java/resources/bulkPayment.feature index 6c27a9169..305a01e4f 100644 --- a/src/test/java/resources/bulkPayment.feature +++ b/src/test/java/resources/bulkPayment.feature @@ -5,9 +5,9 @@ Feature: Test ability to make payment to individual with bank account Given I have tenant as "paymentbb1" And I have the demo csv file "bulk_payment.csv" And I create a list of payee identifiers from csv file - //Given I will assign a port to mock server - //When I can inject MockServer - //Then I can start mock server + #Given I will assign a port to mock server + #When I can inject MockServer + #Then I can start mock server And I can register the stub with "/registerBeneficiary" endpoint for "PUT" request with status of 200 And I create a IdentityMapperDTO for registering beneficiary Then I call the register beneficiary API with expected status of 202 and stub "/registerBeneficiary" diff --git a/src/test/java/resources/gsmaTxn.feature b/src/test/java/resources/gsmaTxn.feature index 49edefc3e..8af870879 100644 --- a/src/test/java/resources/gsmaTxn.feature +++ b/src/test/java/resources/gsmaTxn.feature @@ -2,8 +2,8 @@ Feature: GSMA Transfer API Test for Account Identifier Worker Background: I will start mock server and register stub - //Given I will assign a port to mock server - //Given I will start the mock server + #Given I will assign a port to mock server + #Given I will start the mock server And I can register the stub with "/depositCallback" endpoint for "POST" request with status of 200 And I can register the stub with "/loanCallback" endpoint for "POST" request with status of 200 diff --git a/src/test/java/resources/identityMapperTest.feature b/src/test/java/resources/identityMapperTest.feature index d53c915d4..63813758d 100644 --- a/src/test/java/resources/identityMapperTest.feature +++ b/src/test/java/resources/identityMapperTest.feature @@ -2,8 +2,8 @@ Feature: Identity Account Mapper Api Test Background: I will start mock server and register stub - //Given I will assign a port to mock server - // Given I will start the mock server + #Given I will assign a port to mock server + # Given I will start the mock server And I can register the stub with "/registerBeneficiaryApiTest" endpoint for "PUT" request with status of 200 And I can register the stub with "/addPaymentModalityApiTest" endpoint for "PUT" request with status of 200 And I can register the stub with "/updatePaymentModalityApiTest" endpoint for "PUT" request with status of 200 @@ -298,7 +298,7 @@ Feature: Identity Account Mapper Api Test When I call the update beneficiary API with expected status of 202 and stub "/updateBeneficiaryApiTest" # Then I will sleep for 3000 millisecond Then I should be able to verify that the "PUT" method to "/updateBeneficiaryApiTest" endpoint received a request with no of failed cases as 2 - //And I can stop mock server + #And I can stop mock server diff --git a/src/test/java/resources/inbound.feature b/src/test/java/resources/inbound.feature index 1f80c74cc..f867cd7a5 100644 --- a/src/test/java/resources/inbound.feature +++ b/src/test/java/resources/inbound.feature @@ -9,9 +9,9 @@ Feature: Inbound transaction test Scenario: IAM-005 Bulk Processor Inbound Integration Test When I create an IdentityMapperDTO for registering beneficiary with "gorilla" as DFSPID - // Given I will assign a port to mock server - //Then I can inject MockServer - // And I can start mock server + # Given I will assign a port to mock server + #Then I can inject MockServer + # And I can start mock server When I call the register beneficiary API with expected status of 202 Given I have the demo csv file "ph-ee-bulk-demo-7.csv" And I have tenant as "rhino" diff --git a/src/test/java/resources/mockserver.feature b/src/test/java/resources/mockserver.feature index c792f196a..2f72cdbab 100644 --- a/src/test/java/resources/mockserver.feature +++ b/src/test/java/resources/mockserver.feature @@ -2,13 +2,13 @@ Feature: Testing the startup and working of mockserver Scenario: MS-001 Mockserver config test - // Given I will assign a port to mock server - //Given I can inject MockServer - //And I can start mock server + # Given I will assign a port to mock server + #Given I can inject MockServer + #And I can start mock server Then I should be able to get instance of mock server Scenario: MS-002 Mockserver stub test And I can register the stub with "/testMockServer" endpoint for "POST" request with status of 200 When I make the "POST" request to "/testMockServer" endpoint with expected status of 200 Then I should be able to verify that the "POST" method to "/testMockServer" endpoint received 1 request - //And I can stop mock server + #And I can stop mock server diff --git a/src/test/java/resources/mojaloop.feature b/src/test/java/resources/mojaloop.feature index d00e280ca..c1f5a4882 100644 --- a/src/test/java/resources/mojaloop.feature +++ b/src/test/java/resources/mojaloop.feature @@ -10,13 +10,13 @@ Feature: Mojaloop test Then I call the interop identifier endpoint for "payee" Then I approve the deposit with command "approve" for "payee" When I activate the account with command "activate" for "payee" - When I can inject MockServer - Then I can start mock server + # When I can inject MockServer + # Then I can start mock server Then I can register the stub for callback endpoint of party lookup Then I call the get parties api in ml connector for "payee" # Then I will sleep for 5000 millisecond Then I should be able to verify the callback for lookup - //Then I can stop mock server + #Then I can stop mock server Scenario: ML connector partial payee quotation test Given I am setting up Mojaloop @@ -27,13 +27,13 @@ Feature: Mojaloop test Then I call the interop identifier endpoint for "payee" Then I approve the deposit with command "approve" for "payee" When I activate the account with command "activate" for "payee" - //When I can inject MockServer - //Then I can start mock server + #When I can inject MockServer + #Then I can start mock server Then I can register the stub for callback endpoint of quotation Then I call the get quotation api in ml connector for "payee" # Then I will sleep for 5000 millisecond Then I should be able to verify the callback for quotation - //Then I can stop mock server + #Then I can stop mock server Scenario: ML connector partial payee transfer test Given I am setting up Mojaloop @@ -45,8 +45,8 @@ Feature: Mojaloop test Then I approve the deposit with command "approve" for "payee" When I activate the account with command "activate" for "payee" Given I will assign a port to mock server - When I can inject MockServer - Then I can start mock server + # When I can inject MockServer + #Then I can start mock server Then I can register the stub for callback endpoint of quotation Then I call the get quotation api in ml connector for "payee" # Then I will sleep for 5000 millisecond diff --git a/src/test/java/resources/voucherManagementTest.feature b/src/test/java/resources/voucherManagementTest.feature index 5aeeb7e10..382d49aa3 100644 --- a/src/test/java/resources/voucherManagementTest.feature +++ b/src/test/java/resources/voucherManagementTest.feature @@ -2,9 +2,9 @@ Feature: Voucher Management Api Test Scenario: Create Voucher Api Test - //Given I will assign a port to mock server - // When I can inject MockServer - // Then I can start mock server + #Given I will assign a port to mock server + # When I can inject MockServer + # Then I can start mock server And I can register the stub with "/createVoucher" endpoint for "PUT" request with status of 200 Given I can create an VoucherRequestDTO for voucher creation When I call the create voucher API with expected status of 202 and stub "/createVoucher" @@ -84,4 +84,4 @@ Feature: Voucher Management Api Test And I can register the stub with "/createVoucher" endpoint for "PUT" request with status of 200 And I can register the stub with "/activateVoucher" endpoint for "PUT" request with status of 200 When I call the create, Activate voucher API and store it in "vouchertest/loadTest_demo.csv" - //And I can stop mock server + #And I can stop mock server From 924dfa0c3f7274361e5e8cfced53e6249301101f Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:43:42 +0530 Subject: [PATCH 36/48] Test --- .../org/mifos/integrationtest/TestRunner.java | 19 +++++++++++---- .../cucumber/stepdef/MockServerStepDef.java | 24 +++++++++++-------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index 26c617fcd..fd7e94dde 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -1,6 +1,7 @@ package org.mifos.integrationtest; -import com.github.tomakehurst.wiremock.WireMockServer; +import static com.github.tomakehurst.wiremock.client.WireMock.configureFor; + import courgette.api.CourgetteOptions; import courgette.api.CourgetteRunLevel; import courgette.api.CourgetteTestOutput; @@ -9,6 +10,8 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runner.RunWith; +import org.mifos.integrationtest.config.MockServer; +import org.springframework.beans.factory.annotation.Autowired; //@RunWith(Cucumber.class) //@CucumberOptions(features = { "src/test/java/resources" }, glue = { "org.mifos.integrationtest.cucumber" }, plugin = { @@ -24,18 +27,24 @@ @SuppressWarnings({ "FinalClass", "HideUtilityClassConstructor" }) public class TestRunner { - private static WireMockServer wireMockServer; + @Autowired + public static MockServer mockServer; + + // private static WireMockServer wireMockServer; @BeforeClass public static void setup() { // Start WireMock server - wireMockServer = new WireMockServer(53013); - wireMockServer.start(); + // wireMockServer = new WireMockServer(53013); + // wireMockServer.start(); + mockServer.getMockServer().start(); + configureFor(53013); } @AfterClass public static void teardown() { // Stop WireMock server - wireMockServer.stop(); + // wireMockServer.stop(); + mockServer.getMockServer().stop(); } } diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java index d079c0064..cb7019f2d 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java @@ -2,11 +2,15 @@ import static com.github.tomakehurst.wiremock.client.WireMock.configureFor; import static com.github.tomakehurst.wiremock.client.WireMock.deleteRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.put; import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.status; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; import static com.google.common.truth.Truth.assertThat; import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; @@ -53,18 +57,18 @@ public HttpMethod httpMethod(String httpMethod) { public void startStub(String endpoint, HttpMethod httpMethod, int status) { switch (httpMethod) { case GET -> { - wireMockServer.stubFor(WireMock.get(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); - // mockServer.getMockServer().stubFor(get(urlPathMatching(endpoint)).willReturn(status(status))); + // wireMockServer.stubFor(WireMock.get(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); + mockServer.getMockServer().stubFor(get(urlPathMatching(endpoint)).willReturn(status(status))); } case POST -> { - wireMockServer.stubFor(WireMock.post(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); - // mockServer.getMockServer().stubFor(post(urlPathMatching(endpoint)).willReturn(status(status))); + // wireMockServer.stubFor(WireMock.post(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); + mockServer.getMockServer().stubFor(post(urlPathMatching(endpoint)).willReturn(status(status))); // configureFor("localhost",4040); } case PUT -> { - wireMockServer.stubFor(WireMock.put(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); - // mockServer.getMockServer().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); + // wireMockServer.stubFor(WireMock.put(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); + mockServer.getMockServer().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); } case DELETE -> { wireMockServer.stubFor(WireMock.delete(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); @@ -99,16 +103,16 @@ public void verifyStub(HttpMethod httpMethod, String endpoint, int numberOfReque await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { switch (httpMethod) { case GET -> { - wireMockServer.verify(numberOfRequest, getRequestedFor(urlEqualTo(endpoint))); + mockServer.getMockServer().verify(numberOfRequest, getRequestedFor(urlEqualTo(endpoint))); } case POST -> { - wireMockServer.verify(numberOfRequest, postRequestedFor(urlEqualTo(endpoint))); + mockServer.getMockServer().verify(numberOfRequest, postRequestedFor(urlEqualTo(endpoint))); } case PUT -> { - wireMockServer.verify(numberOfRequest, putRequestedFor(urlEqualTo(endpoint))); + mockServer.getMockServer().verify(numberOfRequest, putRequestedFor(urlEqualTo(endpoint))); } case DELETE -> { - wireMockServer.verify(numberOfRequest, deleteRequestedFor(urlEqualTo(endpoint))); + mockServer.getMockServer().verify(numberOfRequest, deleteRequestedFor(urlEqualTo(endpoint))); } } }); From 1b6f1ce2a4c42e77aab5eb1d30136a8d9a01bdd7 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Thu, 4 Apr 2024 11:51:43 +0530 Subject: [PATCH 37/48] fix --- .../cucumber/stepdef/BillPayStepDef.java | 6 ++---- .../stepdef/VoucherManagementStepDef.java | 17 ++++++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java index d650805bd..5868aebe9 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java @@ -1,10 +1,8 @@ package org.mifos.integrationtest.cucumber.stepdef; -import static com.github.tomakehurst.wiremock.client.WireMock.getAllServeEvents; import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath; import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static com.google.common.truth.Truth.assertThat; import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; @@ -182,7 +180,7 @@ public void iCallTheMockBillsPaymentApiFromPBBToBillerWithBillidWithExpectedStat @Then("I should be able to verify that the {string} method to {string} endpoint received a request with code in body") public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedRequestWithASpecificBody(String httpmethod, String endpoint) { - verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.code"))); + mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.code"))); } @Then("I should be able to extract response body from callback for bill pay") @@ -504,7 +502,7 @@ public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillAlreadyPaid() { public void iShouldNotBeAbleToRemoveAllServerEvents() { boolean flag = false; WireMock.resetAllRequests(); - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); assertThat(allServeEvents.size()).isEqualTo(0); } diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java index 00c6bfe05..8273fdc0b 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java @@ -1,11 +1,9 @@ package org.mifos.integrationtest.cucumber.stepdef; import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; -import static com.github.tomakehurst.wiremock.client.WireMock.getAllServeEvents; import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath; import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static com.google.common.truth.Truth.assertThat; import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; @@ -161,7 +159,7 @@ public void iCanCreateAnVoucherRequestDTOForVoucherCancellation() { @Then("I should be able to verify that the {string} method to {string} endpoint received a request with required parameter in cancel voucher callback body") public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithRequiredParameterInCancelVoucherCallbackBody(String arg0, String endpoint) { - verify(putRequestedFor(urlEqualTo(endpoint)) + mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)) .withRequestBody(matchingJsonPath("$.requestID", equalTo(scenarioScopeState.requstId)))); } @@ -183,21 +181,21 @@ public void iCallTheCancelVoucherAPIWithExpectedStatusOfAndStub(int expectedStat @Then("I should be able to verify that the {string} method to {string} endpoint received a request with required parameter in redeem voucher callback body") public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithRequiredParameterInRedeemVoucherCallbackBody(String arg0, String endpoint) { - verify(putRequestedFor(urlEqualTo(endpoint)) + mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)) .withRequestBody(matchingJsonPath("$.requestID", equalTo(scenarioScopeState.requstId)))); } @Then("I should be able to verify that the {string} method to {string} endpoint received a request with required parameter in suspend voucher callback body") public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithRequiredParameterInSuspendVoucherCallbackBody(String arg0, String endpoint) { - verify(putRequestedFor(urlEqualTo(endpoint)) + mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)) .withRequestBody(matchingJsonPath("$.requestID", equalTo(scenarioScopeState.requstId)))); } @Then("I should be able to extract response body from callback") public void iShouldBeAbleToExtractResponseBodyFromCallback() { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); for (int i = 0; i < allServeEvents.size(); i++) { ServeEvent request = allServeEvents.get(i); @@ -450,7 +448,7 @@ public void iCanExtractResultFromValidationCallbackAndAssertIfValidationIsSucces await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { // (putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.isValid", equalTo("true")))); - List allServeEvents = getAllServeEvents(); + List allServeEvents = mockServer.getMockServer().getAllServeEvents(); String serialNo = null; String isValid = null; for (int i = 0; i < allServeEvents.size(); i++) { @@ -490,9 +488,10 @@ public void iCanAssertThatRedemptionWasUnsuccessfulByAssertingTheStatusInRespons public void iShouldBeAbleToAssertResponseBodyFromCallback(String endpoint) { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { try { - verify(putRequestedFor(urlEqualTo(endpoint)) + mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)) .withRequestBody(matchingJsonPath("$.registerRequestId", equalTo(scenarioScopeState.requestId)))); - verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.numberFailedCases", equalTo("0")))); + mockServer.getMockServer().verify( + putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.numberFailedCases", equalTo("0")))); assertTrue(true);// success } catch (VerificationException e) { assertTrue(false);// failure From 13bdeecbd8b949ae88a58d7f2515d3f08b14adc6 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Thu, 4 Apr 2024 16:08:58 +0530 Subject: [PATCH 38/48] cleanup --- .../org/mifos/integrationtest/TestRunner.java | 7 ------- .../cucumber/stepdef/MockServerStepDef.java | 17 ++++------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index fd7e94dde..e946a9134 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -30,21 +30,14 @@ public class TestRunner { @Autowired public static MockServer mockServer; - // private static WireMockServer wireMockServer; - @BeforeClass public static void setup() { - // Start WireMock server - // wireMockServer = new WireMockServer(53013); - // wireMockServer.start(); mockServer.getMockServer().start(); configureFor(53013); } @AfterClass public static void teardown() { - // Stop WireMock server - // wireMockServer.stop(); mockServer.getMockServer().stop(); } } diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java index cb7019f2d..ea7501a03 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java @@ -1,6 +1,7 @@ package org.mifos.integrationtest.cucumber.stepdef; import static com.github.tomakehurst.wiremock.client.WireMock.configureFor; +import static com.github.tomakehurst.wiremock.client.WireMock.delete; import static com.github.tomakehurst.wiremock.client.WireMock.deleteRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; @@ -17,7 +18,6 @@ import static org.mifos.integrationtest.common.Utils.getDefaultSpec; import com.github.tomakehurst.wiremock.WireMockServer; -import com.github.tomakehurst.wiremock.client.WireMock; import io.cucumber.java.ParameterType; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; @@ -26,13 +26,11 @@ import io.restassured.RestAssured; import io.restassured.builder.ResponseSpecBuilder; import io.restassured.specification.RequestSender; -import java.util.concurrent.atomic.AtomicInteger; import org.mifos.integrationtest.common.HttpMethod; public class MockServerStepDef extends BaseStepDef { private static Boolean wiremockStarted = false; - private static final AtomicInteger portCounter = new AtomicInteger(53013); private static WireMockServer wireMockServer; @Given("I can inject MockServer") @@ -71,8 +69,8 @@ public void startStub(String endpoint, HttpMethod httpMethod, int status) { mockServer.getMockServer().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); } case DELETE -> { - wireMockServer.stubFor(WireMock.delete(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); - // mockServer.getMockServer().stubFor(delete(urlPathMatching(endpoint)).willReturn(status(status))); + // wireMockServer.stubFor(WireMock.delete(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); + mockServer.getMockServer().stubFor(delete(urlPathMatching(endpoint)).willReturn(status(status))); } } } @@ -121,8 +119,7 @@ public void verifyStub(HttpMethod httpMethod, String endpoint, int numberOfReque @And("I can start mock server") public void startMockServer() { mockServer.getMockServer().start(); - logger.info("PORT {}", scenarioScopeState.mockServerPort); - configureFor(scenarioScopeState.mockServerPort); + configureFor("localhost", mockServer.getMockServer().port()); } @And("I can stop mock server") @@ -151,10 +148,4 @@ public void iWillUpdateTheMockServerAndRegisterStubAsDone() { wiremockStarted = true; } - @Given("I will assign a port to mock server") - public void iWillAssignAPortToMockServer() { - int port = portCounter.getAndIncrement(); - scenarioScopeState.mockServerPort = port; - } - } From a7fe8a3c2b6a798ab6a6ae9558ac295b5b9d4f4a Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Fri, 5 Apr 2024 10:17:38 +0530 Subject: [PATCH 39/48] revert --- .../integrationtest/config/MockServerConfig.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/config/MockServerConfig.java b/src/test/java/org/mifos/integrationtest/config/MockServerConfig.java index ecf49713e..4dabff925 100644 --- a/src/test/java/org/mifos/integrationtest/config/MockServerConfig.java +++ b/src/test/java/org/mifos/integrationtest/config/MockServerConfig.java @@ -4,23 +4,22 @@ import com.github.tomakehurst.wiremock.WireMockServer; import lombok.extern.slf4j.Slf4j; -import org.mifos.integrationtest.cucumber.stepdef.ScenarioScopeState; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; @Configuration @Slf4j public class MockServerConfig implements MockServer { - @Autowired - ScenarioScopeState scenarioScopeState; + @Value("${mock-server.port}") + private int port; private static WireMockServer singleInstance = null; public WireMockServer getMockServer() { if (MockServerConfig.singleInstance == null) { - MockServerConfig.singleInstance = new WireMockServer(wireMockConfig().port(scenarioScopeState.mockServerPort)); - // log.debug("PORT {}", port); + MockServerConfig.singleInstance = new WireMockServer(wireMockConfig().port(this.port)); + log.debug("PORT {}", port); } return MockServerConfig.singleInstance; @@ -28,7 +27,7 @@ public WireMockServer getMockServer() { @Override public String getBaseUri() { - return "http://localhost:" + "4040"; + return "http://localhost:" + getMockServer().port(); } } From 1f30ce1508169c5dd7c090029e975f9ea8de2931 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:19:28 +0530 Subject: [PATCH 40/48] comment --- src/test/java/resources/batch.feature | 2 +- src/test/java/resources/billPay.feature | 2 +- src/test/java/resources/mojaloop.feature | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/resources/batch.feature b/src/test/java/resources/batch.feature index 77a9767e4..34cfd7fb4 100644 --- a/src/test/java/resources/batch.feature +++ b/src/test/java/resources/batch.feature @@ -293,7 +293,7 @@ Feature: Batch Details API test Then I should be able to extract response body from callback for batch When I make the "POST" request to "/callback" endpoint with expected status of 200 Then I should be able to extract response body from callback for batch - And I can stop mock server + #And I can stop mock server @gov Scenario: APT-001 actuator API test diff --git a/src/test/java/resources/billPay.feature b/src/test/java/resources/billPay.feature index e339d3b21..d90dcee46 100644 --- a/src/test/java/resources/billPay.feature +++ b/src/test/java/resources/billPay.feature @@ -171,7 +171,7 @@ Feature: Bill Payment P2G Test And I should get transactionId in response # And I will sleep for 5000 millisecond Then I should be able to extract response body from callback for bill already paid - Then I can stop mock server + #Then I can stop mock server @gov Scenario: BP-004B Bill Payments API fails due to bill marked as paid after a timeout (PFI to PBB) diff --git a/src/test/java/resources/mojaloop.feature b/src/test/java/resources/mojaloop.feature index c1f5a4882..b828b7127 100644 --- a/src/test/java/resources/mojaloop.feature +++ b/src/test/java/resources/mojaloop.feature @@ -55,7 +55,7 @@ Feature: Mojaloop test Then I call the transfer api in ml connector for "payee" # Then I will sleep for 5000 millisecond Then I should be able to verify the callback for transfer - Then I can stop mock server + #Then I can stop mock server Scenario: Payer Fund Transfer Flow test Given I am setting up Mojaloop From 691813571903644883c740e8c12abdcec0c362dd Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Sun, 14 Apr 2024 22:46:53 +0530 Subject: [PATCH 41/48] singleton --- .../org/mifos/integrationtest/TestRunner.java | 35 +++++++---- .../config/WireMockServerSingleton.java | 60 +++++++++++++++++++ .../cucumber/stepdef/BaseStepDef.java | 2 + .../cucumber/stepdef/BatchApiStepDef.java | 3 +- .../cucumber/stepdef/BillPayStepDef.java | 5 +- .../cucumber/stepdef/GSMATransferStepDef.java | 3 +- .../stepdef/IdentityMapperStepDef.java | 15 ++--- .../cucumber/stepdef/MockServerStepDef.java | 32 ++++++---- .../stepdef/VoucherManagementStepDef.java | 9 +-- src/test/java/resources/billPay.feature | 11 ++-- .../java/resources/identityMapperTest.feature | 4 +- src/test/java/resources/mockserver.feature | 2 +- .../resources/voucherManagementTest.feature | 2 +- 13 files changed, 136 insertions(+), 47 deletions(-) create mode 100644 src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index e946a9134..f577f2732 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -1,17 +1,34 @@ package org.mifos.integrationtest; import static com.github.tomakehurst.wiremock.client.WireMock.configureFor; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import com.github.tomakehurst.wiremock.WireMockServer; +import courgette.api.CourgetteAfterAll; +import courgette.api.CourgetteBeforeAll; import courgette.api.CourgetteOptions; import courgette.api.CourgetteRunLevel; import courgette.api.CourgetteTestOutput; import courgette.api.CucumberOptions; import courgette.api.junit.Courgette; +import io.cucumber.java.BeforeAll; +import io.cucumber.junit.Cucumber; +import org.junit.After; import org.junit.AfterClass; +import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.jupiter.api.AfterAll; import org.junit.runner.RunWith; import org.mifos.integrationtest.config.MockServer; +import org.mifos.integrationtest.config.MockServerConfig; +import org.mifos.integrationtest.config.WireMockServerSingleton; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.ContextConfiguration; //@RunWith(Cucumber.class) //@CucumberOptions(features = { "src/test/java/resources" }, glue = { "org.mifos.integrationtest.cucumber" }, plugin = { @@ -19,7 +36,7 @@ // "junit:build/cucumber.xml" }) @RunWith(Courgette.class) -@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, testOutput = CourgetteTestOutput.CONSOLE, +@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, testOutput = CourgetteTestOutput.CONSOLE, generateCourgetteRunLog = true , reportTitle = "Paymenthub Test results", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { "html:cucumber-report", "json:cucumber.json", "pretty", "html:build/cucumber-report.html", @@ -27,17 +44,13 @@ @SuppressWarnings({ "FinalClass", "HideUtilityClassConstructor" }) public class TestRunner { - @Autowired - public static MockServer mockServer; - - @BeforeClass - public static void setup() { - mockServer.getMockServer().start(); - configureFor(53013); + @CourgetteBeforeAll + public static void setupWireMockServer() { + WireMockServerSingleton.getInstance(); // Start WireMock server } - @AfterClass - public static void teardown() { - mockServer.getMockServer().stop(); + @CourgetteAfterAll + public static void stopWireMockServer() { + WireMockServerSingleton.getInstance().stop(); // Stop WireMock server } } diff --git a/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java b/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java new file mode 100644 index 000000000..25d85f1a0 --- /dev/null +++ b/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java @@ -0,0 +1,60 @@ +package org.mifos.integrationtest.config; + +import com.github.tomakehurst.wiremock.WireMockServer; +import com.github.tomakehurst.wiremock.common.FatalStartupException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; + +@Component +public class WireMockServerSingleton { + static Logger logger = LoggerFactory.getLogger(WireMockServerSingleton.class); + private static final ThreadLocal threadLocalInstance = new ThreadLocal<>(); + + public static WireMockServer getInstance() { + WireMockServer instance = threadLocalInstance.get(); + if (instance == null || !instance.isRunning()) { + synchronized (WireMockServerSingleton.class) { + instance = threadLocalInstance.get(); // Double-check idiom + if (instance == null || !instance.isRunning()) { + instance = startWireMockServerWithRetry(3); // Retry 3 times + threadLocalInstance.set(instance); + } + } + } + return instance; + } + + private static WireMockServer startWireMockServerWithRetry(int maxRetries) { + WireMockServer server = null; + for (int attempt = 1; attempt <= maxRetries; attempt++) { + int port = getRandomPort(); + server = new WireMockServer(port); + try { + server.start(); + logger.info("WireMock started on port {}", server.port()); + return server; + } catch (FatalStartupException e) { + logger.error("Failed to start WireMock on port {} (Attempt {}/{}). Retrying...", port, attempt, maxRetries, e); + // Optionally, add a short delay here if needed + } + } + throw new IllegalStateException("Failed to start WireMock server after " + maxRetries + " attempts."); + } + + private static int getRandomPort() { + // This returns a port number in the range 1024-65535 + return 1024 + (int)(Math.random() * ((65535 - 1024) + 1)); + } + + public static int getPort() { + WireMockServer instance = threadLocalInstance.get(); + if (instance != null && instance.isRunning()) { + return instance.port(); + } else { + throw new IllegalStateException("WireMock server is not running."); + } + } +} \ No newline at end of file diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BaseStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BaseStepDef.java index c00b55eb1..977743e98 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BaseStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BaseStepDef.java @@ -26,6 +26,7 @@ import org.mifos.integrationtest.config.OperationsAppConfig; import org.mifos.integrationtest.config.TenantConfig; import org.mifos.integrationtest.config.VoucherManagementConfig; +import org.mifos.integrationtest.config.WireMockServerSingleton; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -77,6 +78,7 @@ public class BaseStepDef { @Autowired ScenarioScopeState scenarioScopeState; + int port = WireMockServerSingleton.getPort(); Logger logger = LoggerFactory.getLogger(this.getClass()); protected static BatchRequestDTO batchRequestDTO; diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BatchApiStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BatchApiStepDef.java index 192b09320..52cdcb584 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BatchApiStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BatchApiStepDef.java @@ -60,6 +60,7 @@ import org.mifos.integrationtest.config.BulkProcessorConfig; import org.mifos.integrationtest.config.ChannelConnectorConfig; import org.mifos.integrationtest.config.MockPaymentSchemaConfig; +import org.mifos.integrationtest.config.WireMockServerSingleton; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.env.Environment; @@ -667,7 +668,7 @@ public void iShouldAssertTotalTxnCountAndSuccessfulTxnCountInPaymentBatchDetailR @Then("I should be able to extract response body from callback for batch") public void iShouldBeAbleToExtractResponseBodyFromCallbackForBatch() { boolean flag = false; - List allServeEvents = getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java index 5868aebe9..2c84feff1 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java @@ -32,6 +32,7 @@ import org.mifos.integrationtest.common.dto.PayerFSPDetail; import org.mifos.integrationtest.common.dto.billpayp2g.BillPaymentsReqDTO; import org.mifos.integrationtest.config.BillPayConnectorConfig; +import org.mifos.integrationtest.config.WireMockServerSingleton; import org.springframework.beans.factory.annotation.Autowired; public class BillPayStepDef extends BaseStepDef { @@ -289,7 +290,7 @@ public void iHaveABillerIdAs(String biller) { public void iCanExtractTheCallbackBodyAndAssertTheRtpStatus() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -621,7 +622,7 @@ public void iCanExtractTheErrorFromResponseBodyAndAssertTheErrorInformationAs(St public void iCanExtractTheErrorFromCallbackBodyAndAssertErrorMessageAs(String errorMessage) { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/GSMATransferStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/GSMATransferStepDef.java index 1954816fe..edee0123a 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/GSMATransferStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/GSMATransferStepDef.java @@ -35,6 +35,7 @@ import org.mifos.connector.common.identityaccountmapper.dto.BeneficiaryDTO; import org.mifos.integrationtest.common.Utils; import org.mifos.integrationtest.config.GsmaConfig; +import org.mifos.integrationtest.config.WireMockServerSingleton; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -554,7 +555,7 @@ public void iCallTheAccountLookupAPIWithExpectedStatusOfAndCallbackStub(int expe public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithValidation(String arg0, String endpoint) { await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { - List allServeEvents = getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); Boolean isValidated = null; for (int i = 0; i < allServeEvents.size(); i++) { diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java index dc2052d62..fdd6f96eb 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java @@ -34,6 +34,7 @@ import org.mifos.connector.common.identityaccountmapper.dto.AccountMapperRequestDTO; import org.mifos.connector.common.identityaccountmapper.dto.BeneficiaryDTO; import org.mifos.integrationtest.common.Utils; +import org.mifos.integrationtest.config.WireMockServerSingleton; import org.springframework.beans.factory.annotation.Autowired; public class IdentityMapperStepDef extends BaseStepDef { @@ -158,7 +159,7 @@ public void iCallTheAccountLookupAPITimesWithExpectedStatusOf(int count, int exp for (int i = 1; i < count; i++) { scenarioScopeState.response = RestAssured.given(requestSpec).header("Content-Type", "application/json") - .header("X-Registering-Institution-ID", sourceBBID).header("X-CallbackURL", identityMapperConfig.callbackURL + endpoint) + .header("X-Registering-Institution-ID", sourceBBID).header("X-CallbackURL", identityMapperConfig.callbackURL+ port + endpoint) .queryParam("payeeIdentity", payeeIdentity).queryParam("paymentModality", "00") .queryParam("requestId", generateUniqueNumber(10)).queryParam("sourceBBID", sourceBBID) .baseUri(identityMapperConfig.identityMapperContactPoint).expect() @@ -172,9 +173,9 @@ public void iCallTheAccountLookupAPITimesWithExpectedStatusOf(int count, int exp public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedRequestWithASpecificBody(String httpmethod, String endpoint) { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { try { - mockServer.getMockServer().verify( + WireMockServerSingleton.getInstance().verify( putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.registerRequestID", equalTo(requestId)))); - mockServer.getMockServer().verify( + WireMockServerSingleton.getInstance().verify( putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.numberFailedCases", equalTo("0")))); assertTrue(true); } catch (VerificationException e) { @@ -187,7 +188,7 @@ public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedRequestWithASpec public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithSamePayeeIdentity(String httpmethod, String endpoint) { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { try { - mockServer.getMockServer().verify( + WireMockServerSingleton.getInstance().verify( putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.payeeIdentity", equalTo(payeeIdentity)))); assertTrue(true); } catch (VerificationException e) { @@ -358,7 +359,7 @@ public void iShouldBeAbleToVerifyThatTheMethodToReceiveRequest(String httpMethod throws JsonProcessingException { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); for (int i = 0; i < allServeEvents.size(); i++) { ServeEvent request = allServeEvents.get(i); @@ -604,8 +605,8 @@ public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithNoOf int noOfFailedCases) { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { try { - verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.registerRequestID", equalTo(requestId)))); - verify(putRequestedFor(urlEqualTo(endpoint)) + WireMockServerSingleton.getInstance().verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.registerRequestID", equalTo(requestId)))); + WireMockServerSingleton.getInstance().verify(putRequestedFor(urlEqualTo(endpoint)) .withRequestBody(matchingJsonPath("$.numberFailedCases", equalTo(String.valueOf(noOfFailedCases))))); assertTrue(true); } catch (VerificationException e) { diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java index ea7501a03..b5e4552e7 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java @@ -27,21 +27,26 @@ import io.restassured.builder.ResponseSpecBuilder; import io.restassured.specification.RequestSender; import org.mifos.integrationtest.common.HttpMethod; +import org.mifos.integrationtest.config.WireMockServerSingleton; public class MockServerStepDef extends BaseStepDef { private static Boolean wiremockStarted = false; - private static WireMockServer wireMockServer; + private WireMockServer wireMockServer; @Given("I can inject MockServer") public void checkIfMockServerIsInjected() { assertThat(mockServer).isNotNull(); + //logger.info("{}", mockServer.getMockServer().baseUrl()); } @Then("I should be able to get instance of mock server") public void getInstanceOfMockServer() throws InterruptedException { - assertThat(mockServer.getMockServer()).isNotNull(); - assertThat(mockServer.getMockServer().port()).isEqualTo(scenarioScopeState.mockServerPort); + //assertThat(mockServer.getMockServer()).isNotNull(); + //assertThat(mockServer.getMockServer().port()).isEqualTo(53013); + //WireMockServerSingleton.getInstance + assertThat(WireMockServerSingleton.getInstance()).isNotNull(); + //assertThat(WireMockServerSingleton.getInstance().port()).isEqualTo(53013); } @ParameterType(name = "httpMethod", value = ".*") @@ -56,21 +61,23 @@ public void startStub(String endpoint, HttpMethod httpMethod, int status) { switch (httpMethod) { case GET -> { // wireMockServer.stubFor(WireMock.get(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); - mockServer.getMockServer().stubFor(get(urlPathMatching(endpoint)).willReturn(status(status))); + WireMockServerSingleton.getInstance().stubFor(get(urlPathMatching(endpoint)).willReturn(status(status))); } case POST -> { // wireMockServer.stubFor(WireMock.post(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); - mockServer.getMockServer().stubFor(post(urlPathMatching(endpoint)).willReturn(status(status))); + WireMockServerSingleton.getInstance().stubFor(post(urlPathMatching(endpoint)).willReturn(status(status))); // configureFor("localhost",4040); } case PUT -> { // wireMockServer.stubFor(WireMock.put(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); - mockServer.getMockServer().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); + WireMockServerSingleton.getInstance().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); + + //mockServer.getMockServer().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); } case DELETE -> { // wireMockServer.stubFor(WireMock.delete(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); - mockServer.getMockServer().stubFor(delete(urlPathMatching(endpoint)).willReturn(status(status))); + WireMockServerSingleton.getInstance().stubFor(delete(urlPathMatching(endpoint)).willReturn(status(status))); } } } @@ -101,16 +108,16 @@ public void verifyStub(HttpMethod httpMethod, String endpoint, int numberOfReque await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { switch (httpMethod) { case GET -> { - mockServer.getMockServer().verify(numberOfRequest, getRequestedFor(urlEqualTo(endpoint))); + WireMockServerSingleton.getInstance().verify(numberOfRequest, getRequestedFor(urlEqualTo(endpoint))); } case POST -> { - mockServer.getMockServer().verify(numberOfRequest, postRequestedFor(urlEqualTo(endpoint))); + WireMockServerSingleton.getInstance().verify(numberOfRequest, postRequestedFor(urlEqualTo(endpoint))); } case PUT -> { - mockServer.getMockServer().verify(numberOfRequest, putRequestedFor(urlEqualTo(endpoint))); + WireMockServerSingleton.getInstance().verify(numberOfRequest, putRequestedFor(urlEqualTo(endpoint))); } case DELETE -> { - mockServer.getMockServer().verify(numberOfRequest, deleteRequestedFor(urlEqualTo(endpoint))); + WireMockServerSingleton.getInstance().verify(numberOfRequest, deleteRequestedFor(urlEqualTo(endpoint))); } } }); @@ -118,7 +125,8 @@ public void verifyStub(HttpMethod httpMethod, String endpoint, int numberOfReque @And("I can start mock server") public void startMockServer() { - mockServer.getMockServer().start(); + WireMockServerSingleton.getInstance(); + //mockServer.getMockServer().start(); configureFor("localhost", mockServer.getMockServer().port()); } diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java index 8273fdc0b..a8fed7eb8 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java @@ -37,6 +37,7 @@ import org.mifos.connector.common.vouchers.dto.VoucherInstruction; import org.mifos.integrationtest.common.Utils; import org.mifos.integrationtest.common.dto.ErrorDetails; +import org.mifos.integrationtest.config.WireMockServerSingleton; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -159,7 +160,7 @@ public void iCanCreateAnVoucherRequestDTOForVoucherCancellation() { @Then("I should be able to verify that the {string} method to {string} endpoint received a request with required parameter in cancel voucher callback body") public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithRequiredParameterInCancelVoucherCallbackBody(String arg0, String endpoint) { - mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)) + WireMockServerSingleton.getInstance().verify(putRequestedFor(urlEqualTo(endpoint)) .withRequestBody(matchingJsonPath("$.requestID", equalTo(scenarioScopeState.requstId)))); } @@ -188,14 +189,14 @@ public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithRequ @Then("I should be able to verify that the {string} method to {string} endpoint received a request with required parameter in suspend voucher callback body") public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithRequiredParameterInSuspendVoucherCallbackBody(String arg0, String endpoint) { - mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)) + WireMockServerSingleton.getInstance().verify(putRequestedFor(urlEqualTo(endpoint)) .withRequestBody(matchingJsonPath("$.requestID", equalTo(scenarioScopeState.requstId)))); } @Then("I should be able to extract response body from callback") public void iShouldBeAbleToExtractResponseBodyFromCallback() { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); for (int i = 0; i < allServeEvents.size(); i++) { ServeEvent request = allServeEvents.get(i); @@ -350,7 +351,7 @@ public void createAndActivateVoucher() { @Before("@createVoucher") public void createVoucher() { iCreateAnIdentityMapperDTOForRegisterBeneficiary(); - mockServerStepDef.checkIfMockServerIsInjected(); + //mockServerStepDef.checkIfMockServerIsInjected(); mockServerStepDef.startMockServer(); mockServerStepDef.startStub("/createVoucher", PUT, 200); mockServerStepDef.startStub("/activateVoucher", PUT, 200); diff --git a/src/test/java/resources/billPay.feature b/src/test/java/resources/billPay.feature index d90dcee46..8488b39e0 100644 --- a/src/test/java/resources/billPay.feature +++ b/src/test/java/resources/billPay.feature @@ -76,15 +76,16 @@ Feature: Bill Payment P2G Test When I call the mock bills payment api from PBB to Biller with billid with expected status of 200 Then I should get non empty response - @gov + @gove Scenario: RTP-001 RTP Integration test - And I can register the stub with "/test" endpoint for "POST" request with status of 200 + #And I can inject MockServer + And I can register the stub with "/testing" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" And I have a billerId as "GovBill" And I generate clientCorrelationId And I create a new clientCorrelationId Then I can create DTO for Biller RTP Request - And I can call the biller RTP request API with expected status of 202 and "/test" endpoint + And I can call the biller RTP request API with expected status of 202 and "/testing" endpoint # Then I will sleep for 8000 millisecond And I can extract the callback body and assert the rtpStatus @@ -240,7 +241,7 @@ Feature: Bill Payment P2G Test And I can call the biller RTP request API with expected status of 400 and "/invalidBic" endpoint And I can extract the error from response body and assert the error information as "Payer Fsp details cannot be null or empty" - @gov + @gove Scenario: RTP-008 Request to Pay is unsuccessful because the specified account of the Payer FI was unreachable - did not respond (Txn timed out) And I can register the stub with "/payerUnreachable" endpoint for "POST" request with status of 200 Given I have tenant as "paymentBB2" @@ -252,7 +253,7 @@ Feature: Bill Payment P2G Test # Then I will sleep for 3000 millisecond And I can extract the error from callback body and assert error message as "Payer FI was unreachable" - @gov + @gove Scenario: RTP-009 Request to Pay is unsuccessful because the Payer FSP is unable to debit amount (insufficient amount/ blocked account/ account hold etc) (Payer FSP declines) And I can register the stub with "/debitFailed" endpoint for "POST" request with status of 200 diff --git a/src/test/java/resources/identityMapperTest.feature b/src/test/java/resources/identityMapperTest.feature index 63813758d..818e1d353 100644 --- a/src/test/java/resources/identityMapperTest.feature +++ b/src/test/java/resources/identityMapperTest.feature @@ -1,4 +1,4 @@ -@gov +@gove Feature: Identity Account Mapper Api Test Background: I will start mock server and register stub @@ -11,7 +11,7 @@ Feature: Identity Account Mapper Api Test And I can register the stub with "/accountLookup" endpoint for "PUT" request with status of 200 And I can register the stub with "/batchAccountLookup" endpoint for "PUT" request with status of 200 And I can register the stub with "/updateBeneficiaryApiTest" endpoint for "PUT" request with status of 200 - Then I will update the mock server and register stub as done + #Then I will update the mock server and register stub as done Scenario: IAM-001 Register Beneficiary Api Test diff --git a/src/test/java/resources/mockserver.feature b/src/test/java/resources/mockserver.feature index 2f72cdbab..ab1246344 100644 --- a/src/test/java/resources/mockserver.feature +++ b/src/test/java/resources/mockserver.feature @@ -1,4 +1,4 @@ - @gov + @govi Feature: Testing the startup and working of mockserver Scenario: MS-001 Mockserver config test diff --git a/src/test/java/resources/voucherManagementTest.feature b/src/test/java/resources/voucherManagementTest.feature index 382d49aa3..d37511b58 100644 --- a/src/test/java/resources/voucherManagementTest.feature +++ b/src/test/java/resources/voucherManagementTest.feature @@ -1,4 +1,4 @@ -@gov +@gove Feature: Voucher Management Api Test Scenario: Create Voucher Api Test From 28920d5e3cc434ab1f76552203f10b08db385c79 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Sun, 14 Apr 2024 23:09:28 +0530 Subject: [PATCH 42/48] style --- .../org/mifos/integrationtest/TestRunner.java | 22 +------------------ .../config/WireMockServerSingleton.java | 11 +++++----- .../cucumber/stepdef/BatchApiStepDef.java | 1 - .../cucumber/stepdef/GSMATransferStepDef.java | 1 - .../stepdef/IdentityMapperStepDef.java | 12 +++++----- .../cucumber/stepdef/MockServerStepDef.java | 14 ++++++------ .../stepdef/VoucherManagementStepDef.java | 2 +- 7 files changed, 20 insertions(+), 43 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/TestRunner.java b/src/test/java/org/mifos/integrationtest/TestRunner.java index f577f2732..23e7fc64e 100644 --- a/src/test/java/org/mifos/integrationtest/TestRunner.java +++ b/src/test/java/org/mifos/integrationtest/TestRunner.java @@ -1,9 +1,5 @@ package org.mifos.integrationtest; -import static com.github.tomakehurst.wiremock.client.WireMock.configureFor; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; - -import com.github.tomakehurst.wiremock.WireMockServer; import courgette.api.CourgetteAfterAll; import courgette.api.CourgetteBeforeAll; import courgette.api.CourgetteOptions; @@ -11,24 +7,8 @@ import courgette.api.CourgetteTestOutput; import courgette.api.CucumberOptions; import courgette.api.junit.Courgette; -import io.cucumber.java.BeforeAll; -import io.cucumber.junit.Cucumber; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.jupiter.api.AfterAll; import org.junit.runner.RunWith; -import org.mifos.integrationtest.config.MockServer; -import org.mifos.integrationtest.config.MockServerConfig; import org.mifos.integrationtest.config.WireMockServerSingleton; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; //@RunWith(Cucumber.class) //@CucumberOptions(features = { "src/test/java/resources" }, glue = { "org.mifos.integrationtest.cucumber" }, plugin = { @@ -36,7 +16,7 @@ // "junit:build/cucumber.xml" }) @RunWith(Courgette.class) -@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, testOutput = CourgetteTestOutput.CONSOLE, generateCourgetteRunLog = true , +@CourgetteOptions(threads = 3, runLevel = CourgetteRunLevel.FEATURE, rerunFailedScenarios = false, testOutput = CourgetteTestOutput.CONSOLE, generateCourgetteRunLog = true, reportTitle = "Paymenthub Test results", reportTargetDir = "build", cucumberOptions = @CucumberOptions(features = "src/test/java/resources", glue = "org.mifos.integrationtest.cucumber", tags = "@gov", publish = true, plugin = { "html:cucumber-report", "json:cucumber.json", "pretty", "html:build/cucumber-report.html", diff --git a/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java b/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java index 25d85f1a0..6937d1c4a 100644 --- a/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java +++ b/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java @@ -6,10 +6,9 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; - @Component public class WireMockServerSingleton { + static Logger logger = LoggerFactory.getLogger(WireMockServerSingleton.class); private static final ThreadLocal threadLocalInstance = new ThreadLocal<>(); @@ -17,9 +16,9 @@ public static WireMockServer getInstance() { WireMockServer instance = threadLocalInstance.get(); if (instance == null || !instance.isRunning()) { synchronized (WireMockServerSingleton.class) { - instance = threadLocalInstance.get(); // Double-check idiom + instance = threadLocalInstance.get(); // Double-check idiom if (instance == null || !instance.isRunning()) { - instance = startWireMockServerWithRetry(3); // Retry 3 times + instance = startWireMockServerWithRetry(3); // Retry 3 times threadLocalInstance.set(instance); } } @@ -46,7 +45,7 @@ private static WireMockServer startWireMockServerWithRetry(int maxRetries) { private static int getRandomPort() { // This returns a port number in the range 1024-65535 - return 1024 + (int)(Math.random() * ((65535 - 1024) + 1)); + return 1024 + (int) (Math.random() * ((65535 - 1024) + 1)); } public static int getPort() { @@ -57,4 +56,4 @@ public static int getPort() { throw new IllegalStateException("WireMock server is not running."); } } -} \ No newline at end of file +} diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BatchApiStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BatchApiStepDef.java index 52cdcb584..06332b757 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BatchApiStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BatchApiStepDef.java @@ -1,6 +1,5 @@ package org.mifos.integrationtest.cucumber.stepdef; -import static com.github.tomakehurst.wiremock.client.WireMock.getAllServeEvents; import static com.google.common.truth.Truth.assertThat; import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/GSMATransferStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/GSMATransferStepDef.java index edee0123a..15b5eaf8a 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/GSMATransferStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/GSMATransferStepDef.java @@ -1,6 +1,5 @@ package org.mifos.integrationtest.cucumber.stepdef; -import static com.github.tomakehurst.wiremock.client.WireMock.getAllServeEvents; import static com.google.common.truth.Truth.assertThat; import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java index fdd6f96eb..fdaef1d61 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java @@ -4,7 +4,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath; import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static com.google.common.truth.Truth.assertThat; import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; @@ -159,10 +158,10 @@ public void iCallTheAccountLookupAPITimesWithExpectedStatusOf(int count, int exp for (int i = 1; i < count; i++) { scenarioScopeState.response = RestAssured.given(requestSpec).header("Content-Type", "application/json") - .header("X-Registering-Institution-ID", sourceBBID).header("X-CallbackURL", identityMapperConfig.callbackURL+ port + endpoint) - .queryParam("payeeIdentity", payeeIdentity).queryParam("paymentModality", "00") - .queryParam("requestId", generateUniqueNumber(10)).queryParam("sourceBBID", sourceBBID) - .baseUri(identityMapperConfig.identityMapperContactPoint).expect() + .header("X-Registering-Institution-ID", sourceBBID) + .header("X-CallbackURL", identityMapperConfig.callbackURL + port + endpoint).queryParam("payeeIdentity", payeeIdentity) + .queryParam("paymentModality", "00").queryParam("requestId", generateUniqueNumber(10)) + .queryParam("sourceBBID", sourceBBID).baseUri(identityMapperConfig.identityMapperContactPoint).expect() .spec(new ResponseSpecBuilder().expectStatusCode(expectedStatus).build()).when() .get(identityMapperConfig.accountLookupEndpoint).andReturn().asString(); @@ -605,7 +604,8 @@ public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithNoOf int noOfFailedCases) { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { try { - WireMockServerSingleton.getInstance().verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.registerRequestID", equalTo(requestId)))); + WireMockServerSingleton.getInstance().verify( + putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.registerRequestID", equalTo(requestId)))); WireMockServerSingleton.getInstance().verify(putRequestedFor(urlEqualTo(endpoint)) .withRequestBody(matchingJsonPath("$.numberFailedCases", equalTo(String.valueOf(noOfFailedCases))))); assertTrue(true); diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java index b5e4552e7..00bf7d1da 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java @@ -37,16 +37,16 @@ public class MockServerStepDef extends BaseStepDef { @Given("I can inject MockServer") public void checkIfMockServerIsInjected() { assertThat(mockServer).isNotNull(); - //logger.info("{}", mockServer.getMockServer().baseUrl()); + // logger.info("{}", mockServer.getMockServer().baseUrl()); } @Then("I should be able to get instance of mock server") public void getInstanceOfMockServer() throws InterruptedException { - //assertThat(mockServer.getMockServer()).isNotNull(); - //assertThat(mockServer.getMockServer().port()).isEqualTo(53013); - //WireMockServerSingleton.getInstance + // assertThat(mockServer.getMockServer()).isNotNull(); + // assertThat(mockServer.getMockServer().port()).isEqualTo(53013); + // WireMockServerSingleton.getInstance assertThat(WireMockServerSingleton.getInstance()).isNotNull(); - //assertThat(WireMockServerSingleton.getInstance().port()).isEqualTo(53013); + // assertThat(WireMockServerSingleton.getInstance().port()).isEqualTo(53013); } @ParameterType(name = "httpMethod", value = ".*") @@ -73,7 +73,7 @@ public void startStub(String endpoint, HttpMethod httpMethod, int status) { // wireMockServer.stubFor(WireMock.put(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); WireMockServerSingleton.getInstance().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); - //mockServer.getMockServer().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); + // mockServer.getMockServer().stubFor(put(urlPathMatching(endpoint)).willReturn(status(status))); } case DELETE -> { // wireMockServer.stubFor(WireMock.delete(WireMock.urlEqualTo(endpoint)).willReturn(WireMock.aResponse().withStatus(200))); @@ -126,7 +126,7 @@ public void verifyStub(HttpMethod httpMethod, String endpoint, int numberOfReque @And("I can start mock server") public void startMockServer() { WireMockServerSingleton.getInstance(); - //mockServer.getMockServer().start(); + // mockServer.getMockServer().start(); configureFor("localhost", mockServer.getMockServer().port()); } diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java index a8fed7eb8..fbface6e5 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java @@ -351,7 +351,7 @@ public void createAndActivateVoucher() { @Before("@createVoucher") public void createVoucher() { iCreateAnIdentityMapperDTOForRegisterBeneficiary(); - //mockServerStepDef.checkIfMockServerIsInjected(); + // mockServerStepDef.checkIfMockServerIsInjected(); mockServerStepDef.startMockServer(); mockServerStepDef.startStub("/createVoucher", PUT, 200); mockServerStepDef.startStub("/activateVoucher", PUT, 200); From d9b33e3d669526f8779866fa630c69e4eb35ad81 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Sun, 14 Apr 2024 23:13:11 +0530 Subject: [PATCH 43/48] chexk --- .../mifos/integrationtest/config/WireMockServerSingleton.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java b/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java index 6937d1c4a..3dd709e5c 100644 --- a/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java +++ b/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java @@ -2,11 +2,13 @@ import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.common.FatalStartupException; +import lombok.NoArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @Component +@SuppressWarnings({ "FinalClass", "HideUtilityClassConstructor" }) public class WireMockServerSingleton { static Logger logger = LoggerFactory.getLogger(WireMockServerSingleton.class); From 4e25f999e6b92769a03a1675a079365ddcebaaf0 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Sun, 14 Apr 2024 23:15:25 +0530 Subject: [PATCH 44/48] chexk --- .../mifos/integrationtest/config/WireMockServerSingleton.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java b/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java index 3dd709e5c..c4200bf38 100644 --- a/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java +++ b/src/test/java/org/mifos/integrationtest/config/WireMockServerSingleton.java @@ -2,7 +2,6 @@ import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.common.FatalStartupException; -import lombok.NoArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; From 5b7b080293a6e89770b82c7554801e6edf9b9f51 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:21:56 +0530 Subject: [PATCH 45/48] change --- .../mifos/integrationtest/cucumber/stepdef/BaseStepDef.java | 4 ---- src/test/java/resources/batch.feature | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BaseStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BaseStepDef.java index 977743e98..5faa2cae2 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BaseStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BaseStepDef.java @@ -22,7 +22,6 @@ import org.mifos.integrationtest.config.ChannelConnectorConfig; import org.mifos.integrationtest.config.FspConfig; import org.mifos.integrationtest.config.IdentityMapperConfig; -import org.mifos.integrationtest.config.MockServer; import org.mifos.integrationtest.config.OperationsAppConfig; import org.mifos.integrationtest.config.TenantConfig; import org.mifos.integrationtest.config.VoucherManagementConfig; @@ -47,9 +46,6 @@ public class BaseStepDef { @Autowired ChannelConnectorConfig channelConnectorConfig; - @Autowired - MockServer mockServer; - @Autowired IdentityMapperConfig identityMapperConfig; diff --git a/src/test/java/resources/batch.feature b/src/test/java/resources/batch.feature index 34cfd7fb4..0d16ffef7 100644 --- a/src/test/java/resources/batch.feature +++ b/src/test/java/resources/batch.feature @@ -278,7 +278,7 @@ Feature: Batch Details API test #Given I can inject MockServer #And I can start mock server And I can register the stub with "/callback" endpoint for "POST" request with status of 200 - Then I will update the mock server and register stub as done + #Then I will update the mock server and register stub as done Given I have tenant as "paymentBB1" And I have the demo csv file "ph-ee-bulk-demo-7.csv" And I create a new clientCorrelationId From 81ff7bd5c30e35806f345b0eb793ac55deb67642 Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:30:08 +0530 Subject: [PATCH 46/48] changes --- .../cucumber/stepdef/BillPayStepDef.java | 20 +++++++++---------- .../stepdef/IdentityMapperStepDef.java | 2 +- .../cucumber/stepdef/MockServerStepDef.java | 6 +++--- .../stepdef/VoucherManagementStepDef.java | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java index 2c84feff1..f173f8b7c 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BillPayStepDef.java @@ -181,14 +181,14 @@ public void iCallTheMockBillsPaymentApiFromPBBToBillerWithBillidWithExpectedStat @Then("I should be able to verify that the {string} method to {string} endpoint received a request with code in body") public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedRequestWithASpecificBody(String httpmethod, String endpoint) { - mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.code"))); + WireMockServerSingleton.getInstance().verify(putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.code"))); } @Then("I should be able to extract response body from callback for bill pay") public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillPay() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -228,7 +228,7 @@ public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillPay() { public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillNotification() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -335,7 +335,7 @@ public void iCanExtractTheCallbackBodyAndAssertTheRtpStatus() { public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillerUnidentified() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -371,7 +371,7 @@ public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillerUnidentified( public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillInvalid() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -414,7 +414,7 @@ public void iShouldGetDataInResponse() throws JSONException { public void iShouldBeAbleToExtractResponseBodyFromCallbackForEmptyBillId() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -464,7 +464,7 @@ public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillNotificationWit public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillAlreadyPaid() { await().atMost(awaitMost, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { @@ -503,7 +503,7 @@ public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillAlreadyPaid() { public void iShouldNotBeAbleToRemoveAllServerEvents() { boolean flag = false; WireMock.resetAllRequests(); - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); assertThat(allServeEvents.size()).isEqualTo(0); } @@ -511,7 +511,7 @@ public void iShouldNotBeAbleToRemoveAllServerEvents() { public void iShouldNotBeAbleToExtractResponseBodyFromCallbackForBill() { await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); if (allServeEvents.isEmpty()) { flag = true; } else { @@ -531,7 +531,7 @@ public void iShouldNotBeAbleToExtractResponseBodyFromCallbackForBill() { public void iShouldBeAbleToExtractResponseBodyFromCallbackForBillPaidAfterTimeout() { await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { boolean flag = false; - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); for (int i = allServeEvents.size() - 1; i >= 0; i--) { ServeEvent request = allServeEvents.get(i); if (!(request.getRequest().getBodyAsString()).isEmpty()) { diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java index fdaef1d61..892a0a810 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java @@ -532,7 +532,7 @@ public void iCreateAIdentityMapperDTOForRegisteringBeneficiary() { public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithSuccessfullRegistration(String httpMethod, String stub) { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); for (int i = 0; i < allServeEvents.size(); i++) { ServeEvent request = allServeEvents.get(i); diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java index 00bf7d1da..16786869c 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java @@ -36,7 +36,7 @@ public class MockServerStepDef extends BaseStepDef { @Given("I can inject MockServer") public void checkIfMockServerIsInjected() { - assertThat(mockServer).isNotNull(); + assertThat(WireMockServerSingleton.getInstance()).isNotNull(); // logger.info("{}", mockServer.getMockServer().baseUrl()); } @@ -127,12 +127,12 @@ public void verifyStub(HttpMethod httpMethod, String endpoint, int numberOfReque public void startMockServer() { WireMockServerSingleton.getInstance(); // mockServer.getMockServer().start(); - configureFor("localhost", mockServer.getMockServer().port()); + configureFor("localhost", WireMockServerSingleton.getInstance().port()); } @And("I can stop mock server") public void stopMockServer() { - mockServer.getMockServer().stop(); + WireMockServerSingleton.getInstance().stop(); } @Given("I will start the mock server") diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java index fbface6e5..e8d496ec1 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/VoucherManagementStepDef.java @@ -182,7 +182,7 @@ public void iCallTheCancelVoucherAPIWithExpectedStatusOfAndStub(int expectedStat @Then("I should be able to verify that the {string} method to {string} endpoint received a request with required parameter in redeem voucher callback body") public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithRequiredParameterInRedeemVoucherCallbackBody(String arg0, String endpoint) { - mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)) + WireMockServerSingleton.getInstance().verify(putRequestedFor(urlEqualTo(endpoint)) .withRequestBody(matchingJsonPath("$.requestID", equalTo(scenarioScopeState.requstId)))); } @@ -449,7 +449,7 @@ public void iCanExtractResultFromValidationCallbackAndAssertIfValidationIsSucces await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> { // (putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.isValid", equalTo("true")))); - List allServeEvents = mockServer.getMockServer().getAllServeEvents(); + List allServeEvents = WireMockServerSingleton.getInstance().getAllServeEvents(); String serialNo = null; String isValid = null; for (int i = 0; i < allServeEvents.size(); i++) { @@ -489,9 +489,9 @@ public void iCanAssertThatRedemptionWasUnsuccessfulByAssertingTheStatusInRespons public void iShouldBeAbleToAssertResponseBodyFromCallback(String endpoint) { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { try { - mockServer.getMockServer().verify(putRequestedFor(urlEqualTo(endpoint)) + WireMockServerSingleton.getInstance().verify(putRequestedFor(urlEqualTo(endpoint)) .withRequestBody(matchingJsonPath("$.registerRequestId", equalTo(scenarioScopeState.requestId)))); - mockServer.getMockServer().verify( + WireMockServerSingleton.getInstance().verify( putRequestedFor(urlEqualTo(endpoint)).withRequestBody(matchingJsonPath("$.numberFailedCases", equalTo("0")))); assertTrue(true);// success } catch (VerificationException e) { From aa6734c128c790b09407fd250609885f94fe431d Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:33:37 +0530 Subject: [PATCH 47/48] changes --- .../integrationtest/cucumber/stepdef/MockServerStepDef.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java index 16786869c..918186e54 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MockServerStepDef.java @@ -84,7 +84,7 @@ public void startStub(String endpoint, HttpMethod httpMethod, int status) { @When("I make the {httpMethod} request to {string} endpoint with expected status of {int}") public void hitStubEndpoint(HttpMethod httpMethod, String endpoint, int expectedStatus) { - RequestSender requestSender = RestAssured.given(getDefaultSpec()).baseUri(mockServer.getBaseUri()).expect() + RequestSender requestSender = RestAssured.given(getDefaultSpec()).baseUri("http://localhost").expect() .spec(new ResponseSpecBuilder().expectStatusCode(expectedStatus).build()).when(); switch (httpMethod) { From 40424745639c7404d71f13ecb81e719e25115e4f Mon Sep 17 00:00:00 2001 From: Apurb Rajdhan <103931815+apurbraj@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:57:37 +0530 Subject: [PATCH 48/48] tag --- src/test/java/resources/identityMapperTest.feature | 2 +- src/test/java/resources/voucherManagementTest.feature | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/resources/identityMapperTest.feature b/src/test/java/resources/identityMapperTest.feature index 818e1d353..cf4f4325f 100644 --- a/src/test/java/resources/identityMapperTest.feature +++ b/src/test/java/resources/identityMapperTest.feature @@ -1,4 +1,4 @@ -@gove +@gov Feature: Identity Account Mapper Api Test Background: I will start mock server and register stub diff --git a/src/test/java/resources/voucherManagementTest.feature b/src/test/java/resources/voucherManagementTest.feature index d37511b58..382d49aa3 100644 --- a/src/test/java/resources/voucherManagementTest.feature +++ b/src/test/java/resources/voucherManagementTest.feature @@ -1,4 +1,4 @@ -@gove +@gov Feature: Voucher Management Api Test Scenario: Create Voucher Api Test