Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHEE-653] Test comb all debug #265

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ jobs:
export CALLBACK_URL="https://$NGROK_PUBLIC_URL"
echo -n "Public url ."
echo $CALLBACK_URL
./gradlew test -Dcucumber.filter.tags="@gov"
./gradlew test -Dcucumber.filter.tags="@gov1"
echo -n "Test execution is completed, kill ngrok"
pkill ngrok
- store_test_results:
Expand Down Expand Up @@ -327,7 +327,7 @@ workflows:
- Ngrok
- test-chart-gov:
requires:
- test-chart-ams
- deploying-bpmns
context:
- AWS
- Helm
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ dependencies {
testImplementation "com.github.tomakehurst:wiremock-jre8:2.35.0"
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.mifos:ph-ee-connector-common:1.8.1-SNAPSHOT'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation "com.google.truth:truth:1.1.3"
testImplementation 'com.google.code.gson:gson:2.9.0'
testImplementation('io.rest-assured:rest-assured:5.1.1') {
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
server:
port: 8083

operations-app:
contactpoint: "https://ops-bk.sandbox.fynarfin.io"
dpgcontactpoint: "https://ops-bk-dpg.sandbox.fynarfin.io"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,26 @@ public void callBatchSummaryAPI(int expectedStatus, int totalTxns) {
});
}

@When("I call the batch summary API with expected status of {int} with total successfull {int} txns")
public void callBatchSummaryAPIBulk(int expectedStatus, int totalTxns) {
await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> {
RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant);
if (authEnabled) {
requestSpec.header("Authorization", "Bearer " + scenarioScopeState.accessToken);
}
// requestSpec.queryParam("batchId", scenarioScopeDef.batchId);
logger.info("Calling with batch id: {}", scenarioScopeState.batchId);

scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(operationsAppConfig.operationAppContactPoint).expect()
.spec(new ResponseSpecBuilder().expectStatusCode(expectedStatus).build()).when()
.get(operationsAppConfig.batchSummaryEndpoint + "/" + scenarioScopeState.batchId).andReturn().asString();

logger.info("Batch Summary Response: " + scenarioScopeState.response);
BatchDTO res = objectMapper.readValue(scenarioScopeState.response, BatchDTO.class);
assertThat(res.getTotal()).isEqualTo(totalTxns);
});
}

@When("I call the batch summary API for gsma with expected status of {int} with total {int} txns")
public void callBatchSummaryAPIGSMA(int expectedStatus, int totalTxns) {
await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> {
Expand Down Expand Up @@ -376,6 +396,19 @@ public void iShouldHaveMatchingTotalTxnCountAndSuccessfulTxnCountInResponse() {
});
}

@And("My total txns {} and successful txn count in response should Match")
public void iShouldHaveMatchingTotalTxnCountAndSuccessfulTxnCount(int totalTxnsCount) {
await().atMost(awaitMost, SECONDS).untilAsserted(() -> {
assertThat(scenarioScopeState.batchDTO).isNotNull();
assertThat(scenarioScopeState.batchDTO.getTotal()).isNotNull();
assertThat(scenarioScopeState.batchDTO.getSuccessful()).isNotNull();
assertThat(scenarioScopeState.batchDTO.getTotal()).isGreaterThan(0);
assertThat(scenarioScopeState.batchDTO.getSuccessful()).isGreaterThan(0);
assertThat(totalTxnsCount).isEqualTo(scenarioScopeState.batchDTO.getSuccessful());

});
}

@When("I can assert the approved count as {int} and approved amount as {int}")
public void iCanAssertTheApprovedCountAsAndApprovedAmountAs(int count, int amount) {
BigDecimal approvedCount = scenarioScopeState.batchDTO.getApprovedCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,49 @@ public void iCallTheBalanceApiForPayeeBalance(String id) throws JsonProcessingEx

}

@Then("I call the balance api for payee {string} balance for combine test cases")
public void iCallTheBalanceApiForPayeeBalanceForCombinedTestsCases(String id) throws JsonProcessingException {
RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant);
String finalEndpoint = amsBalanceEndpoint;
if (scenarioScopeState.payeeIdentifierforBatch == null) {
scenarioScopeState.payeeIdentifierforBatch = new String[9];
}
scenarioScopeState.payeeIdentifierforBatch[Integer.parseInt(id)] = scenarioScopeState.payeeIdentifier;
finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN");
finalEndpoint = finalEndpoint.replace("{IdentifierId}", creditParty.isEmpty() ? scenarioScopeState.payeeIdentifier : 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();
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 payee {string} balance for all combine test cases")
public void iCallTheBalanceApiForPayeeBalanceForAllCombinedTestsCases(String id) throws JsonProcessingException {
RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant);
String finalEndpoint = amsBalanceEndpoint;
if (scenarioScopeState.payeeIdentifierforBatch == null) {
scenarioScopeState.payeeIdentifierforBatch = new String[15];
}
scenarioScopeState.payeeIdentifierforBatch[Integer.parseInt(id)] = scenarioScopeState.payeeIdentifier;
finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN");
finalEndpoint = finalEndpoint.replace("{IdentifierId}", creditParty.isEmpty() ? scenarioScopeState.payeeIdentifier : 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();
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 payee with id {string} balance after credit")
public void iCallTheBalanceApiForPayeeBalanceAfterCredit(String id) throws JsonProcessingException {
RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant);
Expand Down Expand Up @@ -731,6 +774,48 @@ public void iCallTheBalanceApiForPayerBalance(String id) throws JsonProcessingEx

}

@Then("I call the balance api for payer {string} balance for combine test cases")
public void iCallTheBalanceApiForPayerBalanceForCombinedTestCases(String id) throws JsonProcessingException {
RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant);
String finalEndpoint = amsBalanceEndpoint;
if (scenarioScopeState.payerIdentifierforBatch == null) {
scenarioScopeState.payerIdentifierforBatch = new String[9];
}
scenarioScopeState.payerIdentifierforBatch[Integer.parseInt(id)] = scenarioScopeState.payerIdentifier;
finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN");
finalEndpoint = finalEndpoint.replace("{IdentifierId}", debitParty.isEmpty() ? scenarioScopeState.payerIdentifier : 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("Balance Response: " + scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
assertThat(
interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayerForBatch[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;
if (scenarioScopeState.payerIdentifierforBatch == null) {
scenarioScopeState.payerIdentifierforBatch = new String[15];
}
scenarioScopeState.payerIdentifierforBatch[Integer.parseInt(id)] = scenarioScopeState.payerIdentifier;
finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN");
finalEndpoint = finalEndpoint.replace("{IdentifierId}", debitParty.isEmpty() ? scenarioScopeState.payerIdentifier : 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("Balance Response: " + scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
assertThat(
interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)])
.isTrue();

}

@Then("I call the balance api for payer with id {string} balance after debit")
public void iCallTheBalanceApiForPayerBalanceAfterDebit(String id) throws JsonProcessingException {
RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ public void iCreateAIdentityMapperDTOForRegisteringBeneficiary() {
fspIndex = 0;
}
String payeeFsp = payeeFspArray[fspIndex];
BeneficiaryDTO beneficiaryDTO = new BeneficiaryDTO(payeeIdentifier, "00", null, payeeFspConfig.getPayeeFsp(payeeFsp));
BeneficiaryDTO beneficiaryDTO = new BeneficiaryDTO(payeeIdentifier, "00", "1234", payeeFspConfig.getPayeeFsp(payeeFsp));
beneficiaryDTOList.add(beneficiaryDTO);
fspIndex++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,34 @@ public void addRowToCsvFile(String paymentMode, int transferAmount, int id) thro
scenarioScopeState.gsmaP2PAmtDebitForBatch[id + 1] = transferAmount;
}

@Then("add row to csv with current payer and payee, payment mode as {string} and transfer amount {int} and id {int} for combine test cases")
public void addRowToCsvFileForCombinedTestCases(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) {
scenarioScopeState.gsmaP2PAmtDebitForBatch = new int[9];
}
scenarioScopeState.gsmaP2PAmtDebitForBatch[id + 1] = transferAmount;
}

@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) {
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 {

Expand Down Expand Up @@ -565,4 +593,82 @@ public void consolidatedPayeeCreationSteps(String client, String id, int amount)
}
}

@When("I create and setup a {string} with id {string} and account balance of {int} for combine test cases")
public void consolidatedPayeeCreationStepsForCombinedTestsCases(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) {
scenarioScopeState.initialBalForPayerForBatch = new int[9];
}
scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)] = amount;
assertThat(scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)]).isNotNull();

} else if (client.equals("payee")) {
if (scenarioScopeState.initialBalForPayeeForBatch == null) {
scenarioScopeState.initialBalForPayeeForBatch = new int[9];
}
scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)] = amount;
assertThat(scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)]).isNotNull();
}
}

@When("I create and setup a {string} with id {string} and account balance of {int} for multiple payment mode bulk test cases")
public void consolidatedPayeeCreationStepsForMultpliePaymentModeTestsCases(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) {
scenarioScopeState.initialBalForPayerForBatch = new int[14];
}
scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)] = amount;
assertThat(scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)]).isNotNull();

} else if (client.equals("payee")) {
if (scenarioScopeState.initialBalForPayeeForBatch == null) {
scenarioScopeState.initialBalForPayeeForBatch = new int[9];
}
scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)] = amount;
assertThat(scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)]).isNotNull();
}
}

@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) {
scenarioScopeState.initialBalForPayerForBatch = new int[15];
}
scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)] = amount;
assertThat(scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)]).isNotNull();

} else if (client.equals("payee")) {
if (scenarioScopeState.initialBalForPayeeForBatch == null) {
scenarioScopeState.initialBalForPayeeForBatch = new int[15];
}
scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)] = amount;
assertThat(scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)]).isNotNull();
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
id,request_id,payment_mode,payer_identifier_type,payer_identifier,payee_identifier_type,payee_identifier,amount,currency,note
0,bf5e4189-cfa4-4e1b-af87-b759d0cbf5b7,closedloop,msisdn,3860,msisdn,3543,10,USD,Test Payee Payment
1,2b161d23-b2f2-47ae-91e9-a99a30600c9d,closedloop,msisdn,3861,msisdn,3544,5,USD,Test Payee Payment
2,936b2c6f-92fe-4a86-85a3-48611fe8b56a,closedloop,msisdn,3862,msisdn,3545,5,USD,Test Payee Payment
3,f6a7aced-60fb-4542-bb78-cec4b6e9a83c,closedloop,msisdn,3863,msisdn,3546,5,USD,Test Payee Payment
4,d5c48256-6689-4ff5-ba5a-1c0b0d0ae444,closedloop,msisdn,3864,msisdn,3547,5,USD,Test Payee Payment
5,954495f6-d544-4a50-bfc1-862c34a2e569,mojaloop,msisdn,3865,msisdn,3548,3,USD,Test Payee Payment
6,c0c4f551-a48a-4d79-a71d-6cad8f124897,mojaloop,msisdn,3866,msisdn,3548,2,USD,Test Payee Payment
7,0df72164-6bf4-4a4e-941d-520466747fe7,mojaloop,msisdn,3867,msisdn,3549,1,USD,Test Payee Payment
4 changes: 4 additions & 0 deletions src/test/java/resources/batch_demo_csv/batchTransaction.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,request_id,payment_mode,payer_identifier_type,payer_identifier,payee_identifier_type,payee_identifier,amount,currency,note
0,52c36327-2c70-48d1-aaa1-a6b3fe447fcd,mojaloop,msisdn,58,msisdn,53,3,USD,Test Payee Payment
1,0bdc4f1e-b287-408e-a1e1-9d9238ec90ac,mojaloop,msisdn,59,msisdn,53,2,USD,Test Payee Payment
2,3cc19513-7988-40cc-9858-24bdaa8b48fd,mojaloop,msisdn,60,msisdn,54,1,USD,Test Payee Payment
Loading