Skip to content

Commit 5f830f3

Browse files
author
Rustam Zeinalov
committed
FINERACT-2203: finalized e2e tests and updated step defenitions
1 parent 19c9b32 commit 5f830f3

File tree

3 files changed

+36
-29
lines changed

3 files changed

+36
-29
lines changed

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

+24-17
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,7 @@
4343
import java.time.Duration;
4444
import java.time.LocalDate;
4545
import java.time.format.DateTimeFormatter;
46-
import java.util.ArrayList;
47-
import java.util.Comparator;
48-
import java.util.HashMap;
49-
import java.util.List;
50-
import java.util.Map;
51-
import java.util.Objects;
52-
import java.util.Optional;
53-
import java.util.Set;
54-
import java.util.UUID;
46+
import java.util.*;
5547
import java.util.stream.Collectors;
5648
import lombok.extern.slf4j.Slf4j;
5749
import org.apache.fineract.avro.loan.v1.LoanAccountDataV1;
@@ -3523,22 +3515,36 @@ public void transactionsExcludedByLoanExternalIdCheck(String excludedTypes, Data
35233515

35243516
@Then("Filtered out transactions list request results an error when filtered out by loanExternalId for transaction type not exist: {string}")
35253517
public void transactionsExcludedErrorNotPresent(String transactionsExcluded) throws IOException {
3526-
// Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
3527-
// long loanId = loanCreateResponse.body().getLoanId();
3518+
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
3519+
String loanExternalId = loanCreateResponse.body().getResourceExternalId();
3520+
3521+
Response<GetLoansLoanIdTransactionsResponse> transactionsByLoanExternalIdFiltered = getTransactionsByLoanIExternalIdFiltered(
3522+
loanExternalId, transactionsExcluded);
35283523

3529-
// Response<GetLoansLoanIdTransactionsResponse> transactionsByLoanIdFiltered =
3530-
// getTransactionsByLoanIdFiltered(loanId, transactionsExcluded);
3531-
// TODO make checks here
3524+
boolean isTransactionPresent = transactionsByLoanExternalIdFiltered.body().getContent().stream()
3525+
.anyMatch(item -> item.getType().equals(org.apache.fineract.client.models.TransactionType.fromValue(transactionsExcluded)));
3526+
assertThat(isTransactionPresent).isFalse();
35323527
}
35333528

35343529
private Response<GetLoansLoanIdTransactionsResponse> getTransactionsByLoanIdFiltered(Long loanId, String excludedTypes)
35353530
throws IOException {
3536-
return loanTransactionsApi.retrieveTransactionsByLoanId(loanId, excludedTypes, null, null, null).execute();
3531+
return loanTransactionsApi.retrieveTransactionsByLoanId(loanId, parseExcludedTypes(excludedTypes), null, null, null).execute();
35373532
}
35383533

35393534
private Response<GetLoansLoanIdTransactionsResponse> getTransactionsByLoanIExternalIdFiltered(String loanExternalId,
35403535
String excludedTypes) throws IOException {
3541-
return loanTransactionsApi.retrieveTransactionsByExternalLoanId(loanExternalId, excludedTypes, null, null, null).execute();
3536+
3537+
return loanTransactionsApi.retrieveTransactionsByExternalLoanId(loanExternalId, parseExcludedTypes(excludedTypes), null, null, null)
3538+
.execute();
3539+
}
3540+
3541+
public static List<org.apache.fineract.client.models.TransactionType> parseExcludedTypes(String excludedTypes) {
3542+
if (excludedTypes == null || excludedTypes.trim().isEmpty()) {
3543+
return Collections.emptyList();
3544+
} else {
3545+
return Arrays.stream(excludedTypes.split(",")).map(String::trim).map(String::toUpperCase)
3546+
.map(org.apache.fineract.client.models.TransactionType::valueOf).collect(Collectors.toList());
3547+
}
35423548
}
35433549

35443550
private List<String> fetchValuesOfFilteredTransaction(List<String> header, GetLoansLoanIdTransactionsTransactionIdResponse t) {
@@ -3567,8 +3573,9 @@ private List<String> fetchValuesOfFilteredTransaction(List<String> header, GetLo
35673573
public void checkPagination(Integer totalPagesExpected, Integer size, String excludedTypes) throws IOException {
35683574
Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
35693575
long loanId = loanCreateResponse.body().getLoanId();
3576+
35703577
Response<GetLoansLoanIdTransactionsResponse> transactionsByLoanIdFiltered = loanTransactionsApi
3571-
.retrieveTransactionsByLoanId(loanId, excludedTypes, null, size, null).execute();
3578+
.retrieveTransactionsByLoanId(loanId, parseExcludedTypes(excludedTypes), null, size, null).execute();
35723579

35733580
Integer totalPagesActual = transactionsByLoanIdFiltered.body().getTotalPages();
35743581

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -6442,13 +6442,13 @@ Feature: LoanAccrualActivity
64426442
| 04 January 2025 | accrual | 0.38 | | 0.38 | | | |
64436443
| 05 January 2025 | repayment | 200.0 | 200.0 | | | | 1800.0 |
64446444
# 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"
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: "waiver"
64546454
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"

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ Feature: LoanAccrualTransaction
11391139
| 20 February 2025 | Accrual | 0.02 | 0.0 | 0.02 | 0.0 | 0.0 | 0.0 | false | false |
11401140
| 21 February 2025 | Accrual | 0.02 | 0.0 | 0.02 | 0.0 | 0.0 | 0.0 | false | false |
11411141

1142-
@TestRailId:C3532
1142+
@TestRailId:C3535
11431143
Scenario: Verify the accrual activity creation in case of full repayment on maturity date - absence of negative numbers with low interest rate and small principal
11441144
When Admin sets the business date to "19 February 2025"
11451145
And Admin creates a client with random data
@@ -1280,7 +1280,7 @@ Feature: LoanAccrualTransaction
12801280
| 19 February 2025 | Repayment | 0.67 | 0.6 | 0.07 | 0.0 | 0.0 | 6.91 | false | false |
12811281
| 20 February 2025 | Merchant Issued Refund | 3.35 | 3.35 | 0.0 | 0.0 | 0.0 | 3.56 | false | false |
12821282

1283-
@TestRailId:C3533
1283+
@TestRailId:C3536
12841284
Scenario: Verify the accrual activity creation in case of full repayment on maturity date - absence of negative numbers with high interest rate and large principal
12851285
When Admin sets the business date to "19 February 2025"
12861286
And Admin creates a client with random data
@@ -1424,7 +1424,7 @@ Feature: LoanAccrualTransaction
14241424
| 20 February 2025 | Accrual | 12.33 | 0.0 | 12.33 | 0.0 | 0.0 | 0.0 | false | false |
14251425
| 20 February 2025 | Accrual | 12.33 | 0.0 | 12.33 | 0.0 | 0.0 | 0.0 | false | false |
14261426

1427-
@TestRailId:C3534
1427+
@TestRailId:C3537
14281428
Scenario: Verify the accrual activity creation in case of full repayment on maturity date - absence of negative numbers with mid-range interest rate and mid-range principal
14291429
When Admin sets the business date to "19 February 2025"
14301430
And Admin creates a client with random data

0 commit comments

Comments
 (0)