This is an automated email from the ASF dual-hosted git repository. adamsaghy pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/fineract.git
commit d36beea75c1b1f983bf30fbcc7fe4fb9a9b6d96d Author: Rustam Zeinalov <[email protected]> AuthorDate: Tue Mar 10 16:31:34 2026 +0100 FINERACT-2455: added e2e tests for Working Capital Loan - Inline COB --- .../common/WorkingCapitalLoanCobStepDef.java | 19 ++--- .../resources/features/WorkingCapital_COB.feature | 80 ++++++++++++++++------ 2 files changed, 70 insertions(+), 29 deletions(-) diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/WorkingCapitalLoanCobStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/WorkingCapitalLoanCobStepDef.java index 34243fe0fe..c6a51ac665 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/WorkingCapitalLoanCobStepDef.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/WorkingCapitalLoanCobStepDef.java @@ -88,7 +88,15 @@ public class WorkingCapitalLoanCobStepDef extends AbstractStepDef { @When("Admin runs inline COB job for Working Capital Loan") public void runWorkingCapitalInlineCOB() throws IOException { InlineJobRequest inlineJobRequest = new InlineJobRequest().addLoanIdsItem(getTrackedLoanIds().getLast()); + ok(() -> fineractClient.inlineJob().executeInlineJob("WC_LOAN_COB", inlineJobRequest)); + } + @When("Admin runs inline COB job for all Working Capital Loans") + public void runWorkingCapitalInlineCOBForAll() throws IOException { + InlineJobRequest inlineJobRequest = new InlineJobRequest(); + for (Long loanId : getTrackedLoanIds()) { + inlineJobRequest.addLoanIdsItem(loanId); + } ok(() -> fineractClient.inlineJob().executeInlineJob("WC_LOAN_COB", inlineJobRequest)); } @@ -224,25 +232,20 @@ public class WorkingCapitalLoanCobStepDef extends AbstractStepDef { .until(() -> { IsCatchUpRunningDTO isCatchUpRunningResponse = ok( () -> fineractClient.workingCapitalLoanCobCatchUpApi().isCatchUpRunning1()); - IsCatchUpRunningDTO isCatchUpRunning = isCatchUpRunningResponse; - return isCatchUpRunning.getCatchUpRunning(); + return isCatchUpRunningResponse.getCatchUpRunning(); }); // Then wait for catch-up to complete await().atMost(Duration.ofMinutes(4)).pollInterval(Duration.ofSeconds(5)).pollDelay(Duration.ofSeconds(5)).until(() -> { - // Check if catch-up is still running IsCatchUpRunningDTO statusResponse = ok(() -> fineractClient.workingCapitalLoanCobCatchUpApi().isCatchUpRunning1()); - // Only proceed with date check if catch-up is not running if (!statusResponse.getCatchUpRunning()) { - // Get the current business date BusinessDateResponse businessDateResponse = ok( () -> fineractClient.businessDateManagement().getBusinessDate(BusinessDateHelper.COB, Map.of())); LocalDate currentBusinessDate = businessDateResponse.getDate(); - // Get the last closed business date - OldestCOBProcessedLoanDTO catchUpResponse = ok(() -> fineractClient.loanCobCatchUp().getOldestCOBProcessedLoan()); + OldestCOBProcessedLoanDTO catchUpResponse = ok( + () -> fineractClient.workingCapitalLoanCobCatchUpApi().getOldestCOBProcessedLoan1()); LocalDate lastClosedDate = catchUpResponse.getCobBusinessDate(); - // Verify that the last closed date is not before the current business date return !lastClosedDate.isBefore(currentBusinessDate); } return false; diff --git a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapital_COB.feature b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapital_COB.feature index 63d7c0dedb..d360f08a9f 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapital_COB.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapital_COB.feature @@ -29,7 +29,7 @@ Feature: Working Capital COB Job When Admin sets the business date to "02 January 2024" When Admin runs WC COB job - @TestRailId:C4698 + @TestRailId:C70320 Scenario: WC COB updates lastClosedBusinessDate for a single active loan # Behavioral test: inserts a WC loan via JDBC, runs COB, verifies lastClosedBusinessDate is set. When Admin sets the business date to "01 January 2024" @@ -37,14 +37,14 @@ Feature: Working Capital COB Job When Admin runs WC COB job Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" - @TestRailId:C4699 + @TestRailId:C70231 Scenario: WC COB processes multiple loans in a single run When Admin sets the business date to "01 January 2024" Given Admin inserts 3 active WC loans into the database When Admin runs WC COB job Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" - @TestRailId:C4700 + @TestRailId:C70232 Scenario: WC COB advances lastClosedBusinessDate over consecutive business dates When Admin sets the business date to "01 January 2024" Given Admin inserts an active WC loan into the database @@ -55,7 +55,7 @@ Feature: Working Capital COB Job Then Admin verifies all inserted WC loans have lastClosedBusinessDate "01 January 2024" Then Admin verifies all inserted WC loans have version 2 - @TestRailId:C4701 + @TestRailId:C70233 Scenario: WC COB does not reprocess loans already closed for the business date # Verifies idempotency — running COB twice on the same business date doesn't cause errors or duplicate processing. When Admin sets the business date to "01 January 2024" @@ -66,7 +66,7 @@ Feature: Working Capital COB Job Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" Then Admin verifies all inserted WC loans have version 1 - @TestRailId:C4702 + @TestRailId:C70234 Scenario: WC COB skips loans with ineligible status (closed obligations met) # COB only processes non-closed statuses: SUBMITTED_AND_PENDING_APPROVAL, APPROVED, ACTIVE, # TRANSFER_IN_PROGRESS, TRANSFER_ON_HOLD. Closed loans should be skipped. @@ -75,7 +75,7 @@ Feature: Working Capital COB Job When Admin runs WC COB job Then Admin verifies all inserted WC loans have null lastClosedBusinessDate - @TestRailId:C4703 + @TestRailId:C70235 Scenario: WC COB processes loans with eligible non-active statuses When Admin sets the business date to "01 January 2024" Given Admin inserts a WC loan with status "SUBMITTED_AND_PENDING_APPROVAL" into the database @@ -83,7 +83,7 @@ Feature: Working Capital COB Job When Admin runs WC COB job Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" - @TestRailId:C4704 + @TestRailId:C70236 Scenario: WC COB processes loans with transfer statuses When Admin sets the business date to "01 January 2024" Given Admin inserts a WC loan with status "TRANSFER_IN_PROGRESS" into the database @@ -91,7 +91,7 @@ Feature: Working Capital COB Job When Admin runs WC COB job Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" - @TestRailId:C4705 + @TestRailId:C70237 Scenario: WC COB skips loans already closed for the current business date When Admin sets the business date to "01 January 2024" Given Admin inserts a WC loan with status "ACTIVE" and lastClosedBusinessDate "31 December 2023" into the database @@ -99,14 +99,14 @@ Feature: Working Capital COB Job Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" Then Admin verifies all inserted WC loans have version 0 - @TestRailId:C4706 + @TestRailId:C70238 Scenario: WC COB advances a loan that is exactly one day behind When Admin sets the business date to "02 January 2024" Given Admin inserts a WC loan with status "ACTIVE" and lastClosedBusinessDate "31 December 2023" into the database When Admin runs WC COB job Then Admin verifies all inserted WC loans have lastClosedBusinessDate "01 January 2024" - @TestRailId:C4707 + @TestRailId:C70239 Scenario: WC COB releases all account locks after completion # After COB completes, no lingering account locks should remain for processed loans. When Admin sets the business date to "01 January 2024" @@ -115,14 +115,14 @@ Feature: Working Capital COB Job Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" Then Admin verifies all inserted WC loans have no account locks - @TestRailId:C4708 + @TestRailId:C70240 Scenario: WC COB handles a batch of 10 loans When Admin sets the business date to "01 January 2024" Given Admin inserts 10 active WC loans into the database When Admin runs WC COB job Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" - @TestRailId:C4709 + @TestRailId:C70241 Scenario: WC COB increments loan version after processing When Admin sets the business date to "01 January 2024" Given Admin inserts an active WC loan into the database @@ -131,7 +131,7 @@ Feature: Working Capital COB Job Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" Then Admin verifies all inserted WC loans have version 1 - @TestRailId:C4710 + @TestRailId:C70242 Scenario: WC COB processes eligible loans and skips ineligible ones in the same batch # Mix of eligible (ACTIVE) and ineligible (CLOSED_OBLIGATIONS_MET) loans — only eligible should be updated. When Admin sets the business date to "01 January 2024" @@ -141,9 +141,38 @@ Feature: Working Capital COB Job Then Admin verifies inserted WC loan 1 has lastClosedBusinessDate "31 December 2023" Then Admin verifies inserted WC loan 2 has null lastClosedBusinessDate + #----------# + @TestRailId:C70243 + Scenario: Inline WC COB processes a single loan and releases locks + When Admin sets the business date to "01 January 2024" + Given Admin inserts an active WC loan into the database + When Admin runs inline COB job for Working Capital Loan + Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" + Then Admin verifies all inserted WC loans have no account locks + Then Admin verifies all inserted WC loans have version 1 + + @TestRailId:C70244 + Scenario: Inline WC COB processes multiple loans in a single request + When Admin sets the business date to "01 January 2024" + Given Admin inserts 3 active WC loans into the database + When Admin runs inline COB job for all Working Capital Loans + Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" + Then Admin verifies all inserted WC loans have version 1 + + @TestRailId:C70245 + Scenario: Inline WC COB and batch WC COB coexistence + When Admin sets the business date to "01 January 2024" + Given Admin inserts an active WC loan into the database + When Admin runs WC COB job + Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" + Then Admin verifies all inserted WC loans have version 1 + When Admin sets the business date to "02 January 2024" + When Admin runs inline COB job for Working Capital Loan + Then Admin verifies all inserted WC loans have lastClosedBusinessDate "01 January 2024" + Then Admin verifies all inserted WC loans have version 2 - @TestRailId:CXXXX - Scenario: inline WC COB advances lastClosedBusinessDate over consecutive business dates + @TestRailId:C70246 + Scenario: Inline WC COB advances lastClosedBusinessDate over consecutive business dates When Admin sets the business date to "01 January 2024" Given Admin inserts an active WC loan into the database When Admin runs inline COB job for Working Capital Loan @@ -153,8 +182,8 @@ Feature: Working Capital COB Job Then Admin verifies all inserted WC loans have lastClosedBusinessDate "01 January 2024" Then Admin verifies all inserted WC loans have version 2 - @TestRailId:CXXXX - Scenario: inline WC COB advances lastClosedBusinessDate over skipped business dates + @TestRailId:C70247 + Scenario: Inline WC COB advances lastClosedBusinessDate over skipped business dates When Admin sets the business date to "01 January 2024" Given Admin inserts an active WC loan into the database When Admin runs inline COB job for Working Capital Loan @@ -162,10 +191,9 @@ Feature: Working Capital COB Job When Admin sets the business date to "05 January 2024" When Admin runs inline COB job for Working Capital Loan Then Admin verifies all inserted WC loans have lastClosedBusinessDate "04 January 2024" - ## version 1 is the created and 3 days of inline catchup happened then the actual which indicates version 5 Then Admin verifies all inserted WC loans have version 5 - @TestRailId:CXXXX + @TestRailId:C70248 Scenario: Working Capital COB catch up advances lastClosedBusinessDate over skipped business dates When Admin sets the business date to "01 January 2024" Given Admin inserts an active WC loan into the database @@ -176,5 +204,15 @@ Feature: Working Capital COB Job When Admin runs COB catch up Then Admin checks that WC Loan COB is running until the current business date Then Admin verifies all inserted WC loans have lastClosedBusinessDate "04 January 2024" - ## version 1 is the created and 3 days of inline catchup happened then the actual which indicates version 5 - Then Admin verifies all inserted WC loans have version 5 \ No newline at end of file + Then Admin verifies all inserted WC loans have version 5 + + @TestRailId:C70249 + Scenario: WC COB catch-up is skipped when loans are already up to date + When Admin sets the business date to "01 January 2024" + Given Admin inserts an active WC loan into the database + When Admin runs WC COB job + Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" + Then Admin verifies all inserted WC loans have version 1 + When Admin runs Working Capital COB catch up + Then Admin verifies all inserted WC loans have lastClosedBusinessDate "31 December 2023" + Then Admin verifies all inserted WC loans have version 1 \ No newline at end of file
