fineract icon indicating copy to clipboard operation
fineract copied to clipboard

FINERACT-2494: Add unit tests for ApiParameterHelper in fineract-core

Open Ambika-Sony opened this issue 8 months ago • 11 comments

This PR introduces a comprehensive unit test suite for ApiParameterHelper in the fineract-core module, covering key methods such as getOffset, getLimit, getCommandId, and getLocale, including important edge cases like null inputs, negative values, and malformed parameters.

The goal is to improve reliability and ensure consistent parameter parsing behavior across API requests.

Additionally, minor refactoring has been performed to resolve static analysis (Error Prone) warnings, such as optimizing regex handling using pre-compiled Pattern constants. These changes are strictly non-functional and do not alter existing behavior.

Verification Results Local Build: Verified with ./gradlew :fineract-savings:compileJava — BUILD SUCCESSFUL.

Checklist [x] Write the commit message as per our guidelines.

[x] Acknowledge that we will not review PRs that are not passing the build ("green").

[x] Follow our coding conventions.

[x] This PR is focused on a single task (Savings API standardization).

Ambika-Sony avatar Mar 20 '26 16:03 Ambika-Sony

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':fineract-core:compileTestJava'.
> Compilation failed; see the compiler output below.
  warning: No processor claimed any of these annotations: /org.junit.jupiter.params.provider.ValueSource,/org.junit.jupiter.api.AfterAll,/org.junit.jupiter.api.Test,/org.junit.jupiter.api.extension.ExtendWith,/org.junit.jupiter.api.BeforeAll,/org.junit.jupiter.api.AfterEach,/org.mockito.Mock,/org.junit.jupiter.api.DisplayName,/org.mockito.InjectMocks,/org.junit.jupiter.api.BeforeEach,/org.junit.jupiter.params.provider.CsvSource,/org.junit.jupiter.params.ParameterizedTest,/org.mockito.junit.jupiter.MockitoSettings,/org.mockito.Spy
  1 error

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.
307 actionable tasks: 270 executed, 10 from cache, 27 up-to-date
  8 warnings
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':fineract-core:checkstyleMain'.
> 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/fineract-core/build/reports/checkstyle/main.html
     Checkstyle files with violations: 1
     Checkstyle violations by severity: [error:1]

adamsaghy avatar Mar 24 '26 14:03 adamsaghy

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':fineract-core:compileTestJava'.
> Compilation failed; see the compiler output below.
  warning: No processor claimed any of these annotations: /org.junit.jupiter.params.provider.ValueSource,/org.junit.jupiter.api.AfterAll,/org.junit.jupiter.api.Test,/org.junit.jupiter.api.extension.ExtendWith,/org.junit.jupiter.api.BeforeAll,/org.junit.jupiter.api.AfterEach,/org.mockito.Mock,/org.junit.jupiter.api.DisplayName,/org.mockito.InjectMocks,/org.junit.jupiter.api.BeforeEach,/org.junit.jupiter.params.provider.CsvSource,/org.junit.jupiter.params.ParameterizedTest,/org.mockito.junit.jupiter.MockitoSettings,/org.mockito.Spy
  1 error

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.
307 actionable tasks: 270 executed, 10 from cache, 27 up-to-date
  8 warnings
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':fineract-core:checkstyleMain'.
> 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/fineract-core/build/reports/checkstyle/main.html
     Checkstyle files with violations: 1
     Checkstyle violations by severity: [error:1]

Hi @adamsaghy, I fixed the errors. I changed the imports, removed the extra spaces, and cleaned up the commit history. Locally build is passing now. Thanks!

Ambika-Sony avatar Mar 24 '26 18:03 Ambika-Sony

* What went wrong:
Execution failed for task ':fineract-core: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/fineract-core/build/reports/checkstyle/test.html
     Checkstyle files with violations: 1
     Checkstyle violations by severity: [error:6]

adamsaghy avatar Apr 02 '26 14:04 adamsaghy

@Ambika-Sony please rebase

Aman-Mittal avatar Apr 02 '26 15:04 Aman-Mittal

@Ambika-Sony please rebase Hi @Aman-Mittal , I have rebased the branch on the latest develop, resolved all conflicts, and cleaned up the commit history. All checks should now pass. Kindly review.

Ambika-Sony avatar Apr 08 '26 06:04 Ambika-Sony

@Ambika-Sony

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':fineract-core: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/fineract-core/build/reports/checkstyle/test.html
     Checkstyle files with violations: 1
     Checkstyle violations by severity: [error:6]


BUILD FAILED in 9m 37s

adamsaghy avatar Apr 08 '26 07:04 adamsaghy

@Ambika-Sony

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':fineract-core: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/fineract-core/build/reports/checkstyle/test.html
     Checkstyle files with violations: 1
     Checkstyle violations by severity: [error:6]


BUILD FAILED in 9m 37s

Hi @adamsaghy, I have resolved the merge conflicts and fixed the Checkstyle violations in ApiParameterHelperTest.java. I also ran ./gradlew spotlessApply to ensure full compliance and local build is passing.Ready for re-review. Thanks!

Ambika-Sony avatar Apr 08 '26 18:04 Ambika-Sony

@Ambika-Sony Please fix the compilation error:


> Task :fineract-core:compileTestJava
/home/runner/work/fineract/fineract/fineract-core/src/test/java/org/apache/fineract/infrastructure/core/api/ApiParameterHelperTest.java:56: error: cannot find symbol
    assertThrows(NumberFormatException.class,()->{
    ^

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

Before any PR or changes, please always run these two commands and make sure there is green build!

adamsaghy avatar Apr 22 '26 09:04 adamsaghy

@Ambika-Sony Please fix the compilation error:


> Task :fineract-core:compileTestJava
/home/runner/work/fineract/fineract/fineract-core/src/test/java/org/apache/fineract/infrastructure/core/api/ApiParameterHelperTest.java:56: error: cannot find symbol
    assertThrows(NumberFormatException.class,()->{
    ^

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

Before any PR or changes, please always run these two commands and make sure there is green build!

Hi @adamsaghy — fixed the compilation error. assertThrows is now called via Assertions.assertThrows consistently with the rest of the test file. Ran both commands locally, build is green. Force pushed. Thank you!

Ambika-Sony avatar May 06 '26 03:05 Ambika-Sony

@Ambika-Sony moving to draft until you return!

P.S.: We hope your exams go as planned! ;)

adamsaghy avatar May 20 '26 14:05 adamsaghy

This pull request seems to be stale. Are you still planning to work on it? We will automatically close it in 30 days.

github-actions[bot] avatar Jun 20 '26 00:06 github-actions[bot]