sidshas03 opened a new pull request, #5038:
URL: https://github.com/apache/fineract/pull/5038

   **Summary**
   This PR completes the i18n work for **InterestRateChart** slab validation 
and gets CI to green. Hard-coded/concatenated messages are replaced with 
**message codes + arguments**, message bundles are updated, focused tests cover 
**overlap** and **gap** scenarios, and `spotless/checkstyle/spotbugs/tests` 
pass locally.
   **Supersedes #4793** (credit to the original author and discussion).
   
   **What changed (final approach adopted)**
   
   * **Domain stays Spring-free; standard validator pattern used**
   
     ```java
     // InterestRateChart.java
     DataValidatorBuilder v = new DataValidatorBuilder(errors)
         .resource("savings.interestRateChart")
         .parameter("slabs");
     v.failWithCode("overlap", slabContext, nextSlabContext);
     v.failWithCode("gap",     slabContext, nextSlabContext);
     ```
   
     Resolves to clean codes:
   
     * `validation.msg.savings.interestRateChart.slabs.overlap`
     * `validation.msg.savings.interestRateChart.slabs.gap`
   * **Message bundles** (added/updated in 
`fineract-provider/src/main/resources/messages.properties`)
   
     ```
     validation.msg.savings.interestRateChart.slabs.overlap=There is an overlap 
between slabs {0} and {1}.
     validation.msg.savings.interestRateChart.slabs.gap=There is a gap between 
slabs {0} and {1}.
     ```
   * **Tests**
     Added/updated unit tests to trigger overlap/gap and assert the **exact 
codes** (and arguments where exposed).
   * **CI**
     Ran `spotless`, `checkstyle`, `spotbugs`, and tests locally — all green.
   
   **Alternatives evaluated and not taken (with reasons)**
   
   * Injecting `MessageSource` / `LocaleContextHolder` into domain/assemblers — 
rejected to keep the domain layer clean; Fineract typically passes **codes + 
args** and resolves messages later.
   * Custom `InterestRateChartDataValidatorBuilder` subclass — rejected to 
avoid expanding API surface; standard builder suffices.
   * Using full i18n keys while the builder had `resource()/parameter()` set — 
led to double-prefixed codes (e.g., 
`validation.msg.interestRateChart.validation.msg.savings…`).
   * Using `failWithCodeNoParameterAddedToErrorCode` on a builder with context 
— could still introduce unwanted prefixes or `null` segments based on builder 
state.
   * Direct `ApiParameterError.parameterError(...)` — functional but bypasses 
the usual validator aggregation flow; reverted for consistency.
   
   **Scope (files of interest)**
   
   * `fineract-savings/src/main/java/.../InterestRateChart.java`
   * `fineract-provider/src/main/resources/messages.properties` (and optional 
locale bundles)
   * `fineract-savings/src/test/java/.../InterestRateChartValidationTest.java`
   
   **Compatibility / API notes**
   
   * No REST schema changes.
   * `globalisationMessageCode` for these validations now follows the standard 
`validation.msg.savings.interestRateChart.*` pattern.
   
   **How to verify**
   
   1. Build & checks:
   
      ```bash
      ./gradlew spotlessApply checkstyleMain checkstyleTest spotbugsMain 
spotbugsTest test
      ```
   2. Confirm no hard-coded “overlap/gap” texts remain in 
`InterestRateChart.java`.
   3. Run the updated tests; assertions should pass for the two codes above.
   
   **Housekeeping**
   
   * JIRA: defaults to **FINERACT-2316**; happy to switch to **FINERACT-2181** 
if that is the intended ticket.
   * Supersedes **#4793**; original author credited.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to