From c13742f70487e898c6c72bb74ea9c66fde66fcb8 Mon Sep 17 00:00:00 2001 From: Arnold Galovics Date: Thu, 26 Oct 2023 09:43:23 +0200 Subject: [PATCH] FINERACT-1971: Flaky test improvement on BatchAPI --- .../integrationtests/BatchApiTest.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchApiTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchApiTest.java index 765e4a03e6f..616c23c655f 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchApiTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchApiTest.java @@ -2559,9 +2559,25 @@ public void shoulRetrieveTheProperErrorDuringLockedLoan() { @Test public void verifyCalculatingRunningBalanceAfterBatchWithReleaseAmount() { + final SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); + final SavingsAccountHelper savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); + final Integer clientID = ClientHelper.createClient(requestSpec, responseSpec); + Assertions.assertNotNull(clientID); + final String savingsProductJSON = savingsProductHelper.withInterestCompoundingPeriodTypeAsDaily() + .withInterestPostingPeriodTypeAsDaily().withInterestCalculationPeriodTypeAsDailyBalance().build(); + final Integer savingsProductID = SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec); + Assertions.assertNotNull(savingsProductID); + final Integer savingsId = savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, + ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); + Assertions.assertNotNull(savingsId); + HashMap savingsStatusHashMap = savingsAccountHelper.approveSavings(savingsId); + SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); + savingsStatusHashMap = savingsAccountHelper.activateSavings(savingsId); + SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); + final float holdAmount = 10F; final float withdrawalAmount = 80F; - final BatchRequest getSavingAccountRequest = BatchHelper.getSavingAccount(1L, 2L, "chargeStatus=all", null); + final BatchRequest getSavingAccountRequest = BatchHelper.getSavingAccount(1L, Long.valueOf(savingsId), "chargeStatus=all", null); final BatchRequest depositSavingAccountRequest = BatchHelper.depositSavingAccount(2L, 1L, 300F); final BatchRequest holdAmountOnSavingAccountRequest = BatchHelper.holdAmountOnSavingAccount(3L, 1L, holdAmount); @@ -2576,8 +2592,7 @@ public void verifyCalculatingRunningBalanceAfterBatchWithReleaseAmount() { final FromJsonHelper jsonHelper = new FromJsonHelper(); final Long holdAmountTransactionId = jsonHelper.parse(responses1.get(2).getBody()).getAsJsonObject().get("resourceId").getAsLong(); - final SavingsAccountHelper savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); - HashMap accountDetails = savingsAccountHelper.getSavingsDetails(2); + HashMap accountDetails = savingsAccountHelper.getSavingsDetails(savingsId); ArrayList> transactions = (ArrayList>) accountDetails.get("transactions"); final float runningBalanceBeforeBatch = (float) transactions.get(0).get("runningBalance"); @@ -2595,7 +2610,7 @@ public void verifyCalculatingRunningBalanceAfterBatchWithReleaseAmount() { Assertions.assertEquals(HttpStatus.SC_OK, responses2.get(1).getStatusCode(), "Verify Status Code 200 for withdraw saving account"); Assertions.assertEquals(HttpStatus.SC_OK, responses2.get(2).getStatusCode(), "Verify Status Code 200 for withdraw saving account"); - accountDetails = savingsAccountHelper.getSavingsDetails(2); + accountDetails = savingsAccountHelper.getSavingsDetails(savingsId); transactions = (ArrayList>) accountDetails.get("transactions"); final HashMap transactionRelease = transactions.get(2);