Skip to content

FINERACT-2553: Modernize Integration Test Helpers to use Fineract-Client#5666

Open
Avtansh88 wants to merge 1 commit intoapache:developfrom
Avtansh88:gsoc/modernize-user-helper
Open

FINERACT-2553: Modernize Integration Test Helpers to use Fineract-Client#5666
Avtansh88 wants to merge 1 commit intoapache:developfrom
Avtansh88:gsoc/modernize-user-helper

Conversation

@Avtansh88
Copy link
Copy Markdown
Contributor

@Avtansh88 Avtansh88 commented Mar 21, 2026

## Description

This PR serves as a Proof of Concept (PoC) for my GSoC 2026 proposal: "Modernizing Integration Tests with Fineract-Client". The goal is to migrate legacy RestAssured based helper methods to the type-safe Fineract-Client (Feign), aligning with the project's long-term modernization strategy.

Key Improvements:

->Helper Modernization: Fully refactored UserHelper.java and RolesHelper.java. Replaced manual Utils.performServerPost/Get calls with type-safe methods from FineractClientHelper.getFineractClient().

->Type-Safe Request Models: Eliminated error-prone manual JSON string building. The integration tests now utilize OpenAPI-generated models such as PostUsersRequest, PutUsersRequest, and PostRolesRequest.

->Integration Test Updates: Updated UserAdministrationTest and RolesTest to be compatible with the modernized helpers, ensuring seamless end-to-end execution.

->Simplified Method Signatures: Removed redundant RequestSpecification and ResponseSpecification parameters from modernized methods to reduce boilerplate code while maintaining backward compatibility where necessary.

->Improved Error Handling: Leveraged Calls.ok() for cleaner response validation and better exception management during test execution.

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.

@vidakovic
Copy link
Copy Markdown
Contributor

vidakovic commented Mar 22, 2026

No proper Jira ticket referenced. Is this a problem we have identified or a spontaneous improvement? In short: no Jira ticket, no PR. Please provide a ticket and format the PR title according to the rules ("FINERACT-1234: Some title here"), thanks.

@Avtansh88
Copy link
Copy Markdown
Contributor Author

Hi @vidakovic, thanks for the guidance.I've already requested a Jira account to create the formal ticket for this improvement. It might take a couple of days for approval. Once it's active, I'll link the ticket here and update the PR title accordingly. In the meantime, I'm also working on modernizing other helpers like RolesHelper to ensure consistency. Thanks for your patience.

@Avtansh88 Avtansh88 force-pushed the gsoc/modernize-user-helper branch 2 times, most recently from 4b8d017 to 09a084a Compare March 23, 2026 15:31
@Avtansh88 Avtansh88 changed the title FINERACT-GSOC: Modernize UserHelper and RolesHelper with Fineract-Client FINERACT-2553: Modernize Integration Test Helpers to use Fineract-Client Mar 24, 2026
@Avtansh88 Avtansh88 force-pushed the gsoc/modernize-user-helper branch from 09a084a to 0492f18 Compare March 24, 2026 15:26
@Avtansh88
Copy link
Copy Markdown
Contributor Author

Hi @vidakovic , I've updated the PR with the Jira ticket FINERACT-2553 and included the modernization for both UserHelper and RolesHelper. The commits are now GPG-verified as well. Looking forward to your feedback when you have a moment. Thanks

@vidakovic
Copy link
Copy Markdown
Contributor

@Avtansh88 ... there are still failing tests... ping again when all these are green.

@Avtansh88 Avtansh88 force-pushed the gsoc/modernize-user-helper branch from 752298b to 25c5217 Compare March 26, 2026 10:43
@Avtansh88 Avtansh88 closed this Mar 26, 2026
@Avtansh88 Avtansh88 force-pushed the gsoc/modernize-user-helper branch from 25c5217 to 5956214 Compare March 26, 2026 15:04
@Avtansh88 Avtansh88 reopened this Mar 27, 2026
@Avtansh88
Copy link
Copy Markdown
Contributor Author

@vidakovic I have modernized UserHelper and RolesHelper using the Fineract client and updated the corresponding integration tests (UserAdministrationTest and RolesTest). All tests are passing locally. Could you please approve the workflows so the CI checks can run? Thanks.

@adamsaghy
Copy link
Copy Markdown
Contributor

Please run:
./gradlew spotlessApply spotbugsMain spotbugsTest checkstyleMain checkstyleTest
./gradlew --no-daemon build -x test -x cucumber -x doc

@Avtansh88 Avtansh88 force-pushed the gsoc/modernize-user-helper branch 2 times, most recently from 858e963 to c2a83f5 Compare April 4, 2026 14:46
@adamsaghy
Copy link
Copy Markdown
Contributor

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':integration-tests:spotlessJavaCheck'.
> The following files had format violations:
      src/test/java/org/apache/fineract/integrationtests/RolesTest.java
          @@ -26,6 +26,7 @@
           import·io.restassured.http.ContentType;
           import·io.restassured.specification.RequestSpecification;
           import·io.restassured.specification.ResponseSpecification;
          +import·java.util.List;
           import·org.apache.fineract.client.models.GetRolesRoleIdResponse;
           import·org.apache.fineract.client.models.PostUsersRequest;
           import·org.apache.fineract.client.models.PostUsersResponse;
          @@ -40,7 +41,6 @@
           import·org.junit.jupiter.api.Test;
           import·org.slf4j.Logger;
           import·org.slf4j.LoggerFactory;
          -import·java.util.List;
           
           public·class·RolesTest·{
           
          @@ -76,7 +76,7 @@
           ········LOG.info("---------------------------------·DISABLING·ROLE·-------------------------------");
           ········PutRolesRoleIdResponse·disableResponse·=·RolesHelper.disableRole(roleId);
           ········assertEquals(roleId.longValue(),·disableResponse.getResourceId());
          -········
          +
           ········GetRolesRoleIdResponse·role·=·RolesHelper.getRoleDetails(roleId);
           ········assertEquals(true,·role.getDisabled());
           ····}
          @@ -92,7 +92,7 @@
           ········LOG.info("---------------------------------·ENABLING·ROLE·-------------------------------");
           ········PutRolesRoleIdResponse·enableResponse·=·RolesHelper.enableRole(roleId);
           ········assertEquals(roleId.longValue(),·enableResponse.getResourceId());
          -········
          +
           ········GetRolesRoleIdResponse·role·=·RolesHelper.getRoleDetails(roleId);
           ········assertEquals(false,·role.getDisabled());
           ····}
          @@ -101,10 +101,10 @@
           ····public·void·testDeleteRoleStatus()·{
           ········LOG.info("--------------------------------·CREATING·A·ROLE---------------------------------------------");
           ········final·Integer·roleId·=·RolesHelper.createRole(this.requestSpec,·this.responseSpec);
          -········
          +
           ········LOG.info("---------------------------------·DELETE·ROLE·-------------------------------");
           ········RolesHelper.deleteRole(roleId);

          -········
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

          +
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.14.3/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
631 actionable tasks: 226 executed, 243 from cache, 162 up-to-date
           ········//·Verifying·deletion·by·attempting·to·get·details·(should·fail)
           ········Assertions.assertThrows(CallFailedRuntimeException.class,·()·->·{
           ············RolesHelper.getRoleDetails(roleId);
          @@ -116,12 +116,11 @@
           ········final·Integer·roleId·=·RolesHelper.createRole(this.requestSpec,·this.responseSpec);
      ... (36 more lines that didn't fit)
  Violations also present in:
      src/test/java/org/apache/fineract/integrationtests/UserAdministrationTest.java
      src/test/java/org/apache/fineract/integrationtests/useradministration/roles/RolesHelper.java
      src/test/java/org/apache/fineract/integrationtests/useradministration/users/UserHelper.java
  Run './gradlew :integration-tests:spotlessApply' to fix these violations.

Also exceptions:


> Task :integration-tests:compileTestJava
  warning: No processor claimed any of these annotations: java.compiler/javax.annotation.processing.Generated
  /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/useradministration/roles/RolesHelper.java:33: error: cannot find symbol
  import org.apache.fineract.client.models.PutRolesPermissionsRequest;
                                          ^
    symbol:   class PutRolesPermissionsRequest
    location: package org.apache.fineract.client.models
  /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/useradministration/roles/RolesHelper.java:34: error: cannot find symbol
  import org.apache.fineract.client.models.PutRolesPermissionsResponse;
                                          ^
    symbol:   class PutRolesPermissionsResponse
    location: package org.apache.fineract.client.models
  /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/useradministration/roles/RolesHelper.java:87: error: cannot find symbol
      public static PutRolesPermissionsResponse addPermissionsToRole(final RequestSpecification requestSpec,
                    ^
    symbol:   class PutRolesPermissionsResponse
    location: class RolesHelper
  /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/UserAdministrationTest.java:35: error: cannot find symbol
  import org.apache.fineract.client.models.PutUsersRequest;
                                          ^
    symbol:   class PutUsersRequest
    location: package org.apache.fineract.client.models
  /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/useradministration/users/UserHelper.java:33: error: cannot find symbol
  import org.apache.fineract.client.models.PutUsersRequest;
                                          ^
    symbol:   class PutUsersRequest
    location: package org.apache.fineract.client.models
  /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/useradministration/users/UserHelper.java:34: error: cannot find symbol
  import org.apache.fineract.client.models.PutUsersResponse;
                                          ^
    symbol:   class PutUsersResponse
    location: package org.apache.fineract.client.models
  /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/useradministration/users/UserHelper.java:78: error: cannot find symbol
      public static PutUsersResponse updateUser(final Long userId, final PutUsersRequest request) {
                                                                         ^
    symbol:   class PutUsersRequest
    location: class UserHelper
  /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/useradministration/users/UserHelper.java:78: error: cannot find symbol
      public static PutUsersResponse updateUser(final Long userId, final PutUsersRequest request) {
                    ^
    symbol:   class PutUsersResponse
    location: class UserHelper
  8 errors

@Avtansh88 Avtansh88 force-pushed the gsoc/modernize-user-helper branch 2 times, most recently from 8edd73e to 3f18620 Compare April 7, 2026 19:54
@adamsaghy
Copy link
Copy Markdown
Contributor

* What went wrong:
Execution failed for task ':integration-tests:compileTestJava'.
> Compilation failed; see the compiler output below.
  /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/NotificationApiTest.java:21: error: cannot find symbol
  import static org.apache.fineract.integrationtests.useradministration.roles.RolesHelper.SUPER_USER_ROLE_ID;
  ^
    symbol:   static SUPER_USER_ROLE_ID
    location: class RolesHelper
  48 errors
  1,500 warnings

@Avtansh88 Avtansh88 force-pushed the gsoc/modernize-user-helper branch from 3f18620 to 79491af Compare April 9, 2026 11:05
@Avtansh88
Copy link
Copy Markdown
Contributor Author

Hi @adamsaghy ,

I have updated the PR. I've modernized the UserHelper and RolesHelper classes and their respective integration tests (UserAdministrationTest and RolesTest) using the Java Client POJO models and static methods.

I have verified the changes locally, and the build is successful. I've also cleaned up the git history to ensure a single clean commit with only the necessary file changes.

Ready for your review.

@Avtansh88 Avtansh88 force-pushed the gsoc/modernize-user-helper branch from 79491af to 983e514 Compare April 11, 2026 06:13
@Avtansh88
Copy link
Copy Markdown
Contributor Author

Hi @adamsaghy , I have modernized UserHelper and RolesHelper and added the corresponding integration tests. I've also ensured that my changes pass the local build and Spotless formatting (verified with ./gradlew :integration-tests:spotlessApply).

Regarding the CI failures (PostgreSQL and Messaging), they appear to be environment-related flakiness as seen in other ongoing PRs. The core logic and formatting are now clean and ready for your review.

@adamsaghy
Copy link
Copy Markdown
Contributor

`What went wrong:
Execution failed for task ':integration-tests:checkstyleTest'.

A failure occurred while executing org.gradle.api.plugins.quality.internal.CheckstyleAction
Checkstyle rule violations were found. See the report at: file:///home/runner/work/fineract/fineract/integration-tests/build/reports/checkstyle/test.html
Checkstyle files with violations: 1
Checkstyle violations by severity: [error:1]`

@Avtansh88 Avtansh88 force-pushed the gsoc/modernize-user-helper branch from 983e514 to 2574e52 Compare April 11, 2026 17:12
@Avtansh88
Copy link
Copy Markdown
Contributor Author

Hi @adamsaghy,

I have fixed the Checkstyle violations and the build is now passing locally.

Key Implementation Details:

Utility Class Pattern: To resolve the HideUtilityClassConstructor violation, I have made the constructors of UserHelper and RolesHelper private.

Defensive Coding: Inside these private constructors, I’ve added throw new UnsupportedOperationException("This is a utility class and cannot be instantiated") to strictly prevent any runtime instantiation.

Refactored Callers: I've updated MakercheckerTest and other integration tests to use static method calls (e.g., UserHelper.createUser(...)) to align with this modernization.

Verification: Verified locally with ./gradlew :integration-tests:checkstyleTest and compileTestJava. Both are now showing Successful Build.

Ready for your review..

@Avtansh88 Avtansh88 force-pushed the gsoc/modernize-user-helper branch from 7941732 to e31cf15 Compare April 12, 2026 14:58
@Avtansh88
Copy link
Copy Markdown
Contributor Author

Hi @adamsaghy , I have refactored the code to use direct static utility patterns in UserHelper and RolesHelper. Also, I've fixed the permission logic in MakercheckerTest and squashed all changes into a single clean commit. Please have a look. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants