FINERACT-2649: Migrate Tier 3 loan integration tests to Feign client#6084
FINERACT-2649: Migrate Tier 3 loan integration tests to Feign client#6084DeathGun44 wants to merge 13 commits into
Conversation
|
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 |
9276e89 to
1d32a0e
Compare
Aman-Mittal
left a comment
There was a problem hiding this comment.
I am still reviewing this one.....
1d32a0e to
ba3e948
Compare
ba3e948 to
07c5b62
Compare
|
@DeathGun44 Please rebase. |
…elpers Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
… Feign Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
…sts to Feign Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
…to Feign Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
… dates Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
… Feign Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
… and down-payment schedule tests to Feign Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
…ests to Feign Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
…d Feign tests Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
07c5b62 to
94261bf
Compare
|
@adamsaghy Done! |
budaidev
left a comment
There was a problem hiding this comment.
The PR has a massive scope and a lot of changes, so the lot of comments doesn't mean it's bad, but I would advise to fix those to keep the refactor clean. The direction is really good.
Also please avoid any behavior changes in the test, by modifying or removing assertations, because it could lead silent errors.
| */ | ||
| public Long createLoanProductFromJson(String loanProductJson) { | ||
| try { | ||
| String sanitizedJson = loanProductJson.replaceAll("(?<=\\d),(?=\\d{3})", ""); |
There was a problem hiding this comment.
Here, any numeric array/sequence where a value with ≥3 digits follows a comma gets silently merged. For example: {"loanIds":[5,1000]} → {"loanIds":[51000]}. I don't think this is the indended behaviour here.
|
|
||
| public <T> T getLoanProductError(String loanProductJson, String jsonAttributeToGetBack) { | ||
| try { | ||
| String sanitizedJson = loanProductJson.replaceAll("(?<=\\d),(?=\\d{3})", ""); |
There was a problem hiding this comment.
Here, any numeric array/sequence where a value with ≥3 digits follows a comma gets silently merged. For example: {"loanIds":[5,1000]} → {"loanIds":[51000]}. I don't think this is the indended behaviour here.
| @@ -114,12 +155,11 @@ public static void setupHelpers() { | |||
| codeHelper = new FeignCodeHelper(client); | |||
| globalConfigurationHelper = new FeignGlobalConfigurationHelper(client); | |||
| schedulerHelper = new FeignSchedulerHelper(client); | |||
| externalEventHelper = new FeignExternalEventHelper(client); | |||
| accounts = new LoanTestAccounts(accountHelper); | |||
There was a problem hiding this comment.
accounts = new LoanTestAccounts(accountHelper) is now eager in @BeforeAll (was lazy in getAccounts()). That's ~21 create-GL-account calls and 21 junk accounts per test class — for all 56 classes this PR moves onto the base, including ones that never touch accounting. Please restore lazy initialization.
| this.overpaymentAccount = getAccounts().getOverpaymentAccount(); | ||
| } | ||
|
|
||
| private ClientHelper clientHelper; |
There was a problem hiding this comment.
unused here, no init no usage
| this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec); | ||
| this.assetAccount = this.accountHelper.createAssetAccount(); | ||
| this.incomeAccount = this.accountHelper.createIncomeAccount(); | ||
| this.expenseAccount = this.accountHelper.createExpenseAccount(); | ||
| this.overpaymentAccount = this.accountHelper.createLiabilityAccount(); | ||
| } | ||
|
|
||
| private ClientHelper clientHelper; |
There was a problem hiding this comment.
unused here, it shadows the parent classes field
| public void testCenterReschedulingMultiTrancheLoansWithInterestRecalculationEnabled() { | ||
|
|
||
| Integer officeId = new OfficeHelper().createOffice(LocalDate.of(2007, 7, 1)).getResourceId().intValue(); | ||
| Long officeId = new FeignOfficeHelper(fineractClient()).createOffice(LocalDate.of(2007, Month.JULY, 1)).getResourceId(); |
There was a problem hiding this comment.
Direct new FeignOfficeHelper(fineractClient()) in the test (helpers belong in the base per the test-infra conventions)
| Long loanProductId = createLoanProduct(product); | ||
| GetLoanProductsProductIdResponse retrievedProduct = retrieveLoanProduct(loanProductId); | ||
| assertNotNull(retrievedProduct); | ||
| return loanProductId; | ||
| } | ||
|
|
||
| private Long addChargeWithCurrency(Long loanId, boolean isPenalty, double amount, String dueDate, String currencyCode) { |
There was a problem hiding this comment.
ignores isPenalty and always creates a fee. Branch to the penalty builder or drop the parameter
| Integer penalty = ChargesHelper.createCharges(requestSpec, responseSpec, | ||
| ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "10", true)); | ||
|
|
||
| Long penalty = createLoanSpecifiedDueDateCharge(10.0); |
| Assertions.assertNotNull(deletedFinancialActivityAccountId); | ||
| Assertions.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId); | ||
| @AfterEach | ||
| public void tearDownFinancialActivityAccounts() { |
There was a problem hiding this comment.
AfterEach now deletes all financial-activity mappings after every test (original: one mapping once in AfterAll) and mapLiabilityTransferFinancialActivity(Long) ignores its parameter; new FinancialActivityAccountHelper(null) is fragile. Also the savings product lost withMinimumOpenningBalance("10000.0").
| return ok(() -> fineractClient.rescheduleLoans().createLoanRescheduleRequest(request)); | ||
| } | ||
|
|
||
| public CallFailedRuntimeException createRescheduleRequestExpectingError(PostCreateRescheduleLoansRequest request) { |
There was a problem hiding this comment.
createRescheduleRequestExpectingError is dead code with a latent bug: the recalc path throws AssertionError (RestAssured expectStatusCode(200)), which FeignCalls.fail() doesn't catch — it can never return the expected exception. Remove or implement via Feign
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 13 commits, grouped logically by test area (reschedule, chargebacks, APA, down-payments, etc.) 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:
BigDecimalprecision assertions across migrated Feign tests.Bug Fix: Incorrect journal entry assertions in
UndoLoanDisbursalWithDownPaymentIntegrationTestDuring the migration, the stricter Feign
verifyJournalEntries()(which performs exact 1-to-1 matching with count validation) exposed a pre-existing bug ondevelopin two test methods:testUndoDisbursalForLoanWithSingleDisbursalAutoDownPaymentEnabledAndHasManualTransactionstestUndoDisbursalForLoanWithMultiDisbursalAutoDownPaymentEnabledAndHasManualTransactionsBoth 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:
InternalLoanReAgeApi: Supports specific internal API flows related to the re-aging of loans.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.runAt): Expanded theFeignLoanTestBaseto cleanly execute nested operations under specific simulated business dates.Awaitility-based assertions for robust verification of asynchronous business events.Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.