Skip to content

Commit 19c9b32

Browse files
peter-kovacs-dpcmagyari-adam
authored andcommitted
FINERACT-2203: extended E2E tests
1 parent 3d594fd commit 19c9b32

File tree

3 files changed

+151
-10
lines changed

3 files changed

+151
-10
lines changed

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorMessageHelper.java

+4
Original file line numberDiff line numberDiff line change
@@ -896,4 +896,8 @@ public static String wrongNumberOfLinesInChargeOffReasonOptions(final int actual
896896
public static String wrongExternalID(String actual, String expected) {
897897
return String.format("Wrong transaction External ID - %nActual value is: %s %nExpected value is: %s", actual, expected);
898898
}
899+
900+
public static String wrongValueInTotalPages(Integer actual, Integer expected) {
901+
return String.format("Wrong value for Total pages. %nActual value is: %s %nExpected value is: %s", actual, expected);
902+
}
899903
}

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanStepDef.java

+106-4
Original file line numberDiff line numberDiff line change
@@ -3454,14 +3454,81 @@ public void transactionsExcluded(String excludedTypes) throws IOException {
34543454
}
34553455

34563456
@Then("Log out transaction list by loanExternalId, filtered out the following transaction types: {string}")
3457-
public void transactionsExcludedBzExternalId(String excludedTypes) throws IOException {
3457+
public void transactionsExcludedByExternalId(String excludedTypes) throws IOException {
34583458
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
34593459
String loanExternalId = loanCreateResponse.body().getResourceExternalId();
34603460

3461-
Response<GetLoansLoanIdTransactionsResponse> transactionsByLoanIdFiltered = getTransactionsByLoanIExternalIdFiltered(loanExternalId,
3462-
excludedTypes);
3461+
Response<GetLoansLoanIdTransactionsResponse> transactionsByLoanIExternalIdFiltered = getTransactionsByLoanIExternalIdFiltered(
3462+
loanExternalId, excludedTypes);
34633463
log.info("Transaction list without the following transaction types: {} \n{}", excludedTypes,
3464-
transactionsByLoanIdFiltered.body().toString());
3464+
transactionsByLoanIExternalIdFiltered.body().toString());
3465+
}
3466+
3467+
@Then("Filtered out transactions list contains the the following entries when filtered out by loanId for transaction types: {string}")
3468+
public void transactionsExcludedCheck(String excludedTypes, DataTable table) throws IOException {
3469+
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
3470+
long loanId = loanCreateResponse.body().getLoanId();
3471+
String resourceId = String.valueOf(loanId);
3472+
3473+
Response<GetLoansLoanIdTransactionsResponse> transactionsByLoanIdFiltered = getTransactionsByLoanIdFiltered(loanId, excludedTypes);
3474+
ErrorHelper.checkSuccessfulApiCall(transactionsByLoanIdFiltered);
3475+
List<GetLoansLoanIdTransactionsTransactionIdResponse> transactions = transactionsByLoanIdFiltered.body().getContent();
3476+
List<List<String>> data = table.asLists();
3477+
for (int i = 1; i < data.size(); i++) {
3478+
List<String> expectedValues = data.get(i);
3479+
String transactionDateExpected = expectedValues.get(0);
3480+
List<List<String>> actualValuesList = transactions.stream()//
3481+
.filter(t -> transactionDateExpected.equals(FORMATTER.format(t.getDate())))//
3482+
.map(t -> fetchValuesOfFilteredTransaction(table.row(0), t))//
3483+
.collect(Collectors.toList());//
3484+
boolean containsExpectedValues = actualValuesList.stream()//
3485+
.anyMatch(actualValues -> actualValues.equals(expectedValues));//
3486+
assertThat(containsExpectedValues)
3487+
.as(ErrorMessageHelper.wrongValueInLineInTransactionsTab(resourceId, i, actualValuesList, expectedValues)).isTrue();
3488+
}
3489+
assertThat(transactions.size())
3490+
.as(ErrorMessageHelper.nrOfLinesWrongInTransactionsTab(resourceId, transactions.size(), data.size() - 1))
3491+
.isEqualTo(data.size() - 1);
3492+
}
3493+
3494+
@Then("Filtered out transactions list contains the the following entries when filtered out by loanExternalId for transaction types: {string}")
3495+
public void transactionsExcludedByLoanExternalIdCheck(String excludedTypes, DataTable table) throws IOException {
3496+
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
3497+
String loanExternalId = loanCreateResponse.body().getResourceExternalId();
3498+
long loanId = loanCreateResponse.body().getLoanId();
3499+
String resourceId = String.valueOf(loanId);
3500+
3501+
Response<GetLoansLoanIdTransactionsResponse> transactionsByLoanExternalIdFiltered = getTransactionsByLoanIExternalIdFiltered(
3502+
loanExternalId, excludedTypes);
3503+
ErrorHelper.checkSuccessfulApiCall(transactionsByLoanExternalIdFiltered);
3504+
3505+
List<GetLoansLoanIdTransactionsTransactionIdResponse> transactions = transactionsByLoanExternalIdFiltered.body().getContent();
3506+
List<List<String>> data = table.asLists();
3507+
for (int i = 1; i < data.size(); i++) {
3508+
List<String> expectedValues = data.get(i);
3509+
String transactionDateExpected = expectedValues.get(0);
3510+
List<List<String>> actualValuesList = transactions.stream()//
3511+
.filter(t -> transactionDateExpected.equals(FORMATTER.format(t.getDate())))//
3512+
.map(t -> fetchValuesOfFilteredTransaction(table.row(0), t))//
3513+
.collect(Collectors.toList());//
3514+
boolean containsExpectedValues = actualValuesList.stream()//
3515+
.anyMatch(actualValues -> actualValues.equals(expectedValues));//
3516+
assertThat(containsExpectedValues)
3517+
.as(ErrorMessageHelper.wrongValueInLineInTransactionsTab(resourceId, i, actualValuesList, expectedValues)).isTrue();
3518+
}
3519+
assertThat(transactions.size())
3520+
.as(ErrorMessageHelper.nrOfLinesWrongInTransactionsTab(resourceId, transactions.size(), data.size() - 1))
3521+
.isEqualTo(data.size() - 1);
3522+
}
3523+
3524+
@Then("Filtered out transactions list request results an error when filtered out by loanExternalId for transaction type not exist: {string}")
3525+
public void transactionsExcludedErrorNotPresent(String transactionsExcluded) throws IOException {
3526+
// Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
3527+
// long loanId = loanCreateResponse.body().getLoanId();
3528+
3529+
// Response<GetLoansLoanIdTransactionsResponse> transactionsByLoanIdFiltered =
3530+
// getTransactionsByLoanIdFiltered(loanId, transactionsExcluded);
3531+
// TODO make checks here
34653532
}
34663533

34673534
private Response<GetLoansLoanIdTransactionsResponse> getTransactionsByLoanIdFiltered(Long loanId, String excludedTypes)
@@ -3473,4 +3540,39 @@ private Response<GetLoansLoanIdTransactionsResponse> getTransactionsByLoanIExter
34733540
String excludedTypes) throws IOException {
34743541
return loanTransactionsApi.retrieveTransactionsByExternalLoanId(loanExternalId, excludedTypes, null, null, null).execute();
34753542
}
3543+
3544+
private List<String> fetchValuesOfFilteredTransaction(List<String> header, GetLoansLoanIdTransactionsTransactionIdResponse t) {
3545+
List<String> actualValues = new ArrayList<>();
3546+
for (String headerName : header) {
3547+
switch (headerName) {
3548+
case "Transaction date" -> actualValues.add(t.getDate() == null ? null : FORMATTER.format(t.getDate()));
3549+
case "Transaction Type" -> actualValues.add(t.getType().getCode() == null ? null : t.getType().getCode().substring(20));
3550+
case "Amount" -> actualValues.add(t.getAmount() == null ? null : String.valueOf(t.getAmount()));
3551+
case "Principal" -> actualValues.add(t.getPrincipalPortion() == null ? null : String.valueOf(t.getPrincipalPortion()));
3552+
case "Interest" -> actualValues.add(t.getInterestPortion() == null ? null : String.valueOf(t.getInterestPortion()));
3553+
case "Fees" -> actualValues.add(t.getFeeChargesPortion() == null ? null : String.valueOf(t.getFeeChargesPortion()));
3554+
case "Penalties" ->
3555+
actualValues.add(t.getPenaltyChargesPortion() == null ? null : String.valueOf(t.getPenaltyChargesPortion()));
3556+
case "Loan Balance" ->
3557+
actualValues.add(t.getOutstandingLoanBalance() == null ? null : String.valueOf(t.getOutstandingLoanBalance()));
3558+
case "Overpayment" ->
3559+
actualValues.add(t.getOverpaymentPortion() == null ? null : String.valueOf(t.getOverpaymentPortion()));
3560+
default -> throw new IllegalStateException(String.format("Header name %s cannot be found", headerName));
3561+
}
3562+
}
3563+
return actualValues;
3564+
}
3565+
3566+
@Then("Filtered out transactions list has {int} pages in case of size set to {int} and transactions are filtered out for transaction types: {string}")
3567+
public void checkPagination(Integer totalPagesExpected, Integer size, String excludedTypes) throws IOException {
3568+
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
3569+
long loanId = loanCreateResponse.body().getLoanId();
3570+
Response<GetLoansLoanIdTransactionsResponse> transactionsByLoanIdFiltered = loanTransactionsApi
3571+
.retrieveTransactionsByLoanId(loanId, excludedTypes, null, size, null).execute();
3572+
3573+
Integer totalPagesActual = transactionsByLoanIdFiltered.body().getTotalPages();
3574+
3575+
assertThat(totalPagesActual).as(ErrorMessageHelper.wrongValueInTotalPages(totalPagesActual, totalPagesExpected))
3576+
.isEqualTo(totalPagesExpected);
3577+
}
34763578
}

fineract-e2e-tests-runner/src/test/resources/features/LoanAccrualActivity.feature

+41-6
Original file line numberDiff line numberDiff line change
@@ -6404,16 +6404,51 @@ Feature: LoanAccrualActivity
64046404

64056405
@TestRailId:C3533
64066406
Scenario: Logging out transaction list, excluded given transaction types
6407-
When Admin sets the business date to "01 January 2024"
6407+
When Admin sets the business date to "01 January 2025"
64086408
When Admin creates a client with random data
64096409
When Admin creates a fully customized loan with the following data:
64106410
| LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy |
6411-
| LP2_ADV_PYMNT_INTEREST_RECOGNITION_DISBURSEMENT_DAILY_EMI_360_30_ACCRUAL_ACTIVITY | 01 January 2024 | 2000 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
6412-
And Admin successfully approves the loan on "01 January 2024" with "2000" amount and expected disbursement date on "01 January 2024"
6413-
When Admin successfully disburse the loan on "01 January 2024" with "2000" EUR transaction amount
6411+
| LP2_ADV_PYMNT_INTEREST_RECOGNITION_DISBURSEMENT_DAILY_EMI_360_30_ACCRUAL_ACTIVITY | 01 January 2025 | 2000 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
6412+
And Admin successfully approves the loan on "01 January 2025" with "2000" amount and expected disbursement date on "01 January 2025"
6413+
When Admin successfully disburse the loan on "01 January 2025" with "2000" EUR transaction amount
64146414
And Admin runs inline COB job for Loan
6415-
When Admin sets the business date to "05 January 2024"
6416-
And Customer makes "AUTOPAY" repayment on "05 January 2024" with 200 EUR transaction amount
6415+
When Admin sets the business date to "05 January 2025"
6416+
And Customer makes "AUTOPAY" repayment on "05 January 2025" with 200 EUR transaction amount
64176417
And Admin runs inline COB job for Loan
6418+
And Loan Transactions tab has the following data:
6419+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
6420+
| 01 January 2025 | Disbursement | 2000.0 | 0.0 | 0.0 | 0.0 | 0.0 | 2000.0 | false | false |
6421+
| 01 January 2025 | Accrual | 0.38 | 0.0 | 0.38 | 0.0 | 0.0 | 0.0 | false | false |
6422+
| 02 January 2025 | Accrual | 0.37 | 0.0 | 0.37 | 0.0 | 0.0 | 0.0 | false | false |
6423+
| 03 January 2025 | Accrual | 0.38 | 0.0 | 0.38 | 0.0 | 0.0 | 0.0 | false | false |
6424+
| 04 January 2025 | Accrual | 0.38 | 0.0 | 0.38 | 0.0 | 0.0 | 0.0 | false | false |
6425+
| 05 January 2025 | Repayment | 200.0 | 200.0 | 0.0 | 0.0 | 0.0 | 1800.0 | false | false |
64186426
Then Log out transaction list by loanId, filtered out the following transaction types: "disbursement, accrual"
64196427
Then Log out transaction list by loanExternalId, filtered out the following transaction types: "accrual"
6428+
Then Filtered out transactions list contains the the following entries when filtered out by loanId for transaction types: "accrual"
6429+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
6430+
| 01 January 2025 | disbursement | 2000.0 | | | | | 2000.0 |
6431+
| 05 January 2025 | repayment | 200.0 | 200.0 | | | | 1800.0 |
6432+
Then Filtered out transactions list contains the the following entries when filtered out by loanExternalId for transaction types: "accrual"
6433+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
6434+
| 01 January 2025 | disbursement | 2000.0 | | | | | 2000.0 |
6435+
| 05 January 2025 | repayment | 200.0 | 200.0 | | | | 1800.0 |
6436+
Then Filtered out transactions list contains the the following entries when filtered out by loanId for transaction types: ""
6437+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
6438+
| 01 January 2025 | disbursement | 2000.0 | | | | | 2000.0 |
6439+
| 01 January 2025 | accrual | 0.38 | | 0.38 | | | |
6440+
| 02 January 2025 | accrual | 0.37 | | 0.37 | | | |
6441+
| 03 January 2025 | accrual | 0.38 | | 0.38 | | | |
6442+
| 04 January 2025 | accrual | 0.38 | | 0.38 | | | |
6443+
| 05 January 2025 | repayment | 200.0 | 200.0 | | | | 1800.0 |
6444+
# TODO recheck when enums for txn types are implemented (what are the rules for existing but not present txn types AND what for NOT existing txn types)
6445+
# Then Filtered out transactions list contains the the following entries when filtered out by loanId for transaction types: "merchant_issued_refund"
6446+
# | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
6447+
# | 01 January 2025 | disbursement | 2000.0 | | | | | 2000.0 |
6448+
# | 01 January 2025 | accrual | 0.38 | | 0.38 | | | |
6449+
# | 02 January 2025 | accrual | 0.37 | | 0.37 | | | |
6450+
# | 03 January 2025 | accrual | 0.38 | | 0.38 | | | |
6451+
# | 04 January 2025 | accrual | 0.38 | | 0.38 | | | |
6452+
# | 05 January 2025 | repayment | 200.0 | 200.0 | | | | 1800.0 |
6453+
# Then Filtered out transactions list request results an error when filtered out by loanExternalId for transaction type not exist: "test"
6454+
Then Filtered out transactions list has 4 pages in case of size set to 1 and transactions are filtered out for transaction types: "disbursement, repayment"

0 commit comments

Comments
 (0)