Skip to content

Commit

Permalink
FINERACT-2181: E2E test external ID check fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-kovacs-dpc committed Mar 7, 2025
1 parent 60d7e38 commit d2cb57f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -892,4 +892,8 @@ public static String wrongNumberOfLinesInChargeOffReasonOptions(final int actual
"Number of lines in loan charge-off reason options is not correct. Actual value is: %d - Expected value is: %d", actual,
expected);
}

public static String wrongExternalID(String actual, String expected) {
return String.format("Wrong transaction External ID - %nActual value is: %s %nExpected value is: %s", actual, expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2424,7 +2424,27 @@ public void checkLoanAdjustTransactionBusinessEventNotCreated(String date) throw
.noneMatch(t -> date.equals(FORMATTER.format(t.getDate())) && "Accrual Adjustment".equals(t.getType().getValue()));
}

@Then("External ID for the replayed Accrual Activity on {string} is present but is null for the original transaction")
@When("Save external ID of {string} transaction made on {string}")
public void saveExternalIdForTransaction(String transactionName, String transactionDate) throws IOException {
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
long loanId = loanCreateResponse.body().getLoanId();

Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);

List<GetLoansLoanIdTransactions> transactions = loanDetailsResponse.body().getTransactions();

GetLoansLoanIdTransactions loadTransaction = transactions.stream()
.filter(t -> transactionDate.equals(FORMATTER.format(t.getDate())) && transactionName.equals(t.getType().getValue()))
.findFirst().orElseThrow(
() -> new IllegalStateException(String.format("No %s transaction found on %s", transactionName, transactionDate)));

String externalId = loadTransaction.getExternalId();
testContext().set(TestContextKey.TRANSACTION_EXTERNAL_ID, externalId);
log.info("Transaction external ID: {} saved to testContext", externalId);
}

@Then("External ID for the replayed Accrual Activity on {string} is present and the same as it was for the original transaction and was nulled for the original transaction")
public void checkExternalIdForReplayedAccrualActivity(String date) throws IOException {
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
long loanId = loanCreateResponse.body().getLoanId();
Expand All @@ -2445,8 +2465,10 @@ public void checkExternalIdForReplayedAccrualActivity(String date) throws IOExce

Response<GetLoansLoanIdTransactionsTransactionIdResponse> replayedTransaction = loanTransactionsApi
.retrieveTransaction(loanId, replayedTransactionId, "").execute();
assertNotNull(String.format("Replayed transaction external id is null %n%s", replayedTransaction.body()),
replayedTransaction.body().getExternalId());
String externalIdExpected = testContext().get(TestContextKey.TRANSACTION_EXTERNAL_ID).toString();
String externalIdActual = replayedTransaction.body().getExternalId();
assertThat(externalIdActual).as(ErrorMessageHelper.wrongExternalID(externalIdActual, externalIdExpected))
.isEqualTo(externalIdExpected);

Response<GetLoansLoanIdTransactionsTransactionIdResponse> originalTransaction = loanTransactionsApi
.retrieveTransaction(loanId, originalTransactionId, "").execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,5 @@ public abstract class TestContextKey {
public static final String LOAN_WRITE_OFF_RESPONSE = "loanWriteOffResponse";
public static final String LOAN_DELINQUENCY_ACTION_RESPONSE = "loanDelinquencyActionResponse";
public static final String LOAN_TRANSACTION_RESPONSE = "loanTransactionResponse";
public static final String TRANSACTION_EXTERNAL_ID = "transactionExternalId";
}
Original file line number Diff line number Diff line change
Expand Up @@ -6066,6 +6066,7 @@ Feature: LoanAccrualActivity
| 01 January 2025 | Disbursement | 800.0 | 0.0 | 0.0 | 0.0 | 0.0 | 800.0 | false | false |
| 01 February 2025 | Accrual | 4.67 | 0.0 | 4.67 | 0.0 | 0.0 | 0.0 | false | false |
| 01 February 2025 | Accrual Activity | 4.67 | 0.0 | 4.67 | 0.0 | 0.0 | 0.0 | false | false |
When Save external ID of "Accrual Activity" transaction made on "01 February 2025"
When Customer makes "AUTOPAY" repayment on "31 January 2025" with 900 EUR transaction amount
Then Loan Repayment schedule has 6 periods, with the following data for periods:
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
Expand All @@ -6088,7 +6089,7 @@ Feature: LoanAccrualActivity
| 02 February 2025 | Accrual Adjustment | 0.15 | 0.0 | 0.15 | 0.0 | 0.0 | 0.0 | false | false |
And LoanAdjustTransactionBusinessEvent is raised for the origin of Accrual Activity on "31 January 2025" but not raised for the replayed one
And LoanAccrualAdjustmentTransactionBusinessEvent is raised on "02 February 2025"
And External ID for the replayed Accrual Activity on "31 January 2025" is present but is null for the original transaction
And External ID for the replayed Accrual Activity on "31 January 2025" is present and the same as it was for the original transaction and was nulled for the original transaction

@TestRailId:C3526
Scenario: Verify accrual activity behavior in case of repayment reversal on an overpaid loan - UC2
Expand Down Expand Up @@ -6138,6 +6139,7 @@ Feature: LoanAccrualActivity
| 10 March 2025 | Repayment | 80.0 | 75.71 | 0.21 | 0.0 | 0.0 | 0.0 | false | false |
| 10 March 2025 | Accrual | 0.02 | 0.0 | 0.02 | 0.0 | 0.0 | 0.0 | false | false |
| 10 March 2025 | Accrual Activity | 0.21 | 0.0 | 0.21 | 0.0 | 0.0 | 0.0 | false | false |
When Save external ID of "Accrual Activity" transaction made on "10 March 2025"
When Customer undo "1"th "Repayment" transaction made on "10 March 2025"
Then Loan Repayment schedule has 6 periods, with the following data for periods:
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
Expand All @@ -6159,7 +6161,7 @@ Feature: LoanAccrualActivity
| 10 March 2025 | Accrual | 0.02 | 0.0 | 0.02 | 0.0 | 0.0 | 0.0 | false | false |
| 25 March 2025 | Accrual Activity | 0.44 | 0.0 | 0.44 | 0.0 | 0.0 | 0.0 | false | true |
And LoanAdjustTransactionBusinessEvent is raised for the origin of Accrual Activity on "25 March 2025" but not raised for the replayed one
And External ID for the replayed Accrual Activity on "25 March 2025" is present but is null for the original transaction
And External ID for the replayed Accrual Activity on "25 March 2025" is present and the same as it was for the original transaction and was nulled for the original transaction

@TestRailId:C3527
Scenario: Verify accrual activity behavior in case repayment reversal before the installment date - UC3
Expand Down Expand Up @@ -6269,6 +6271,7 @@ Feature: LoanAccrualActivity
| 27 January 2025 | Repayment | 816.46 | 800.0 | 3.91 | 0.0 | 0.0 | 0.0 | false | false |
| 27 January 2025 | Accrual | 3.91 | 0.0 | 3.91 | 0.0 | 0.0 | 0.0 | false | false |
| 27 January 2025 | Accrual Activity | 3.91 | 0.0 | 3.91 | 0.0 | 0.0 | 0.0 | false | false |
When Save external ID of "Accrual Activity" transaction made on "27 January 2025"
When Admin sets the business date to "03 February 2025"
And Customer undo "1"th "Repayment" transaction made on "27 January 2025"
Then Loan Repayment schedule has 6 periods, with the following data for periods:
Expand All @@ -6290,7 +6293,7 @@ Feature: LoanAccrualActivity
| 27 January 2025 | Accrual | 3.91 | 0.0 | 3.91 | 0.0 | 0.0 | 0.0 | false | false |
| 01 February 2025 | Accrual Activity | 4.67 | 0.0 | 4.67 | 0.0 | 0.0 | 0.0 | false | true |
And LoanAdjustTransactionBusinessEvent is raised for the origin of Accrual Activity on "01 February 2025" but not raised for the replayed one
And External ID for the replayed Accrual Activity on "01 February 2025" is present but is null for the original transaction
And External ID for the replayed Accrual Activity on "01 February 2025" is present and the same as it was for the original transaction and was nulled for the original transaction

@TestRailId:C3529
Scenario: Verify accrual activity behavior when COB runs on installment date and backdated repayment happens - UC5
Expand Down Expand Up @@ -6320,6 +6323,7 @@ Feature: LoanAccrualActivity
| 01 January 2025 | Disbursement | 800.0 | 0.0 | 0.0 | 0.0 | 0.0 | 800.0 | false | false |
| 01 February 2025 | Accrual | 4.67 | 0.0 | 4.67 | 0.0 | 0.0 | 0.0 | false | false |
| 01 February 2025 | Accrual Activity | 4.67 | 0.0 | 4.67 | 0.0 | 0.0 | 0.0 | false | false |
When Save external ID of "Accrual Activity" transaction made on "01 February 2025"
When Customer makes "AUTOPAY" repayment on "27 January 2025" with 800 EUR transaction amount
Then Loan Repayment schedule has 6 periods, with the following data for periods:
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
Expand All @@ -6340,7 +6344,7 @@ Feature: LoanAccrualActivity
| 01 February 2025 | Accrual | 4.67 | 0.0 | 4.67 | 0.0 | 0.0 | 0.0 | false | false |
| 01 February 2025 | Accrual Activity | 3.91 | 0.0 | 3.91 | 0.0 | 0.0 | 0.0 | false | true |
And LoanAdjustTransactionBusinessEvent is raised for the origin of Accrual Activity on "01 February 2025" but not raised for the replayed one
And External ID for the replayed Accrual Activity on "01 February 2025" is present but is null for the original transaction
And External ID for the replayed Accrual Activity on "01 February 2025" is present and the same as it was for the original transaction and was nulled for the original transaction

@TestRailId:C3530
Scenario: Verify accrual activity behavior in case of partial payment which is reversed after the installment date - UC6
Expand Down Expand Up @@ -6373,6 +6377,7 @@ Feature: LoanAccrualActivity
| 15 January 2025 | Repayment | 100.0 | 100.0 | 0.0 | 0.0 | 0.0 | 700.0 | false | false |
| 01 February 2025 | Accrual | 4.35 | 0.0 | 4.35 | 0.0 | 0.0 | 0.0 | false | false |
| 01 February 2025 | Accrual Activity | 4.35 | 0.0 | 4.35 | 0.0 | 0.0 | 0.0 | false | false |
When Save external ID of "Accrual Activity" transaction made on "01 February 2025"
When Customer undo "1"th "Repayment" transaction made on "15 January 2025"
Then Loan Repayment schedule has 6 periods, with the following data for periods:
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
Expand All @@ -6393,4 +6398,4 @@ Feature: LoanAccrualActivity
| 01 February 2025 | Accrual | 4.35 | 0.0 | 4.35 | 0.0 | 0.0 | 0.0 | false | false |
| 01 February 2025 | Accrual Activity | 4.67 | 0.0 | 4.67 | 0.0 | 0.0 | 0.0 | false | true |
And LoanAdjustTransactionBusinessEvent is raised for the origin of Accrual Activity on "01 February 2025" but not raised for the replayed one
And External ID for the replayed Accrual Activity on "01 February 2025" is present but is null for the original transaction
And External ID for the replayed Accrual Activity on "01 February 2025" is present and the same as it was for the original transaction and was nulled for the original transaction

0 comments on commit d2cb57f

Please sign in to comment.