FINERACT-2649: Migrate Tier 3 loan integration tests to Feign client
Description
This PR transitions 56 test classes (encompassing approximately 277 test methods) to utilize the Feign client, entirely removing their dependency on REST-assured.
Note on Behavior: The core test behavior and assertions remain completely unchanged. This is strictly a refactor of the underlying HTTP client layer.
Targeted commits
I've split this work into 14 commits, grouped logically by test area (reschedule, chargebacks, APA, down-payments, etc.) plus a dedicated review-feedback refinement commit to keep things manageable for review.
This will ensure that if CI fails or issues arise later, it is much easier to isolate and track down the specific batch that introduced the regression.
Scope
Included in this PR:
- Comprehensive Loan Rescheduling and Re-aging tests (including Center/Group reschedules).
- Chargeback integration scenarios (non-APA workflows, overpaid loans, payment type constraints).
- Down-payment workflows (product configuration, transaction typing, undo disbursal, and repayment schedules).
- Advanced Payment Allocation (APA) coverage for write-offs, transaction reprocessing, and external-id support.
- Client loan lifecycle tests (credit balance refund, multiple disbursements, floating rates, and date validations).
- Reverse-replay transaction relations and loan summary tests.
- Standardization of
BigDecimalprecision assertions across migrated Feign tests.
Review Feedback & OpenAPI Refinements
Based on maintainer review feedback, this PR also includes cleanups to improve codebase hygiene and client generation:
- OpenAPI Schema Fix (
retrieveTransactionTemplate): Corrected@ApiResponseonretrieveTransactionTemplateto declareLoanTransactionData.classinstead ofGetLoansLoanIdTransactionsTemplateResponse.class. This aligns the OpenAPI definition with actual wire runtime behavior and enables standard generated Feign clients to deserialize transaction templates without custom workarounds. - Strongly Typed Response Models: Replaced untyped
HashMap<String, Object>test builder responses with strongly-typed generated models (PostLoansResponse,PostLoansLoanIdResponse). - Simplified Business Date Context: Streamlined
FeignBusinessDateHelper.runAt(...)by removing unnecessary nestedThreadLocaldepth tracking. - Date Readability: Standardized
LocalDate.of(...)calls to use concise numeric month parameters.
Bug Fix: Incorrect journal entry assertions in UndoLoanDisbursalWithDownPaymentIntegrationTest
During the migration, the stricter Feign verifyJournalEntries() (which performs exact 1-to-1 matching with count validation) exposed a pre-existing bug on develop in two test methods:
testUndoDisbursalForLoanWithSingleDisbursalAutoDownPaymentEnabledAndHasManualTransactionstestUndoDisbursalForLoanWithMultiDisbursalAutoDownPaymentEnabledAndHasManualTransactions
Both tests make a manual repayment of 100.0 after disbursement, then undo the disbursal. The "repayment entries compensated" journal entry assertions incorrectly expected 250.0 (the down-payment amount) instead of 100.0 (the actual repayment amount). The old REST-assured based verifyJournalEntries() had more lenient matching semantics that masked this error. Fixed as part of the migration commit.
Infrastructure Enhancements
This PR builds upon the shared Feign test infrastructure from earlier batches, adding and extending several utilities to streamline testing:
FeignGroupCenterHelper: Provides utilities for managing group and center associations during loan testing.FeignRawHttpHelper: Safely handles edge cases that require raw HTTP requests to bypass strict Swagger model limitations (e.g., floating rate properties), utilizingfineract.it.urlsecurely.- Business Date Context (
runAt): Cleanly executes operations under simulated business dates with guaranteed cleanup. - Event Verification: Integrated
Awaitility-based assertions for robust verification of asynchronous business events. - Shared Builders & Validators: Expanded Feign loan helpers for external-ids, re-amortizations, write-offs, and credit allocations.
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
- [ ] Write the commit message as per our guidelines
- [ ] Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
- [ ] Create/update unit or integration tests for verifying the changes made.
- [ ] Follow our coding conventions.
- [ ] Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
- [ ] This PR must not be a "code dump". Large changes can be made in a branch, with assistance. Ask for help on the developer mailing list.
Your assigned reviewer(s) will follow our guidelines for code reviews.
the test is failing and the issue is in develop itself, because a reversal of a 100.0 repayment should produce 100.0 journal entries, not 250.0. i am adding a fix for it in the pr and describing it in the description aswell
@DeathGun44 Please rebase.
@adamsaghy Done!
@budaidev Thank you for the thorough review! I enjoy all these reviews as they help me learn a lot. I know there is a lot of code to go through. I will keep trying my best to make it as clean as possible and easier to review, and I'll make sure the quality of the code doesn't deteriorate with these bulk prs. Thanks again, everyone, for keeping up!
please rebase and handle the conflicts
@adamsaghy @budaidev Done!
Regarding the OpenAPI backward-compatibility check failure: this is expected due to updating the @ApiResponse schema on retrieveTransactionTemplate from GetLoansLoanIdTransactionsTemplateResponse to LoanTransactionData.
Inspecting LoanTransactionsApiResource.java shows the endpoint uses DefaultToApiJsonSerializer
the other test failure is just flaky ,should pass on rerun. I have also updated the pr description with regard to the current state
@adamsaghy please take a look when you have a moment!
I am postponing to merge this till release of 1.15.0 is not finished