From 28bd0970007a1bbe409f56e9d7183c573801b11a Mon Sep 17 00:00:00 2001 From: Abhinav Mishra <150892830+abhinavm117@users.noreply.github.com> Date: Thu, 11 Jul 2024 14:56:01 +0530 Subject: [PATCH] Govstack demo tcs and Co-dev Tcs (#312) --- .circleci/config.yml | 49 +- .jit/jit-integration.yml | 1 + .../cucumber/stepdef/BatchApiStepDef.java | 1 - .../cucumber/stepdef/GSMATransferStepDef.java | 101 +++- .../stepdef/IdentityMapperStepDef.java | 25 +- .../cucumber/stepdef/MojaloopStepDef.java | 63 ++- .../stepdef/PayerFundTransferDef.java | 2 +- .../stepdef/PayerFundTransferStepDef.java | 164 ++++++- .../org/mifos/integrationtest/util/Util.java | 12 + src/test/java/resources/batch.feature | 4 +- ...ansactioClosedLoopMojaloopFundTransfer.csv | 9 + .../batch_demo_csv/batchTransaction.csv | 4 + .../batchTransactionGsmaClosedLoop.csv | 9 - src/test/java/resources/bulkPayment.feature | 441 +++++++++++++++++- 14 files changed, 831 insertions(+), 54 deletions(-) create mode 100644 src/test/java/org/mifos/integrationtest/util/Util.java create mode 100644 src/test/java/resources/batch_demo_csv/batchTransactioClosedLoopMojaloopFundTransfer.csv create mode 100644 src/test/java/resources/batch_demo_csv/batchTransaction.csv delete mode 100644 src/test/java/resources/batch_demo_csv/batchTransactionGsmaClosedLoop.csv diff --git a/.circleci/config.yml b/.circleci/config.yml index d0f3d0736..57081008b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -234,6 +234,45 @@ jobs: path: build/test-results/test/TEST-org.mifos.integrationtest.TestRunner.xml - store_artifacts: path: build/test-results + + test-chart-e2e: + docker: + - image: cimg/openjdk:17.0.0-node + steps: + - checkout + #- run: git clone https://github.com/fynarfin/ph-ee-integration-test + - run: + name: Ngrok setup + command: curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list && sudo apt update && sudo apt install ngrok + - run: + name: Test execution + no_output_timeout: 30m + command: | + ngrok config add-authtoken $AUTH_TOKEN + echo "web_addr: $LOCAL_PORT" >> /home/circleci/.config/ngrok/ngrok.yml + ngrok http 53013 > /dev/null & + echo -n "Extracting ngrok public url ." + NGROK_PUBLIC_URL="" + while [ -z "$NGROK_PUBLIC_URL" ]; do + # Run 'curl' against ngrok API and extract public (using 'sed' command) + export NGROK_PUBLIC_URL=$(curl --silent --max-time 10 --connect-timeout 5 \ + --show-error http://127.0.0.1:$LOCAL_PORT/api/tunnels | \ + sed -nE 's/.*public_url":"https:..([^"]*).*/\1/p') + sleep 1 + echo -n "." + done + + export CALLBACK_URL="https://$NGROK_PUBLIC_URL" + echo -n "Public url ." + echo $CALLBACK_URL + ./gradlew test -Dcucumber.filter.tags="@e2e" + echo -n "Test execution is completed, kill ngrok" + pkill ngrok + - store_test_results: + path: build/test-results/test/TEST-org.fynarfin.integrationtest.TestRunner.xml + - store_artifacts: + path: build/test-results + test-chart-ams: docker: - image: cimg/openjdk:17.0.0 @@ -318,7 +357,7 @@ workflows: - AWS - Helm - slack - - test-chart-ams: + - test-chart-e2e: requires: - deploying-bpmns context: @@ -326,6 +365,14 @@ workflows: - Helm - slack - Ngrok + - test-chart-ams: + requires: + - test-chart-e2e + context: + - AWS + - Helm + - slack + - Ngrok - test-chart-gov: requires: - test-chart-ams diff --git a/.jit/jit-integration.yml b/.jit/jit-integration.yml index e69de29bb..8b1378917 100644 --- a/.jit/jit-integration.yml +++ b/.jit/jit-integration.yml @@ -0,0 +1 @@ + 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 5b6296d53..174697c6a 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BatchApiStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/BatchApiStepDef.java @@ -311,7 +311,6 @@ public void callBatchTransactionsEndpoint(int expectedStatus) { RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant, scenarioScopeState.clientCorrelationId); requestSpec.header(HEADER_PURPOSE, "Integartion test"); requestSpec.header(HEADER_FILENAME, scenarioScopeState.filename); - requestSpec.header(HEADER_REGISTERING_INSTITUTE_ID, "SocialWelfare"); requestSpec.queryParam(QUERY_PARAM_TYPE, "CSV"); requestSpec.header(QUERY_PARAM_TYPE, "CSV"); if (scenarioScopeState.signature != null && !scenarioScopeState.signature.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 dad45a985..3b0c2a380 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.util.Util; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -431,10 +432,10 @@ public void iCallTheBalanceApiForPayerBalance() throws JsonProcessingException { finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.debitParty.isEmpty() ? scenarioScopeState.payerIdentifier : scenarioScopeState.debitParty); - logger.info("Endpoint: " + finalEndpoint); + logger.info("Endpoint: {}", finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); - logger.info("Balance Response: " + scenarioScopeState.response); + logger.info("Balance Response: {}", scenarioScopeState.response); InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class); assertThat(interopAccountDTO.getAvailableBalance().intValue() <= scenarioScopeState.initialBalForPayer).isTrue(); scenarioScopeState.gsmaP2PAmtDebit = 0; @@ -448,10 +449,10 @@ public void iCallTheBalanceApiForPayeeBalance() throws JsonProcessingException { finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.creditParty.isEmpty() ? scenarioScopeState.payeeIdentifier : scenarioScopeState.creditParty); - logger.info("Endpoint: " + finalEndpoint); + logger.info("Endpoint: {}", finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); - logger.info("Balance Response: " + scenarioScopeState.response); + logger.info("Balance Response: {}", scenarioScopeState.response); InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class); assertThat(interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayee).isTrue(); @@ -468,7 +469,7 @@ public void iCallTheBalanceApiForPayerBalanceAfterDebit() throws JsonProcessingE logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); - logger.info("Balance Response: " + scenarioScopeState.response); + logger.info("Balance Response: {}", scenarioScopeState.response); InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class); assertThat(interopAccountDTO.getAvailableBalance().intValue() == scenarioScopeState.initialBalForPayer - scenarioScopeState.gsmaP2PAmtDebit).isTrue(); @@ -484,10 +485,10 @@ public void iCallTheBalanceApiForPayeeBalanceAfterCredit() throws JsonProcessing finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.creditParty.isEmpty() ? scenarioScopeState.payeeIdentifier : scenarioScopeState.creditParty); - logger.info("Endpoint: " + finalEndpoint); + logger.info("Endpoint: {}", finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); - logger.info("Balance Response: " + scenarioScopeState.response); + logger.info("Balance Response: {}", scenarioScopeState.response); InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class); assertThat(interopAccountDTO.getAvailableBalance().intValue() == scenarioScopeState.initialBalForPayee + scenarioScopeState.gsmaP2PAmtDebit).isTrue(); @@ -690,7 +691,7 @@ public void iCallTheBalanceApiForPayeeBalance(String id) throws JsonProcessingEx logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); - logger.info("Balance Response: " + scenarioScopeState.response); + logger.info("Balance Response: {}", scenarioScopeState.response); InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class); assertThat( interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)]) @@ -712,7 +713,71 @@ public void iCallTheBalanceApiForPayeeBalanceForCombinedTestsCases(String id) th logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); - logger.info("Balance Response: " + scenarioScopeState.response); + logger.info("Balance Response: {}", scenarioScopeState.response); + InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class); + assertThat( + interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)]) + .isTrue(); + + } + + @Then("I call the balance api for payer {string} balance for all combine test cases") + public void iCallTheBalanceApiForAllPayerBalanceForCombinedTestCases(String id) throws JsonProcessingException { + RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant); + String finalEndpoint = amsBalanceEndpoint; + // Check whether a new batch been initialized + initializeIfNotInitialized(id); + scenarioScopeState.payerIdentifierforBatch[Integer.parseInt(id)] = scenarioScopeState.payerIdentifier; + String accountId = (scenarioScopeState.debitParty == null) ? scenarioScopeState.payerIdentifier : scenarioScopeState.debitParty; + String identifierType = "MSISDN"; + finalEndpoint = Util.getFormattedEndpoint(finalEndpoint, "{IdentifierType}", identifierType); + finalEndpoint = Util.getFormattedEndpoint(finalEndpoint, "{IdentifierId}", accountId); + logger.info("Endpoint: {} ", finalEndpoint); + scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() + .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); + logger.info("Balance Response: {}", scenarioScopeState.response); + InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class); + assertThat( + interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)]) + .isTrue(); + } + + public void initializeIfNotInitialized(String id) { + if (shouldInitializeArray(id)) { + scenarioScopeState.payerIdentifierforBatch = new String[15]; + } + } + + private boolean shouldInitializeArray(String id) { + return scenarioScopeState.payerIdentifierforBatch == null || id.equals("1"); + } + + public void initializeIfNotInitializedForPayee(String id) { + if (shouldInitializeArrayForPayee(id)) { + scenarioScopeState.payeeIdentifierforBatch = new String[15]; + } + } + + private boolean shouldInitializeArrayForPayee(String id) { + return scenarioScopeState.payeeIdentifierforBatch == null || id.equals("1"); + } + + @Then("I call the balance api for payee {string} balance for all combine test cases") + public void iCallTheBalanceApiForPayeeBalanceForAllCombinedTestsCases(String id) throws JsonProcessingException { + RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant); + String finalEndpoint = amsBalanceEndpoint; + + initializeIfNotInitializedForPayee(id); + scenarioScopeState.payeeIdentifierforBatch[Integer.parseInt(id)] = scenarioScopeState.payeeIdentifier; + String identifierId = (scenarioScopeState.creditParty == null) ? scenarioScopeState.payeeIdentifier + : scenarioScopeState.creditParty; + String identifierType = "MSISDN"; + finalEndpoint = Util.getFormattedEndpoint(finalEndpoint, "{IdentifierType}", identifierType); + finalEndpoint = Util.getFormattedEndpoint(finalEndpoint, "{IdentifierId}", identifierId); + logger.info("Endpoint: {}", finalEndpoint); + scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() + .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); + logger.info("Balance Response: {}", scenarioScopeState.response); InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class); assertThat( interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)]) @@ -724,16 +789,18 @@ public void iCallTheBalanceApiForPayeeBalanceForCombinedTestsCases(String id) th public void iCallTheBalanceApiForPayeeBalanceAfterCredit(String id) throws JsonProcessingException { RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant); String finalEndpoint = amsBalanceEndpoint; - finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); - finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.payeeIdentifierforBatch[Integer.parseInt(id)]); - logger.info("Endpoint: " + finalEndpoint); + String identifierId = (scenarioScopeState.creditParty == null) ? scenarioScopeState.payeeIdentifier + : scenarioScopeState.creditParty; + String identifierType = "MSISDN"; + finalEndpoint = Util.getFormattedEndpoint(finalEndpoint, "{IdentifierType}", identifierType); + finalEndpoint = Util.getFormattedEndpoint(finalEndpoint, "{IdentifierId}", identifierId); + logger.info("Endpoint: {}", finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); - logger.info("Balance Response: " + scenarioScopeState.response); + logger.info("Balance Response: {}", scenarioScopeState.response); InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class); assertThat(interopAccountDTO.getAvailableBalance().intValue() == scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)] + scenarioScopeState.gsmaP2PAmtDebitForBatch[Integer.parseInt(id)]).isTrue(); - } @Then("I call the balance api for payer {string} balance") @@ -749,7 +816,7 @@ public void iCallTheBalanceApiForPayerBalance(String id) throws JsonProcessingEx logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); - logger.info("Balance Response: " + scenarioScopeState.response); + logger.info("Balance Response: {}", scenarioScopeState.response); InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class); assertThat( interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)]) @@ -771,7 +838,7 @@ public void iCallTheBalanceApiForPayerBalanceForCombinedTestCases(String id) thr logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); - logger.info("Balance Response: " + scenarioScopeState.response); + logger.info("Balance Response: {}", scenarioScopeState.response); InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class); assertThat( interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)]) @@ -788,7 +855,7 @@ public void iCallTheBalanceApiForPayerBalanceAfterDebit(String id) throws JsonPr logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); - logger.info("Balance Response: " + scenarioScopeState.response); + logger.info("Balance Response: {}", scenarioScopeState.response); InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class); int originBal = scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)]; int debitAmt = scenarioScopeState.gsmaP2PAmtDebitForBatch[Integer.parseInt(id)]; 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 862071084..954c01c91 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/IdentityMapperStepDef.java @@ -25,8 +25,10 @@ import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; import org.json.JSONArray; import org.json.JSONException; @@ -74,9 +76,9 @@ public class IdentityMapperStepDef extends BaseStepDef { public void iCallTheRegisterBeneficiaryAPIWithExpectedStatusOf(int expectedStatus, String stub) { RequestSpecification requestSpec = Utils.getDefaultSpec(); scenarioScopeState.response = RestAssured.given(requestSpec).header("Content-Type", "application/json") - .header("X-Registering-Institution-ID", sourceBBID).header("X-CallbackURL", identityMapperConfig.callbackURL + stub) - .baseUri(identityMapperConfig.identityMapperContactPoint).body(registerBeneficiaryBody).expect() - .spec(new ResponseSpecBuilder().expectStatusCode(expectedStatus).build()).when() + .header("X-Registering-Institution-ID", scenarioScopeState.registeringInstituteId) + .header("X-CallbackURL", identityMapperConfig.callbackURL + stub).baseUri(identityMapperConfig.identityMapperContactPoint) + .body(registerBeneficiaryBody).expect().spec(new ResponseSpecBuilder().expectStatusCode(expectedStatus).build()).when() .post(identityMapperConfig.registerBeneficiaryEndpoint).andReturn().asString(); logger.info("Identity Mapper Response: {}", scenarioScopeState.response); @@ -526,6 +528,23 @@ public void iCreateAIdentityMapperDTOForRegisteringBeneficiary() { registerBeneficiaryBody = new AccountMapperRequestDTO(requestId, sourceBBID, beneficiaryDTOList); } + @And("I create a IdentityMapperDTO for registering payee with IAM") + public void iCreateAIdentityMapperDTOForRegisteringPayee() { + List beneficiaryDTOList = new ArrayList<>(); + String payeeFsp = "payeefsp3"; + String[] financialAddressArray = { "1234", "1235", "1236" }; + int fspIndex = 0; + Set payeeIdentifiers = new HashSet<>(scenarioScopeState.payeeIdentifiers); + for (String payeeIdentifier : payeeIdentifiers) { + BeneficiaryDTO beneficiaryDTO = new BeneficiaryDTO(payeeIdentifier, "00", financialAddressArray[fspIndex], + payeeFspConfig.getPayeeFsp(payeeFsp)); + beneficiaryDTOList.add(beneficiaryDTO); + fspIndex++; + } + requestId = generateUniqueNumber(12); + registerBeneficiaryBody = new AccountMapperRequestDTO(requestId, sourceBBID, beneficiaryDTOList); + } + @And("I should be able to verify that the {string} method to {string} endpoint received a request with successfull registration") public void iShouldBeAbleToVerifyThatTheMethodToEndpointReceivedARequestWithSuccessfullRegistration(String httpMethod, String stub) { await().atMost(awaitMost, SECONDS).untilAsserted(() -> { diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MojaloopStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MojaloopStepDef.java index 9209182b6..c1ce820d5 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MojaloopStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/MojaloopStepDef.java @@ -11,6 +11,7 @@ import io.restassured.specification.RequestSpecification; import org.mifos.integrationtest.common.Utils; import org.mifos.integrationtest.config.MojaloopConfig; +import org.mifos.integrationtest.util.Util; import org.springframework.beans.factory.annotation.Autowired; public class MojaloopStepDef extends BaseStepDef { @@ -24,6 +25,8 @@ public class MojaloopStepDef extends BaseStepDef { @Autowired ScenarioScopeState scenarioScopeState; + private static final String CONTENT_TYPE = "application/vnd.interoperability.participants+json;version=1.0"; + @Then("I add {string} to als") public void addUsersToALS(String client) throws JsonProcessingException { @@ -51,7 +54,7 @@ public void addUsersToALS(String client) throws JsonProcessingException { RequestSpecification requestSpec = Utils.getDefaultSpec(); requestSpec.header("FSPIOP-Source", fspId); requestSpec.header("Date", getCurrentDateInFormat()); - requestSpec.header("Accept", "application/vnd.interoperability.participants+json;version=1"); + requestSpec.header("Accept", CONTENT_TYPE); // requestSpec.header("Content-Type", "application/vnd.interoperability.participants+json;version=1.0"); String endpoint = mojaloopConfig.addUserToAlsEndpoint; @@ -66,7 +69,58 @@ public void addUsersToALS(String client) throws JsonProcessingException { String response = RestAssured.given(requestSpec).baseUri(mojaloopConfig.mojaloopBaseurl) .config(RestAssured.config().encoderConfig(encoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false))) - .body(requestBody).contentType("application/vnd.interoperability.participants+json;version=1.0").expect() + .body(requestBody).contentType(CONTENT_TYPE).expect().spec(new ResponseSpecBuilder().expectStatusCode(202).build()).when() + .post(endpoint).andReturn().asString(); + + logger.info(response); + assertThat(response).isNotNull(); + } + + @Then("I add {string} with account id {string} to als") + public void addBudgetAccountToALS(String client, String accountId) throws JsonProcessingException { + + String clientIdentifierId; + String fspId; + switch (client) { + case "payer" -> { + clientIdentifierId = scenarioScopeState.payerIdentifier; + fspId = mojaloopConfig.payerFspId; + } + case "payee2" -> { + clientIdentifierId = scenarioScopeState.payeeIdentifier; + fspId = mojaloopConfig.payeeFspId2; + } + case "payee3" -> { + clientIdentifierId = scenarioScopeState.payeeIdentifier; + fspId = mojaloopConfig.payeeFspId3; + } + default -> { + clientIdentifierId = scenarioScopeState.payeeIdentifier; + fspId = mojaloopConfig.payeeFspId; + } + } + + RequestSpecification requestSpec = Utils.getDefaultSpec(); + requestSpec.header("FSPIOP-Source", fspId); + requestSpec.header("Date", getCurrentDateInFormat()); + requestSpec.header("Accept", CONTENT_TYPE); + + String endpoint = mojaloopConfig.addUserToAlsEndpoint; + String identifierType = "MSISDN"; + endpoint = Util.getFormattedEndpoint(endpoint, "{{identifierType}}", identifierType); + endpoint = Util.getFormattedEndpoint(endpoint, "{{identifier}}", accountId); + String identifierId = (scenarioScopeState.creditParty == null) ? scenarioScopeState.payeeIdentifier + : scenarioScopeState.creditParty; + endpoint = String.format(endpoint, identifierType, identifierId); + String requestBody = mojaloopDef.setBodyAddAlsUser(fspId); + + logger.info(mojaloopConfig.mojaloopBaseurl); + logger.info(requestBody); + logger.info(endpoint); + + String response = RestAssured.given(requestSpec).baseUri(mojaloopConfig.mojaloopBaseurl) + .config(RestAssured.config().encoderConfig(encoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false))) + .body(requestBody).contentType(CONTENT_TYPE).expect() .spec(new ResponseSpecBuilder().expectStatusCode(202).build()).when().post(endpoint).andReturn().asString(); logger.info(response); @@ -81,7 +135,6 @@ public void mojaloopSetup() throws JsonProcessingException { String payeeFsp2 = mojaloopConfig.payeeFspId2; String payeeFsp3 = mojaloopConfig.payeeFspId3; - if (!mojaloopDef.isHubAccountTypesAdded()) { logger.info("Calling hub account apis"); @@ -107,8 +160,8 @@ public void mojaloopSetup() throws JsonProcessingException { mojaloopDef.addInitialPositionAndLimit(payeeFsp2); mojaloopDef.addInitialPositionAndLimit(payeeFsp3); - if (!mojaloopDef.getCallbackEndpoints(payerFsp) || !mojaloopDef.getCallbackEndpoints(payeeFsp) || !mojaloopDef.getCallbackEndpoints(payeeFsp2) - || !mojaloopDef.getCallbackEndpoints(payeeFsp3)) { + if (!mojaloopDef.getCallbackEndpoints(payerFsp) || !mojaloopDef.getCallbackEndpoints(payeeFsp) + || !mojaloopDef.getCallbackEndpoints(payeeFsp2) || !mojaloopDef.getCallbackEndpoints(payeeFsp3)) { mojaloopDef.setCallbackEndpoints(); } diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/PayerFundTransferDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/PayerFundTransferDef.java index 5a4c04263..4bdc7621b 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/PayerFundTransferDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/PayerFundTransferDef.java @@ -155,7 +155,7 @@ protected String setBodySavingsAccount(String client) throws JsonProcessingExcep // Getting resourceId and clientId PostClientsResponse createPayerClientResponse; - if (client.equals("payer")) { + if (("payer").equals(client)) { createPayerClientResponse = objectMapper.readValue(responsePayerClient, PostClientsResponse.class); } else { createPayerClientResponse = objectMapper.readValue(responsePayeeClient, PostClientsResponse.class); diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/PayerFundTransferStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/PayerFundTransferStepDef.java index 9926590ae..373b8f6d2 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/PayerFundTransferStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/PayerFundTransferStepDef.java @@ -33,6 +33,7 @@ import org.mifos.integrationtest.common.Utils; import org.mifos.integrationtest.config.MojaloopConfig; import org.mifos.integrationtest.config.PayerFundTransferConfig; +import org.mifos.integrationtest.util.Util; import org.springframework.beans.factory.annotation.Autowired; public class PayerFundTransferStepDef extends BaseStepDef { @@ -42,6 +43,8 @@ public class PayerFundTransferStepDef extends BaseStepDef { private static String payer_identifier; + private static String savings_account_id; + private static String payee_identifier; private static String quoteId; @@ -103,7 +106,7 @@ public void callCreateClientEndpoint(String client) throws JsonProcessingExcepti .expect().spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().post(transferConfig.clientEndpoint) .andReturn().asString(); - if (client.equals("payer")) { + if ("payer".equals(client)) { fundTransferDef.responsePayerClient = clientResponse; assertThat(fundTransferDef.responsePayerClient).isNotEmpty(); } else { @@ -158,7 +161,7 @@ public void callCreateInteropIdentifierEndpoint(String client) throws JsonProces fundTransferDef.interopIdentifierBody = fundTransferDef.setBodyInteropIdentifier(); // Setting account ID in path - String responseSavingsAccount = client.equals("payer") ? fundTransferDef.responseSavingsAccountPayer + String responseSavingsAccount = ("payer").equals(client) ? fundTransferDef.responseSavingsAccountPayer : fundTransferDef.responseSavingsAccountPayee; PostSavingsAccountsResponse savingsAccountResponse = objectMapper.readValue(responseSavingsAccount, @@ -182,7 +185,44 @@ public void callCreateInteropIdentifierEndpoint(String client) throws JsonProces .body(fundTransferDef.interopIdentifierBody).expect().spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when() .post(endpoint).andReturn().asString(); - logger.info("Interop Identifier Response: " + fundTransferDef.responseInteropIdentifier); + logger.info("Interop Identifier Response: {}", fundTransferDef.responseInteropIdentifier); + assertThat(fundTransferDef.responseInteropIdentifier).isNotEmpty(); + } + + @Then("I call the interop identifier endpoint for {string} and accountId {string}") + public void callCreateInteropBudgetIdentifierEndpoint(String client, String accountId) throws JsonProcessingException { + // Setting headers and body + RequestSpecification requestSpec = Utils.getDefaultSpec(); + requestSpec = fundTransferDef.setHeaders(requestSpec); + fundTransferDef.interopIdentifierBody = fundTransferDef.setBodyInteropIdentifier(); + // Setting account ID in path + + String responseSavingsAccount = ("payer").equals(client) ? fundTransferDef.responseSavingsAccountPayer + : fundTransferDef.responseSavingsAccountPayee; + + PostSavingsAccountsResponse savingsAccountResponse = objectMapper.readValue(responseSavingsAccount, + PostSavingsAccountsResponse.class); + savings_account_id = savingsAccountResponse.getSavingsId().toString(); + + if (client.equals("payer")) { + payer_identifier = accountId; + scenarioScopeState.payerIdentifier = accountId; + } else { + payee_identifier = accountId; + scenarioScopeState.payeeIdentifier = accountId; + } + + String endpoint = transferConfig.interopIdentifierEndpoint; + String identifierType = "MSISDN"; + endpoint = Util.getFormattedEndpoint(endpoint, "{{identifierType}}", identifierType); + endpoint = Util.getFormattedEndpoint(endpoint, "{{identifier}}", accountId); + + // Calling Interop Identifier endpoint + fundTransferDef.responseInteropIdentifier = RestAssured.given(requestSpec).baseUri(transferConfig.savingsBaseUrl) + .body(fundTransferDef.interopIdentifierBody).expect().spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when() + .post(endpoint).andReturn().asString(); + + logger.info("Interop Identifier Response: {}", fundTransferDef.responseInteropIdentifier); assertThat(fundTransferDef.responseInteropIdentifier).isNotEmpty(); } @@ -206,7 +246,31 @@ public void callApproveSavingsEndpoint(String command, String client) throws Jso .body(fundTransferDef.savingsApproveBody).expect().spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when() .post(endpoint).andReturn().asString(); - logger.info("Savings Approve Response: " + fundTransferDef.responseSavingsApprove); + logger.info("Savings Approve Response: {}", fundTransferDef.responseSavingsApprove); + assertThat(fundTransferDef.responseSavingsApprove).isNotEmpty(); + } + + @Then("I approve the deposit for Budget Account with command {string} for {string}") + public void callApproveBudgetAccountEndpoint(String command, String client) throws JsonProcessingException { + // Setting headers and body + RequestSpecification requestSpec = Utils.getDefaultSpec(); + requestSpec = fundTransferDef.setHeaders(requestSpec); + requestSpec.queryParam("command", command); + fundTransferDef.savingsApproveBody = fundTransferDef.setBodySavingsApprove(); + String endpoint = transferConfig.savingsApproveEndpoint; + + if (client.equals("payer")) { + endpoint = Util.getFormattedEndpoint(endpoint, "{{savingsAccId}}", savings_account_id); + } else { + endpoint = Util.getFormattedEndpoint(endpoint, "{{savingsAccId}}", savings_account_id); + } + + // Calling create loan account endpoint + fundTransferDef.responseSavingsApprove = RestAssured.given(requestSpec).baseUri(transferConfig.savingsBaseUrl) + .body(fundTransferDef.savingsApproveBody).expect().spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when() + .post(endpoint).andReturn().asString(); + + logger.info("Savings Approve Response: {}", fundTransferDef.responseSavingsApprove); assertThat(fundTransferDef.responseSavingsApprove).isNotEmpty(); } @@ -229,7 +293,30 @@ public void callSavingsActivateEndpoint(String command, String client) throws Js .body(fundTransferDef.savingsActivateBody).expect().spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when() .post(endpoint).andReturn().asString(); - logger.info("Savings Activate Response: " + fundTransferDef.responseSavingsActivate); + logger.info("Savings Activate Response: {}", fundTransferDef.responseSavingsActivate); + assertThat(fundTransferDef.responseSavingsActivate).isNotEmpty(); + } + + @When("I activate the budget account with command {string} for {string}") + public void callBudgetAccountActivateEndpoint(String command, String client) throws JsonProcessingException { + // Setting headers and body + RequestSpecification requestSpec = Utils.getDefaultSpec(); + requestSpec = fundTransferDef.setHeaders(requestSpec); + requestSpec.queryParam("command", command); + fundTransferDef.savingsActivateBody = fundTransferDef.setBodySavingsActivate(); + + String endpoint = transferConfig.savingsActivateEndpoint; + if (client.equals("payer")) { + endpoint = Util.getFormattedEndpoint(endpoint, "{{savingsAccId}}", savings_account_id); + } else { + endpoint = Util.getFormattedEndpoint(endpoint, "{{savingsAccId}}", savings_account_id); + } + // Calling create loan account endpoint + fundTransferDef.responseSavingsActivate = RestAssured.given(requestSpec).baseUri(transferConfig.savingsBaseUrl) + .body(fundTransferDef.savingsActivateBody).expect().spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when() + .post(endpoint).andReturn().asString(); + + logger.info("Savings Activate Response: {}", fundTransferDef.responseSavingsActivate); assertThat(fundTransferDef.responseSavingsActivate).isNotEmpty(); } @@ -555,6 +642,47 @@ public void addRowToCsvFileForCombinedTestCases(String paymentMode, int transfer scenarioScopeState.gsmaP2PAmtDebitForBatch[id + 1] = transferAmount; } + @When("I create and setup a {string} with id {string} and account balance of {int} for all combine test cases") + public void consolidatedPayeeCreationStepsForAllCombinedTestsCases(String client, String id, int amount) + throws JsonProcessingException { + setTenantForPayer(client); + callCreateClientEndpoint(client); + callCreateSavingsProductEndpoint(client); + callCreateSavingsAccountEndpoint(client); + callCreateInteropIdentifierEndpoint(client); + callApproveSavingsEndpoint("approve", client); + callSavingsActivateEndpoint("activate", client); + callDepositAccountEndpoint("deposit", amount, client); + if (client.equals("payer")) { + if (scenarioScopeState.initialBalForPayerForBatch == null || id.equals("1")) { + scenarioScopeState.initialBalForPayerForBatch = new int[14]; + } + scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)] = amount; + assertThat(scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)]).isNotNull(); + + } else if (("payee").equals(client)) { + if (scenarioScopeState.initialBalForPayeeForBatch == null || id.equals("1")) { + scenarioScopeState.initialBalForPayeeForBatch = new int[14]; + } + scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)] = amount; + assertThat(scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)]).isNotNull(); + } + } + + @Then("add row to csv with current payer and payee, payment mode as {string} and transfer amount {int} and id {int} for all combine test cases") + public void addRowToCsvFileForAllCombinedTestCases(String paymentMode, int transferAmount, int id) throws IOException { + + String[] row = { String.valueOf(id), UUID.randomUUID().toString(), paymentMode, "msisdn", scenarioScopeState.payerIdentifier, + "msisdn", scenarioScopeState.payeeIdentifier, String.valueOf(transferAmount), "USD", "Test Payee Payment" }; + String filePath = Utils.getAbsoluteFilePathToResource(scenarioScopeState.filename); + csvHelper.addRow(filePath, row); + scenarioScopeState.gsmaP2PAmtDebit = scenarioScopeState.gsmaP2PAmtDebit + transferAmount; + if (scenarioScopeState.gsmaP2PAmtDebitForBatch == null || id == 1) { + scenarioScopeState.gsmaP2PAmtDebitForBatch = new int[14]; + } + scenarioScopeState.gsmaP2PAmtDebitForBatch[id + 1] = transferAmount; + } + @Then("add last row to csv with current payer and payee, payment mode as {string} and transfer amount {int} and id {int}") public void addLastRowToCsvFile(String paymentMode, int transferAmount, int id) throws IOException { @@ -577,14 +705,14 @@ public void consolidatedPayeeCreationSteps(String client, String id, int amount) callApproveSavingsEndpoint("approve", client); callSavingsActivateEndpoint("activate", client); callDepositAccountEndpoint("deposit", amount, client); - if (client.equals("payer")) { + if (("payer").equals(client)) { if (scenarioScopeState.initialBalForPayerForBatch == null) { scenarioScopeState.initialBalForPayerForBatch = new int[4]; } scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)] = amount; assertThat(scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)]).isNotNull(); - } else if (client.equals("payee")) { + } else if (("payee").equals(client)) { if (scenarioScopeState.initialBalForPayeeForBatch == null) { scenarioScopeState.initialBalForPayeeForBatch = new int[4]; } @@ -619,4 +747,26 @@ public void consolidatedPayeeCreationStepsForCombinedTestsCases(String client, S } } + @Then("I check whether budget account exists with accoundId {string}") + public void budgetAccountExistsWithAccoundId(String accountId) throws JsonProcessingException { + RequestSpecification requestSpec = Utils.getDefaultSpec(); + requestSpec = fundTransferDef.setHeaders(requestSpec); + // Setting account ID in path + + String endpoint = transferConfig.interopIdentifierEndpoint; + String identifierType = "MSISDN"; + endpoint = Util.getFormattedEndpoint(endpoint, "{{identifierType}}", identifierType); + endpoint = Util.getFormattedEndpoint(endpoint, "{{identifier}}", accountId); + try { + // Calling Interop Identifier endpoint + fundTransferDef.responseInteropIdentifier = RestAssured.given(requestSpec).baseUri(transferConfig.savingsBaseUrl).expect() + .spec(new ResponseSpecBuilder().build()).when().delete(endpoint).andReturn().asString(); + } catch (Exception e) { + logger.error("Error checking account existence: ", e); + throw new RuntimeException("Failed to check account existence", e); + } + logger.info("Interop Identifier Response: {}", fundTransferDef.responseInteropIdentifier); + assertThat(fundTransferDef.responseInteropIdentifier).isNotEmpty(); + } + } diff --git a/src/test/java/org/mifos/integrationtest/util/Util.java b/src/test/java/org/mifos/integrationtest/util/Util.java new file mode 100644 index 000000000..f1507e39e --- /dev/null +++ b/src/test/java/org/mifos/integrationtest/util/Util.java @@ -0,0 +1,12 @@ +package org.mifos.integrationtest.util; + +public final class Util { + + private Util() { + throw new UnsupportedOperationException("Utility class"); + } + + public static String getFormattedEndpoint(String formattedTemplate, String tobeReplaced, String replacedWith) { + return formattedTemplate.replace(tobeReplaced, replacedWith); + } +} diff --git a/src/test/java/resources/batch.feature b/src/test/java/resources/batch.feature index 94486311d..807ceb73d 100644 --- a/src/test/java/resources/batch.feature +++ b/src/test/java/resources/batch.feature @@ -149,8 +149,8 @@ Feature: Batch Details API test Scenario: BD-011 Batch test for payerIdentifier resolution using budgetAccount info Given I have tenant as "paymentBB2" And I have the demo csv file "payerIdentifier-resolution-using-budgetAccount.csv" - And I have the registeringInstituteId "123" - And I have the programId "SocialWelfare" + And I have the registeringInstituteId "SocialWelfare" + And I have the programId "Education" And I generate clientCorrelationId And I have private key And I generate signature diff --git a/src/test/java/resources/batch_demo_csv/batchTransactioClosedLoopMojaloopFundTransfer.csv b/src/test/java/resources/batch_demo_csv/batchTransactioClosedLoopMojaloopFundTransfer.csv new file mode 100644 index 000000000..186f4b564 --- /dev/null +++ b/src/test/java/resources/batch_demo_csv/batchTransactioClosedLoopMojaloopFundTransfer.csv @@ -0,0 +1,9 @@ +id,request_id,payment_mode,payer_identifier_type,payer_identifier,payee_identifier_type,payee_identifier,amount,currency,note +0,dbe1d284-1bea-4f03-bc0f-8faece9f5da2,closedloop,msisdn,2300,msisdn,1759,10,USD,Test Payee Payment +1,696a9340-adc2-48e3-a1d1-10a239bc412b,closedloop,msisdn,2301,msisdn,1760,5,USD,Test Payee Payment +2,8e2eaf78-4566-438e-9183-ec02288fd16b,closedloop,msisdn,2302,msisdn,1761,5,USD,Test Payee Payment +3,b9bc0bc8-cf25-417a-adbc-97345330737a,closedloop,msisdn,2303,msisdn,1762,5,USD,Test Payee Payment +4,a59acbe1-4ebb-4618-bda3-630f2c306e09,closedloop,msisdn,2304,msisdn,1763,5,USD,Test Payee Payment +5,d79a4bc6-f9ec-4eba-beb7-96277bd832b3,mojaloop,msisdn,2305,msisdn,1764,3,USD,Test Payee Payment +6,1f838585-5091-44ef-9432-77d13b9c4583,mojaloop,msisdn,2306,msisdn,1764,2,USD,Test Payee Payment +7,94fd7bd1-7482-4f4f-bf12-a21ab4b550a8,mojaloop,msisdn,2307,msisdn,1765,1,USD,Test Payee Payment \ No newline at end of file diff --git a/src/test/java/resources/batch_demo_csv/batchTransaction.csv b/src/test/java/resources/batch_demo_csv/batchTransaction.csv new file mode 100644 index 000000000..18905bd4d --- /dev/null +++ b/src/test/java/resources/batch_demo_csv/batchTransaction.csv @@ -0,0 +1,4 @@ +id,request_id,payment_mode,payer_identifier_type,payer_identifier,payee_identifier_type,payee_identifier,amount,currency,note +0,ed6bf87e-4bda-44dc-be52-004e71438f0f,mojaloop,msisdn,345,msisdn,363,3,USD,Test Payee Payment +1,25ddc445-069a-417b-b62a-f5b952ac313e,mojaloop,msisdn,346,msisdn,363,2,USD,Test Payee Payment +2,0842d2df-0aec-4312-ada4-c3dd2be1ed80,mojaloop,msisdn,347,msisdn,364,1,USD,Test Payee Payment \ No newline at end of file diff --git a/src/test/java/resources/batch_demo_csv/batchTransactionGsmaClosedLoop.csv b/src/test/java/resources/batch_demo_csv/batchTransactionGsmaClosedLoop.csv deleted file mode 100644 index f03d5970e..000000000 --- a/src/test/java/resources/batch_demo_csv/batchTransactionGsmaClosedLoop.csv +++ /dev/null @@ -1,9 +0,0 @@ -id,request_id,payment_mode,payer_identifier_type,payer_identifier,payee_identifier_type,payee_identifier,amount,currency,note -0,3e2dcaf6-7f66-4460-aa03-2be3a12222eb,closedloop,msisdn,5397,msisdn,5141,10,USD,Test Payee Payment -1,b9760d58-676a-4353-a555-3a3b63f1760a,closedloop,msisdn,5398,msisdn,5142,5,USD,Test Payee Payment -2,00ffd1a8-c7a7-4943-b68f-11df7c2763a5,closedloop,msisdn,5399,msisdn,5143,5,USD,Test Payee Payment -3,74a81c70-0335-45b9-877b-43b3b6ec2f16,closedloop,msisdn,5400,msisdn,5144,5,USD,Test Payee Payment -4,777035ca-a4d9-4725-b905-0c840b567c51,closedloop,msisdn,5401,msisdn,5145,5,USD,Test Payee Payment -5,f50f0d85-7fec-44ad-8a3f-0811b4926db6,gsma,msisdn,5402,msisdn,5146,6,USD,Test Payee Payment -6,9c780986-28a9-45eb-896e-1139ef2a15c2,gsma,msisdn,5403,msisdn,5147,7,USD,Test Payee Payment -7,09abfde9-73c8-45d9-a89c-9623eacddcd3,gsma,msisdn,5404,msisdn,5148,8,USD,Test Payee Payment \ No newline at end of file diff --git a/src/test/java/resources/bulkPayment.feature b/src/test/java/resources/bulkPayment.feature index a56b3a215..515bca356 100644 --- a/src/test/java/resources/bulkPayment.feature +++ b/src/test/java/resources/bulkPayment.feature @@ -1,12 +1,178 @@ -@gov @ext +@e2e Feature: Test ability to make payment to individual with bank account + @commonExtended - Scenario: Input CSV file using the batch transaction API and poll batch summary API till we get completed status + Scenario: BB-FSP 001 Create Budget Account and Register Payee + Given I am setting up Mojaloop + And I have the registeringInstituteId "SocialWelfare" + And I have the programId "Education" + Given I have Fineract-Platform-TenantId for "payer" + When I call the create client endpoint for "payer" + Then I call the create savings product endpoint for "payer" + When I call the create savings account endpoint for "payer" + Then I check whether budget account exists with accoundId "123456789" + Then I call the interop identifier endpoint for "payer" and accountId "123456789" + Then I approve the deposit for Budget Account with command "approve" for "payer" + When I activate the budget account with command "activate" for "payer" + Then I call the deposit account endpoint with command "deposit" for amount 7000 for "payer" + #Registring account lookup + Then I add "payer" with account id "123456789" to als + + + When I call the create client endpoint for "payer" + Then I call the create savings product endpoint for "payer" + When I call the create savings account endpoint for "payer" + Then I check whether budget account exists with accoundId "223456789" + Then I call the interop identifier endpoint for "payer" and accountId "223456789" + Then I approve the deposit for Budget Account with command "approve" for "payer" + When I activate the budget account with command "activate" for "payer" + Then I call the deposit account endpoint with command "deposit" for amount 9000 for "payer" + Then I add "payer" with account id "223456789" to als + + + When I call the create client endpoint for "payer" + Then I call the create savings product endpoint for "payer" + When I call the create savings account endpoint for "payer" + Then I check whether budget account exists with accoundId "323456789" + Then I call the interop identifier endpoint for "payer" and accountId "323456789" + Then I approve the deposit for Budget Account with command "approve" for "payer" + When I activate the budget account with command "activate" for "payer" + Then I call the deposit account endpoint with command "deposit" for amount 9000 for "payer" + Then I add "payer" with account id "323456789" to als + + Given I have Fineract-Platform-TenantId for "payee1" + When I call the create client endpoint for "payee" + Then I call the create savings product endpoint for "payee" + When I call the create savings account endpoint for "payee" + Then I check whether budget account exists with accoundId "1234" + Then I call the interop identifier endpoint for "payee" and accountId "1234" + Then I approve the deposit for Budget Account with command "approve" for "payee" + When I activate the budget account with command "activate" for "payee" + Then I call the deposit account endpoint with command "deposit" for amount 1000 for "payee" + Then I add "payee1" with account id "1234" to als + + Given I have Fineract-Platform-TenantId for "payee2" + When I call the create client endpoint for "payee" + Then I call the create savings product endpoint for "payee" + When I call the create savings account endpoint for "payee" + Then I check whether budget account exists with accoundId "2235" + Then I call the interop identifier endpoint for "payee" and accountId "2235" + Then I approve the deposit for Budget Account with command "approve" for "payee" + When I activate the budget account with command "activate" for "payee" + Then I call the deposit account endpoint with command "deposit" for amount 2000 for "payee" + Then I add "payee2" with account id "2235" to als + + Given I have Fineract-Platform-TenantId for "payee3" + When I call the create client endpoint for "payee" + Then I call the create savings product endpoint for "payee" + When I call the create savings account endpoint for "payee" + Then I check whether budget account exists with accoundId "3235" + Then I call the interop identifier endpoint for "payee" and accountId "3235" + Then I approve the deposit for Budget Account with command "approve" for "payee" + When I activate the budget account with command "activate" for "payee" + Then I call the deposit account endpoint with command "deposit" for amount 3000 for "payee" + Then I add "payee3" with account id "3235" to als + + And I have the demo csv file "bulk_payment.csv" + 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 list of payee identifiers from csv file + And I create a IdentityMapperDTO for registering payee with IAM + Then I call the register beneficiary API with expected status of 202 and stub "/registerBeneficiary" + And I should be able to verify that the "PUT" method to "/registerBeneficiary" endpoint received a request with successfull registration + + + Scenario: BB-FSP 002 Input CSV file using the batch transaction API and poll batch summary API till we get completed status + 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 + When I can inject MockServer + Then I can start mock server + And I have the registeringInstituteId "SocialWelfare" + And I have the programId "Education" + And I can register the stub with "/registerBeneficiary" endpoint for "PUT" request with status of 200 + And I create a IdentityMapperDTO for registering payee with IAM + Then I call the register beneficiary API with expected status of 202 and stub "/registerBeneficiary" + And I should be able to verify that the "PUT" method to "/registerBeneficiary" endpoint received a request with successfull registration + + And I create a new clientCorrelationId + And I have private key + And I generate signature + + When I call the batch transactions endpoint with expected status of 202 + Then I should get non empty response + And I am able to parse batch transactions response + And I fetch batch ID from batch transaction API's response +# Then I will sleep for 10000 millisecond + Given I have tenant as "paymentbb1" + When I call the batch summary API with expected status of 200 with total 6 txns + Then I am able to parse batch summary response + And Status of transaction is "COMPLETED" + And I should have matching total txn count and successful txn count in response + + + Scenario: BB-FSP 003 Input CSV file using the batch transaction API and poll batch summary API till we get completed status 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 When I can inject MockServer Then I can start mock server + And I have the registeringInstituteId "SocialWelfare" + And I have the programId "UnconditionalCashTransfer" + And I can register the stub with "/registerBeneficiary" endpoint for "PUT" request with status of 200 + And I create a IdentityMapperDTO for registering payee with IAM + Then I call the register beneficiary API with expected status of 202 and stub "/registerBeneficiary" + And I should be able to verify that the "PUT" method to "/registerBeneficiary" endpoint received a request with successfull registration + And I create a new clientCorrelationId + And I have private key + And I generate signature + When I call the batch transactions endpoint with expected status of 202 + Then I should get non empty response + And I am able to parse batch transactions response + And I fetch batch ID from batch transaction API's response +# Then I will sleep for 10000 millisecond + Given I have tenant as "paymentbb1" + When I call the batch summary API with expected status of 200 with total 6 txns + Then I am able to parse batch summary response + And Status of transaction is "COMPLETED" + And I should have matching total txn count and successful txn count in response + + + Scenario: BB-FSP 004 Input CSV file using the batch transaction API and poll batch summary API till we get completed status + 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 + When I can inject MockServer + Then I can start mock server + And I have the registeringInstituteId "Health" + And I have the programId "Maternity" + And I can register the stub with "/registerBeneficiary" endpoint for "PUT" request with status of 200 + And I create a IdentityMapperDTO for registering payee with IAM + Then I call the register beneficiary API with expected status of 202 and stub "/registerBeneficiary" + And I should be able to verify that the "PUT" method to "/registerBeneficiary" endpoint received a request with successfull registration + And I create a new clientCorrelationId + And I have private key + And I generate signature + When I call the batch transactions endpoint with expected status of 202 + Then I should get non empty response + And I am able to parse batch transactions response + And I fetch batch ID from batch transaction API's response +# Then I will sleep for 10000 millisecond + Given I have tenant as "paymentbb1" + When I call the batch summary API with expected status of 200 with total 6 txns + Then I am able to parse batch summary response + And Status of transaction is "COMPLETED" + And I should have matching total txn count and successful txn count in response + + Scenario:BB-FSP 005 Input CSV file using the batch transaction API and poll batch summary API till we get completed status + 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 + When I can inject MockServer + Then I can start mock server + And I have the registeringInstituteId "SocialWelfare" + And I have the programId "Education" 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" @@ -25,12 +191,14 @@ Feature: Test ability to make payment to individual with bank account And Status of transaction is "COMPLETED" And I should have matching total txn count and successful txn count in response - Scenario: Bulk Transfer with ClosedLoop and Mojaloop - Given I have tenant as "paymentbb2" + Scenario:BB-FSP 006 Bulk Transfer with ClosedLoop and Mojaloop + Given I have tenant as "payerfsp" And I have the demo csv file "bulk_payment_closedl_mock_mojaloop.csv" And I create a list of payee identifiers from csv file When I can inject MockServer Then I can start mock server + And I have the registeringInstituteId "SocialWelfare" + And I have the programId "Education" 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" @@ -42,15 +210,14 @@ Feature: Test ability to make payment to individual with bank account Then I should get non empty response And I am able to parse batch transactions response And I fetch batch ID from batch transaction API's response -# Then I will sleep for 10000 millisecond - Given I have tenant as "paymentbb2" + Then I will sleep for 10000 millisecond + Given I have tenant as "payerfsp" When I call the batch summary API with expected status of 200 with total successfull 8 txns Then I am able to parse batch summary response And Status of transaction is "COMPLETED" And My total txns 8 and successful txn count in response should Match - @commonExtended - Scenario: Bulk Transfer with ClosedLoop and GSMA + Scenario:BB-FSP 007 Bulk Transfer with ClosedLoop and GSMA #payer 1 creation Given I have Fineract-Platform-TenantId as "payerfsp2" And I initialize the payee list @@ -149,6 +316,9 @@ Feature: Test ability to make payment to individual with bank account When I can inject MockServer Then I can start mock server + And I have the registeringInstituteId "SocialWelfare" + And I have the programId "Education" + 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" @@ -169,3 +339,258 @@ Feature: Test ability to make payment to individual with bank account And Status of transaction is "COMPLETED" And My total txns 8 and successful txn count in response should Match + + Scenario:BB-FSP 008 Bulk Transfer with Closedloop and Real Mojaloop + #payer 1 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + And I initialize the payee list + When I create and setup a "payer" with id "1" and account balance of 100 for combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "1" balance for combine test cases + #payee 1 creation + When I create and setup a "payee" with id "1" and account balance of 10 for combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "1" balance for combine test cases + + Then Create a csv file with file name "batchTransactioClosedLoopMojaloopFundTransfer.csv" + Then add row to csv with current payer and payee, payment mode as "closedloop" and transfer amount 10 and id 0 for combine test cases + + #payer 2 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + When I create and setup a "payer" with id "2" and account balance of 50 for combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "2" balance for combine test cases + #payee 2 creation + When I create and setup a "payee" with id "2" and account balance of 20 for combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "2" balance for combine test cases + + Then add row to csv with current payer and payee, payment mode as "closedloop" and transfer amount 5 and id 1 for combine test cases + + #payer 3 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + When I create and setup a "payer" with id "3" and account balance of 50 for combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "3" balance + #payee 3 creation + When I create and setup a "payee" with id "3" and account balance of 20 for combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "3" balance for combine test cases + + Then add row to csv with current payer and payee, payment mode as "closedloop" and transfer amount 5 and id 2 for combine test cases + + #payer 4 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + When I create and setup a "payer" with id "4" and account balance of 50 for combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "4" balance for combine test cases + #payee 4 creation + When I create and setup a "payee" with id "4" and account balance of 20 for combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "4" balance for combine test cases + + Then add row to csv with current payer and payee, payment mode as "closedloop" and transfer amount 5 and id 3 for combine test cases + #payer 5 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + When I create and setup a "payer" with id "5" and account balance of 50 for combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "5" balance for combine test cases + #payee 5 creation + When I create and setup a "payee" with id "5" and account balance of 20 for combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "5" balance for combine test cases + + Then add row to csv with current payer and payee, payment mode as "closedloop" and transfer amount 5 and id 4 for combine test cases + #Mojaloop + Given I am setting up Mojaloop + #payer and payee 6 for mojaloop [1] + When I create and setup a "payer" with account balance of 12 + When I create and setup a "payee" with account balance of 10 + Then I add "payer" to als + Then I add "payee" to als + Then add row to csv with current payer and payee, payment mode as "mojaloop" and transfer amount 3 and id 5 for combine test cases + + #payer and payee 7 for mojaloop [2] + Then I add "payer" to als + When I create and setup a "payer" with account balance of 120 + Then add row to csv with current payer and payee, payment mode as "mojaloop" and transfer amount 2 and id 6 for combine test cases + + When I create and setup a "payer" with account balance of 66 + When I create and setup a "payee" with account balance of 10 + Then I add "payer" to als + Then I add "payee" to als + Then add last row to csv with current payer and payee, payment mode as "mojaloop" and transfer amount 1 and id 7 + + Given I have Fineract-Platform-TenantId for "payer" + And I create a new clientCorrelationId + And I have private key + And I generate signature + + When I call the batch transactions endpoint with expected status of 202 + Then I should get non empty response + And I am able to parse batch transactions response + And I fetch batch ID from batch transaction API's response + Then I will sleep for 10000 millisecond + Given I have tenant as "payerfsp" + When I call the batch summary API with expected status of 200 with total successfull 8 txns + Then I am able to parse batch summary response + And Status of transaction is "COMPLETED" + And My total txns 8 and successful txn count in response should Match + + + Scenario:BB-FSP 009 Bulk Transfer with ClosedLoop, Real mojaloop and Real GSMA + #payer 1 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + And I initialize the payee list + When I create and setup a "payer" with id "1" and account balance of 100 for all combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "1" balance for all combine test cases + #payee 1 creation + When I create and setup a "payee" with id "1" and account balance of 10 for all combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "1" balance for all combine test cases + + Then Create a csv file with file name "batchTransactionGsmaClosedLoopMojaloop.csv" + Then add row to csv with current payer and payee, payment mode as "closedloop" and transfer amount 10 and id 0 for all combine test cases + + #payer 2 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + When I create and setup a "payer" with id "2" and account balance of 50 for all combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "2" balance for all combine test cases + #payee 2 creation + When I create and setup a "payee" with id "2" and account balance of 20 for all combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "2" balance for all combine test cases + + Then add row to csv with current payer and payee, payment mode as "closedloop" and transfer amount 5 and id 1 for all combine test cases + + #payer 3 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + When I create and setup a "payer" with id "3" and account balance of 50 for all combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "3" balance for all combine test cases + #payee 3 creation + When I create and setup a "payee" with id "3" and account balance of 20 for all combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "3" balance for all combine test cases + + Then add row to csv with current payer and payee, payment mode as "closedloop" and transfer amount 5 and id 2 for all combine test cases + + #payer 4 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + When I create and setup a "payer" with id "4" and account balance of 50 + Given I have tenant as "payerfsp" + Then I call the balance api for payer "4" balance for all combine test cases + #payee 4 creation + When I create and setup a "payee" with id "4" and account balance of 20 for all combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "4" balance for all combine test cases + + Then add row to csv with current payer and payee, payment mode as "closedloop" and transfer amount 5 and id 3 for all combine test cases + #payer 5 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + When I create and setup a "payer" with id "5" and account balance of 50 for all combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "5" balance for all combine test cases + #payee 5 creation + When I create and setup a "payee" with id "5" and account balance of 20 for all combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "5" balance for all combine test cases + + Then add row to csv with current payer and payee, payment mode as "closedloop" and transfer amount 5 and id 4 for all combine test cases + + #payer 6 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + When I create and setup a "payer" with id "6" and account balance of 50 for all combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "6" balance for all combine test cases + #payee 6 creation + When I create and setup a "payee" with id "6" and account balance of 20 for all combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "6" balance for all combine test cases + + Then add row to csv with current payer and payee, payment mode as "gsma" and transfer amount 6 and id 5 for all combine test cases + + #payer 7 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + When I create and setup a "payer" with id "7" and account balance of 50 for all combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "7" balance for all combine test cases + #payee 7 creation + When I create and setup a "payee" with id "7" and account balance of 20 for all combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "7" balance for all combine test cases + + Then add row to csv with current payer and payee, payment mode as "gsma" and transfer amount 7 and id 6 for all combine test cases + #payer 8 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + When I create and setup a "payer" with id "8" and account balance of 30 for all combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "8" balance for all combine test cases + #payee 8 creation + When I create and setup a "payee" with id "8" and account balance of 30 for all combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "8" balance for all combine test cases + + Then add row to csv with current payer and payee, payment mode as "gsma" and transfer amount 8 and id 7 for all combine test cases + + #payer 9 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + When I create and setup a "payer" with id "9" and account balance of 50 for all combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "9" balance for all combine test cases + #payee 9 creation + When I create and setup a "payee" with id "9" and account balance of 20 for all combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "9" balance for all combine test cases + + Then add row to csv with current payer and payee, payment mode as "gsma" and transfer amount 9 and id 8 for all combine test cases + #payer 10 creation + Given I have Fineract-Platform-TenantId as "payerfsp2" + When I create and setup a "payer" with id "10" and account balance of 30 for all combine test cases + Given I have tenant as "payerfsp" + Then I call the balance api for payer "10" balance for all combine test cases + #payee 10 creation + When I create and setup a "payee" with id "10" and account balance of 30 for all combine test cases + Given I have tenant as "payeefsp3" + Then I call the balance api for payee "10" balance for all combine test cases + + Then add row to csv with current payer and payee, payment mode as "gsma" and transfer amount 10 and id 9 for all combine test cases + + #Mojaloop batch setup + Given I am setting up Mojaloop + #payer and payee 10 for mojaloop [1] + When I create and setup a "payer" with account balance of 12 + When I create and setup a "payee" with account balance of 10 + Then I add "payer" to als + Then I add "payee" to als + Then add row to csv with current payer and payee, payment mode as "mojaloop" and transfer amount 3 and id 10 for all combine test cases + + #payer and payee 11 for mojaloop [2] + Then I add "payer" to als + When I create and setup a "payer" with account balance of 120 + Then add row to csv with current payer and payee, payment mode as "mojaloop" and transfer amount 2 and id 11 for all combine test cases + + #payer and payee 12 for mojaloop [3] + When I create and setup a "payer" with account balance of 66 + When I create and setup a "payee" with account balance of 10 + Then I add "payer" to als + Then I add "payee" to als + Then add last row to csv with current payer and payee, payment mode as "mojaloop" and transfer amount 1 and id 12 + + #batch process + Given I have tenant as "payerfsp" + And I have the demo csv file "batchTransactionGsmaClosedLoopMojaloop.csv" + And I generate clientCorrelationId + And I have private key + And I generate signature + When I call the batch transactions endpoint with expected status of 202 + And I am able to parse batch transactions response + And I fetch batch ID from batch transaction API's response + Then I will sleep for 10000 millisecond + When I call the batch summary API with expected status of 200 with total successfull 13 txns + Then I should get non empty response + Then I am able to parse batch summary response + And Status of transaction is "COMPLETED" + And My total txns 13 and successful txn count in response should Match