Skip to content

Commit

Permalink
FINERACT-1971: Flaky test improvement on BatchAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
galovics committed Oct 26, 2023
1 parent e602fa6 commit c13742f
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) accountDetails.get("transactions");
final float runningBalanceBeforeBatch = (float) transactions.get(0).get("runningBalance");

Expand All @@ -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<HashMap<String, Object>>) accountDetails.get("transactions");

final HashMap<String, Object> transactionRelease = transactions.get(2);
Expand Down

0 comments on commit c13742f

Please sign in to comment.