Skip to content

Improve test readability in AsHumanReadableTextTest.java with switch-based locale handling#295

Merged
jy95 merged 2 commits intomainfrom
jy95-patch-1
Jan 6, 2026
Merged

Improve test readability in AsHumanReadableTextTest.java with switch-based locale handling#295
jy95 merged 2 commits intomainfrom
jy95-patch-1

Conversation

@jy95
Copy link
Owner

@jy95 jy95 commented Jan 6, 2026

Summary by CodeRabbit

  • Tests
    • Improved test readability and maintainability via formatting and minor control-flow refinements.
    • Centralized locale-based expected-text selection for clearer localization handling; default remains English.
    • Removed redundant inline comments and simplified assertions; no changes to public behavior or test outcomes.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

📝 Walkthrough

Walkthrough

Refactors R4 and R5 test files: collapses builder constructions, removes spacer comments in helper dosage methods, and replaces locale-specific if/else chains in getExpectedText(Locale) with a locale.toLanguageTag() switch including a default case; no public API signatures changed.

Changes

Cohort / File(s) Summary
R4 Test Refactor
r4/src/test/java/io/github/jy95/fds/r4/methods/AsHumanReadableTextTest.java
Collapsed FDSConfigR4.builder() calls to single-line form; removed spacer comments before getFirstDosage(), getSecondDosage(), getThirdDosage(); replaced locale if/else chain with locale.toLanguageTag() switch and default; minor newline/formatting tweaks.
R5 Test Refactor
r5/src/test/java/io/github/jy95/fds/r5/methods/AsHumanReadableTextTest.java
Collapsed FDSConfigR5.builder() formatting; simplified assertions to compare expected text directly; removed redundant inline comments in helper methods; replaced locale if/else chain with locale.toLanguageTag() switch including explicit cases (fr, de, es, it, nl-BE) and default English mapping.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 Hops of tidy code I bring,
Switches sing where branches swing,
Builders shortened, comments gone,
Tests still pass from dusk to dawn.
A rabbit cheers: neat changes, spring!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title is overly vague and generic, using 'Update' without specifying what was actually changed in the test files. Use a more descriptive title that captures the main change, such as 'Refactor AsHumanReadableTextTest locale mapping logic' or 'Convert locale-specific if-else to switch statement in AsHumanReadableTextTest'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbb07e5 and 36dcf0a.

📒 Files selected for processing (1)
  • r5/src/test/java/io/github/jy95/fds/r5/methods/AsHumanReadableTextTest.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (3)
r5/src/test/java/io/github/jy95/fds/r5/methods/AsHumanReadableTextTest.java (3)

31-33: LGTM - Clean formatting improvement.

The collapsed builder invocation improves readability without changing behavior.


46-48: LGTM - Consistent formatting with testOneItem.

Same formatting improvement applied consistently across test methods.


55-55: LGTM - Good extraction of expected text logic.

Centralizing the expected text in a helper method improves maintainability and follows DRY principles.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codacy-production
Copy link

codacy-production bot commented Jan 6, 2026

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (a427992) 1582 1582 100.00%
Head commit (36dcf0a) 3164 (+1582) 3164 (+1582) 100.00% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#295) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@jy95 jy95 changed the title Update AsHumanReadableTextTest.java Improve test readability in AsHumanReadableTextTest.java with switch-based locale handling Jan 6, 2026
@jy95 jy95 merged commit e3550c0 into main Jan 6, 2026
20 checks passed
@jy95 jy95 deleted the jy95-patch-1 branch January 6, 2026 17:40
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.

1 participant