FINERACT-2494: Add unit tests for ApiParameterHelper in fineract-core#5510
FINERACT-2494: Add unit tests for ApiParameterHelper in fineract-core#5510Ambika-Sony wants to merge 1 commit intoapache:developfrom
Conversation
d3a8f13 to
03c1a73
Compare
|
@Ambika-Sony Testing 1 method does not provide too much value. Would you consider to test the whole class? |
bbe7a08 to
eaf3dee
Compare
I've Implemented pagination (limit, offset), sorting (orderBy, sortOrder), and association helpers in ApiParameterHelper. Added 10 unit tests in ApiParameterHelperTest, covering standard scenarios, null/empty inputs, and defensive checks for whitespace handling. Verified the build locally with ./gradlew :fineract-core:test --tests ApiParameterHelperTest (all 10 passed). Looking forward to your feedback. |
c298bf2 to
5e18810
Compare
|
@adamsaghy I noticed the Cucumber E2E tests are failing in the CI, but since my changes are strictly limited to the ApiParameterHelper utility and its unit tests (2 files), these failures seem unrelated to my code. I saw your recent email about the E2E framework transition—perhaps these are known issues? |
1672c0e to
936cc1c
Compare
| @@ -0,0 +1,131 @@ | |||
| /** | |||
| *Licensed to the Apache Software Foundation (ASF) under one | |||
There was a problem hiding this comment.
Please fix the header it should be exactly same as from other files
936cc1c to
a18106e
Compare
a18106e to
07ff3ef
Compare
| String commaSeparatedParameters = queryParams.getFirst("associations"); | ||
|
|
||
| if (StringUtils.isNotBlank(commaSeparatedParameters)) { | ||
| String[] split = commaSeparatedParameters.split(","); |
There was a problem hiding this comment.
This will trigger errorProne String[] split = commaSeparatedParameters.split(","); fix this
| public static Integer extractLimitParameter(MultivaluedMap<String, String> queryParameters) { | ||
| Objects.requireNonNull(queryParameters, "queryParameters map cannot be null"); | ||
| String limit = queryParameters.getFirst("limit"); | ||
| return (StringUtils.isNotBlank(limit)) ? Integer.valueOf(limit.trim()) : null; |
There was a problem hiding this comment.
/home/runner/work/fineract/fineract/fineract-validation/src/main/java/org/apache/fineract/validation/constraints/EnumValueValidator.java:33: warning: [StringCaseLocaleUsage] Specify a Locale when calling String#to{Lower,Upper}Case. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)
acceptedValues = Arrays.stream(annotation.enumClass().getEnumConstants()).map(e -> e.name().toLowerCase())
^
(see https://errorprone.info/bugpattern/StringCaseLocaleUsage)
Did you mean 'acceptedValues = Arrays.stream(annotation.enumClass().getEnumConstants()).map(e -> e.name().toLowerCase(Locale.ROOT))' or 'acceptedValues = Arrays.stream(annotation.enumClass().getEnumConstants()).map(e -> e.name().toLowerCase(Locale.getDefault()))' or 'acceptedValues = Arrays.stream(annotation.enumClass().getEnumConstants()).map(e -> Ascii.toLowerCase(e.name()))'?
/home/runner/work/fineract/fineract/fineract-validation/src/main/java/org/apache/fineract/validation/constraints/EnumValueValidator.java:39: warning: [StringCaseLocaleUsage] Specify a Locale when calling String#to{Lower,Upper}Case. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)
return value != null && acceptedValues.contains(value.toLowerCase());
^
(see https://errorprone.info/bugpattern/StringCaseLocaleUsage)
Did you mean 'return value != null && acceptedValues.contains(value.toLowerCase(Locale.ROOT));' or 'return value != null && acceptedValues.contains(value.toLowerCase(Locale.getDefault()));' or 'return value != null && acceptedValues.contains(Ascii.toLowerCase(value));'?
3 warnings
Unable to resolve POM for org.eclipse.platform:org.eclipse.swt:3.124.100
|
|
||
| public static Integer extractOffsetParameter(MultivaluedMap<String, String> queryParameters) { | ||
| Objects.requireNonNull(queryParameters, "queryParameters map cannot be null"); | ||
| String offset = queryParameters.getFirst("offset"); |
There was a problem hiding this comment.
@Ambika-Sony try running ./gradlew compileJava for errorProne for more info.
Description
This PR adds unit test coverage for the ApiParameterHelper utility class in the fineract-core module.
Changes:
Added ApiParameterHelperTest.java to test core methods like extractFieldsForResponseIfProvided.
Verified code formatting using ./gradlew spotlessApply.
Testing:
Successfully ran locally using: ./gradlew :fineract-core:test --tests "org.apache.fineract.infrastructure.core.api.ApiParameterHelperTest"
All tests passed (100% success rate).
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.