From 5210ea955d900647cb65efff283af4c8b1950b4b Mon Sep 17 00:00:00 2001 From: Ankita Ranjan <92036361+ankita10r@users.noreply.github.com> Date: Tue, 28 May 2024 12:45:14 +0530 Subject: [PATCH] [PHEE-669] Tc for Account Status and Account Name APIs (#280) --- src/main/resources/application.yaml | 2 + .../cucumber/stepdef/ErrorCodeStepDef.java | 4 +- .../cucumber/stepdef/GSMATransferStepDef.java | 95 ++++++++++++++----- .../cucumber/stepdef/ScenarioScopeState.java | 3 +- src/test/java/resources/account.feature | 37 ++++++++ .../batch_demo_csv/batchTransactionGsma.csv | 6 +- 6 files changed, 115 insertions(+), 32 deletions(-) create mode 100644 src/test/java/resources/account.feature diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 1e464f9b1..cb7987fb7 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -65,6 +65,8 @@ amsmifos: ams: base-url: https://ams-mifos.sandbox.fynarfin.io balance-endpoint: /ams/accounts/{IdentifierType}/{IdentifierId}/balance + status-endpoint: /ams/accounts/{IdentifierType}/{IdentifierId}/status + name-endpoint: /ams/accounts/{IdentifierType}/{IdentifierId}/accountname loan: base-url: https://fynams.sandbox.fynarfin.io diff --git a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/ErrorCodeStepDef.java b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/ErrorCodeStepDef.java index e118bc422..b33f8d4c6 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/ErrorCodeStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/ErrorCodeStepDef.java @@ -382,8 +382,8 @@ public void iShouldPollTheTransferQueryEndpointWithTransactionIdUntilStatusIsPop public void iCanCreateGSMATransactionDTOWithDifferentPayerAndPayee() { GSMATransferHelper gsmaTransferHelper = new GSMATransferHelper(); Fee fee = gsmaTransferHelper.feeHelper("11", "USD", "string"); - GsmaParty debit = gsmaTransferHelper.gsmaPartyHelper("msisdn", gsmaTransferStepDef.debitParty); - GsmaParty credit = gsmaTransferHelper.gsmaPartyHelper("msisdn", gsmaTransferStepDef.creditParty); + GsmaParty debit = gsmaTransferHelper.gsmaPartyHelper("msisdn", scenarioScopeState.debitParty); + GsmaParty credit = gsmaTransferHelper.gsmaPartyHelper("msisdn", scenarioScopeState.creditParty); InternationalTransferInformation internationalTransferInformation = gsmaTransferHelper .internationalTransferInformationHelper("string", "string", "directtoaccount", "USA", "USA", "USA", "USA"); IdDocument idDocument = gsmaTransferHelper.idDocumentHelper("passport", "string", "USA", "2022-09-28T12:51:19.260+00:00", 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 e79b53903..8c2c7469b 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/GSMATransferStepDef.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/GSMATransferStepDef.java @@ -42,14 +42,15 @@ public class GSMATransferStepDef extends BaseStepDef { - String debitParty = ""; - String creditParty = ""; - int balance; @Value("${ams.base-url}") String amsBaseUrl; @Value("${ams.balance-endpoint}") String amsBalanceEndpoint; + @Value("${ams.status-endpoint}") + String amsStatusEndpoint; + @Value("${ams.name-endpoint}") + String amsNameEndpoint; @Autowired GsmaConfig gsmaConfig; @@ -385,7 +386,7 @@ public void callCreateDebitInteropIdentifierEndpointMSISDN() throws JsonProcessi // Setting account ID in path PostSavingsAccountsResponse savingsAccountResponse = objectMapper.readValue(gsmaTransferDef.responseSavingsAccount, PostSavingsAccountsResponse.class); - String payer_identifier = debitParty; + String payer_identifier = scenarioScopeState.debitParty; String debitInteropEndpoint = gsmaConfig.interopIdentifierEndpoint; debitInteropEndpoint = debitInteropEndpoint.replaceAll("\\{\\{identifierType\\}\\}", "MSISDN"); @@ -409,7 +410,7 @@ public void callCreateCreditInteropIdentifierEndpointMSISDN() throws JsonProcess // Setting account ID in path PostSavingsAccountsResponse savingsAccountResponse = objectMapper.readValue(gsmaTransferDef.responseSavingsAccount, PostSavingsAccountsResponse.class); - String payer_identifier = creditParty; + String payer_identifier = scenarioScopeState.creditParty; String creditInteropEndpoint = gsmaConfig.interopIdentifierEndpoint; creditInteropEndpoint = creditInteropEndpoint.replaceAll("\\{\\{identifierType\\}\\}", "MSISDN"); creditInteropEndpoint = creditInteropEndpoint.replaceAll("\\{\\{identifier\\}\\}", payer_identifier); @@ -428,7 +429,7 @@ public void iCallTheBalanceApiForPayerBalance() throws JsonProcessingException { RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant); String finalEndpoint = amsBalanceEndpoint; finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); - finalEndpoint = finalEndpoint.replace("{IdentifierId}", debitParty.isEmpty() ? scenarioScopeState.payerIdentifier : debitParty); + finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.debitParty.isEmpty() ? scenarioScopeState.payerIdentifier : scenarioScopeState.debitParty); logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); @@ -444,7 +445,7 @@ public void iCallTheBalanceApiForPayeeBalance() throws JsonProcessingException { RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant); String finalEndpoint = amsBalanceEndpoint; finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); - finalEndpoint = finalEndpoint.replace("{IdentifierId}", creditParty.isEmpty() ? scenarioScopeState.payeeIdentifier : creditParty); + finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.creditParty.isEmpty() ? scenarioScopeState.payeeIdentifier : scenarioScopeState.creditParty); logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); @@ -460,7 +461,7 @@ public void iCallTheBalanceApiForPayerBalanceAfterDebit() throws JsonProcessingE RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant); String finalEndpoint = amsBalanceEndpoint; finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); - finalEndpoint = finalEndpoint.replace("{IdentifierId}", debitParty.isEmpty() ? scenarioScopeState.payerIdentifier : debitParty); + finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.debitParty.isEmpty() ? scenarioScopeState.payerIdentifier : scenarioScopeState.debitParty); logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); @@ -479,7 +480,7 @@ public void iCallTheBalanceApiForPayeeBalanceAfterCredit() throws JsonProcessing String finalEndpoint = amsBalanceEndpoint; finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); finalEndpoint = finalEndpoint.replace("{IdentifierId}", - creditParty.isEmpty() ? scenarioScopeState.payeeIdentifier : creditParty); + scenarioScopeState.creditParty.isEmpty() ? scenarioScopeState.payeeIdentifier : scenarioScopeState.creditParty); logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); @@ -494,11 +495,11 @@ public void iCallTheBalanceApiForPayeeBalanceAfterCredit() throws JsonProcessing @When("I create a set of debit and credit party") public void iCreateASetOfDebitAndCreditParty() { Random random = new Random(); - debitParty = String.valueOf(random.nextInt(900000000) + 1000000000); - creditParty = String.valueOf(random.nextInt(900000000) + 1000000000); - assertThat(debitParty).isNotEmpty(); - assertThat(creditParty).isNotEmpty(); - assertThat(debitParty).isNotEqualTo(creditParty); + scenarioScopeState.debitParty = String.valueOf(random.nextInt(900000000) + 1000000000); + scenarioScopeState.creditParty = String.valueOf(random.nextInt(900000000) + 1000000000); + assertThat(scenarioScopeState.debitParty).isNotEmpty(); + assertThat(scenarioScopeState.creditParty).isNotEmpty(); + assertThat(scenarioScopeState.debitParty).isNotEqualTo(scenarioScopeState.creditParty); } @@ -638,11 +639,11 @@ public void iCreateASetOfDebitAndCreditPartyFromFile(String filename) { while (scanner.hasNextLine() && !line.isEmpty()) { String line2 = scanner.nextLine(); String[] parts = line2.split(","); - debitParty = parts[4]; - creditParty = parts[6]; - assertThat(debitParty).isNotEmpty(); - assertThat(creditParty).isNotEmpty(); - assertThat(debitParty).isNotEqualTo(creditParty); + scenarioScopeState.debitParty = parts[4]; + scenarioScopeState.creditParty = parts[6]; + assertThat(scenarioScopeState.debitParty).isNotEmpty(); + assertThat(scenarioScopeState.creditParty).isNotEmpty(); + assertThat(scenarioScopeState.debitParty).isNotEqualTo(scenarioScopeState.creditParty); } scanner.close(); } catch (FileNotFoundException e) { @@ -682,7 +683,7 @@ public void iCallTheBalanceApiForPayeeBalance(String id) throws JsonProcessingEx } scenarioScopeState.payeeIdentifierforBatch[Integer.parseInt(id)] = scenarioScopeState.payeeIdentifier; finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); - finalEndpoint = finalEndpoint.replace("{IdentifierId}", creditParty.isEmpty() ? scenarioScopeState.payeeIdentifier : creditParty); + finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.payeeIdentifier); logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); @@ -703,7 +704,7 @@ public void iCallTheBalanceApiForPayeeBalanceForCombinedTestsCases(String id) th } scenarioScopeState.payeeIdentifierforBatch[Integer.parseInt(id)] = scenarioScopeState.payeeIdentifier; finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); - finalEndpoint = finalEndpoint.replace("{IdentifierId}", creditParty.isEmpty() ? scenarioScopeState.payeeIdentifier : creditParty); + finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.creditParty.isEmpty() ? scenarioScopeState.payeeIdentifier : scenarioScopeState.creditParty); logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); @@ -720,8 +721,7 @@ public void iCallTheBalanceApiForPayeeBalanceAfterCredit(String id) throws JsonP RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant); String finalEndpoint = amsBalanceEndpoint; finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); - finalEndpoint = finalEndpoint.replace("{IdentifierId}", - creditParty.isEmpty() ? scenarioScopeState.payeeIdentifierforBatch[Integer.parseInt(id)] : creditParty); + finalEndpoint = finalEndpoint.replace("{IdentifierId}",scenarioScopeState.payeeIdentifierforBatch[Integer.parseInt(id)]); logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); @@ -741,7 +741,7 @@ public void iCallTheBalanceApiForPayerBalance(String id) throws JsonProcessingEx } scenarioScopeState.payerIdentifierforBatch[Integer.parseInt(id)] = scenarioScopeState.payerIdentifier; finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); - finalEndpoint = finalEndpoint.replace("{IdentifierId}", debitParty.isEmpty() ? scenarioScopeState.payerIdentifier : debitParty); + finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.payerIdentifier); logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); @@ -762,7 +762,7 @@ public void iCallTheBalanceApiForPayerBalanceForCombinedTestCases(String id) thr } scenarioScopeState.payerIdentifierforBatch[Integer.parseInt(id)] = scenarioScopeState.payerIdentifier; finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); - finalEndpoint = finalEndpoint.replace("{IdentifierId}", debitParty.isEmpty() ? scenarioScopeState.payerIdentifier : debitParty); + finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.debitParty.isEmpty() ? scenarioScopeState.payerIdentifier : scenarioScopeState.debitParty); logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); @@ -780,7 +780,7 @@ public void iCallTheBalanceApiForPayerBalanceAfterDebit(String id) throws JsonPr String finalEndpoint = amsBalanceEndpoint; finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); finalEndpoint = finalEndpoint.replace("{IdentifierId}", - debitParty.isEmpty() ? scenarioScopeState.payerIdentifierforBatch[Integer.parseInt(id)] : debitParty); + scenarioScopeState.payerIdentifierforBatch[Integer.parseInt(id)]); logger.info("Endpoint: " + finalEndpoint); scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect() .spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString(); @@ -792,4 +792,47 @@ public void iCallTheBalanceApiForPayerBalanceAfterDebit(String id) throws JsonPr assertThat(avlBal == originBal - debitAmt).isTrue(); } + + @Then("I call the account status api") + public void iCallTheAccountStatus() throws JsonProcessingException { + RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant); + String finalEndpoint = amsStatusEndpoint; + finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); + finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.debitParty); + 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("Status Response: " + scenarioScopeState.response); + + } + + @And("I can assert {string} status in response") + public void iCanAssertStatusInResponse(String status) { + assertThat(scenarioScopeState.response.contains(status)).isTrue(); + } + + @Then("I call the account name api") + public void iCallTheAccountName() throws JsonProcessingException { + RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant); + String finalEndpoint = amsNameEndpoint; + finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN"); + finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.debitParty); + 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("Status Response: " + scenarioScopeState.response); + + } + + @And("I can assert name in response") + public void iCanAssertNameInResponse() throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + JsonNode jsonNode = mapper.readTree(scenarioScopeState.response); + + String firstName = jsonNode.get("name").get("firstName").asText(); + String lastName = jsonNode.get("name").get("lastName").asText(); + logger.info("Name is {} {}", firstName, lastName); + assertThat(firstName.isEmpty()).isFalse(); + assertThat(lastName.isEmpty()).isFalse(); + } } 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 dcf8e9677..a0dde5444 100644 --- a/src/test/java/org/mifos/integrationtest/cucumber/stepdef/ScenarioScopeState.java +++ b/src/test/java/org/mifos/integrationtest/cucumber/stepdef/ScenarioScopeState.java @@ -96,7 +96,8 @@ public class ScenarioScopeState { protected int initialBalForPayer; protected int initialBalForPayee; - + protected String debitParty; + protected String creditParty; protected String[] payeeIdentifierforBatch; protected String[] payerIdentifierforBatch; protected int[] initialBalForPayeeForBatch; diff --git a/src/test/java/resources/account.feature b/src/test/java/resources/account.feature new file mode 100644 index 000000000..119c7829c --- /dev/null +++ b/src/test/java/resources/account.feature @@ -0,0 +1,37 @@ +Feature: Account Status and Account Name Check api + + @amsIntegration + Scenario: Savings account Status Test + Given I have Fineract-Platform-TenantId as "payerfsp1" + When I create a set of debit and credit party + When I call the create payer client endpoint + Then I call the create savings product endpoint + When I call the create savings account endpoint + Then I call the debit interop identifier endpoint with MSISDN + Given I have tenant as "payerfsp" + Then I call the account status api + And I can assert "submitted" status in response + Then I approve the deposit with command "approve" + Given I have tenant as "payerfsp" + Then I call the account status api + And I can assert "approved" status in response + When I activate the account with command "activate" + Then I call the deposit account endpoint with command "deposit" for amount 11 + Given I have tenant as "payerfsp" + Then I call the account status api + And I can assert "active" status in response + + @amsIntegration + Scenario: Savings account Name Test + Given I have Fineract-Platform-TenantId as "payerfsp1" + When I create a set of debit and credit party + When I call the create payer client endpoint + Then I call the create savings product endpoint + When I call the create savings account endpoint + Then I call the debit interop identifier endpoint with MSISDN + Then I approve the deposit with command "approve" + When I activate the account with command "activate" + Then I call the deposit account endpoint with command "deposit" for amount 100 + Given I have tenant as "payerfsp" + Then I call the account name api + Then I can assert name in response \ No newline at end of file diff --git a/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv b/src/test/java/resources/batch_demo_csv/batchTransactionGsma.csv index 4183bb6fb..e8e8fcd26 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,f41f4f3a-479f-44d3-b254-1f6574b11e09,gsma,msisdn,2224,msisdn,2032,10,USD,Test Payee Payment -1,caf6c982-7182-4d4d-9931-75da625cec66,gsma,msisdn,2225,msisdn,2033,5,USD,Test Payee Payment -2,7e79d1b1-d000-43f4-a13f-451dd4c51457,gsma,msisdn,2226,msisdn,2034,1,USD,Test Payee Payment \ No newline at end of file +0,1fe8af66-9a34-4b92-bbd5-1a116b635bb5,gsma,msisdn,4004,msisdn,3815,10,USD,Test Payee Payment +1,dbbe52aa-20a0-4eb9-80a0-ad6df8068e40,gsma,msisdn,4005,msisdn,3816,5,USD,Test Payee Payment +2,021955bc-8a96-45d3-bec0-69e365d5369c,gsma,msisdn,4006,msisdn,3817,1,USD,Test Payee Payment \ No newline at end of file