|
43 | 43 | import java.time.Duration;
|
44 | 44 | import java.time.LocalDate;
|
45 | 45 | 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.*; |
55 | 47 | import java.util.stream.Collectors;
|
56 | 48 | import lombok.extern.slf4j.Slf4j;
|
57 | 49 | import org.apache.fineract.avro.loan.v1.LoanAccountDataV1;
|
@@ -3523,22 +3515,36 @@ public void transactionsExcludedByLoanExternalIdCheck(String excludedTypes, Data
|
3523 | 3515 |
|
3524 | 3516 | @Then("Filtered out transactions list request results an error when filtered out by loanExternalId for transaction type not exist: {string}")
|
3525 | 3517 | 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); |
3528 | 3523 |
|
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(); |
3532 | 3527 | }
|
3533 | 3528 |
|
3534 | 3529 | private Response<GetLoansLoanIdTransactionsResponse> getTransactionsByLoanIdFiltered(Long loanId, String excludedTypes)
|
3535 | 3530 | throws IOException {
|
3536 |
| - return loanTransactionsApi.retrieveTransactionsByLoanId(loanId, excludedTypes, null, null, null).execute(); |
| 3531 | + return loanTransactionsApi.retrieveTransactionsByLoanId(loanId, parseExcludedTypes(excludedTypes), null, null, null).execute(); |
3537 | 3532 | }
|
3538 | 3533 |
|
3539 | 3534 | private Response<GetLoansLoanIdTransactionsResponse> getTransactionsByLoanIExternalIdFiltered(String loanExternalId,
|
3540 | 3535 | 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 | + } |
3542 | 3548 | }
|
3543 | 3549 |
|
3544 | 3550 | private List<String> fetchValuesOfFilteredTransaction(List<String> header, GetLoansLoanIdTransactionsTransactionIdResponse t) {
|
@@ -3567,8 +3573,9 @@ private List<String> fetchValuesOfFilteredTransaction(List<String> header, GetLo
|
3567 | 3573 | public void checkPagination(Integer totalPagesExpected, Integer size, String excludedTypes) throws IOException {
|
3568 | 3574 | Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
3569 | 3575 | long loanId = loanCreateResponse.body().getLoanId();
|
| 3576 | + |
3570 | 3577 | Response<GetLoansLoanIdTransactionsResponse> transactionsByLoanIdFiltered = loanTransactionsApi
|
3571 |
| - .retrieveTransactionsByLoanId(loanId, excludedTypes, null, size, null).execute(); |
| 3578 | + .retrieveTransactionsByLoanId(loanId, parseExcludedTypes(excludedTypes), null, size, null).execute(); |
3572 | 3579 |
|
3573 | 3580 | Integer totalPagesActual = transactionsByLoanIdFiltered.body().getTotalPages();
|
3574 | 3581 |
|
|
0 commit comments