Skip to content

[Unit Tests] Add McRPGLocalizationManager locale chain, date formatting, and utility tests - #332

Open
DiamondDagger590 wants to merge 2 commits into
recodefrom
claude/magical-cray-01fkil
Open

[Unit Tests] Add McRPGLocalizationManager locale chain, date formatting, and utility tests#332
DiamondDagger590 wants to merge 2 commits into
recodefrom
claude/magical-cray-01fkil

Conversation

@DiamondDagger590

@DiamondDagger590 DiamondDagger590 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Expand McRPGLocalizationManagerTest from 20 to 35 tests (15 new tests across 5 nested classes)
  • Cover getLocaleChain() for all 3 LocaleSetting paths: CLIENT_LOCALE, SERVER_LOCALE, and SpecificLocaleSetting, each with and without a Bukkit player available (7 tests)
  • Cover getServerDefaultLocale(), getRegisteredLocales() (empty/multiple/defensive-copy), formatDisplayDate() (English + German locale-aware formatting), and getPaletteReplacements() (content + size)
  • Fix misleading Javadoc on test palette map that incorrectly claimed to mirror config.yml defaults

Test plan

  • Full test suite passes via ./gradlew verifiedShadowJar (clean + test + build)
  • All 35 tests in McRPGLocalizationManagerTest pass
  • No regressions in any other test classes
  • Testing audit persona reviewed changes — only NIT-level findings (reflection fragility inherent to the CALLS_REAL_METHODS mock approach, and an untested addPaletteEntry fallback branch that is unreachable via the current test setup pattern)

https://claude.ai/code/session_015UdHRdCMsutDyGRaqUcTKu


Generated by Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded localization test coverage for locale fallback chains and server-default locale retrieval.
    • Added tests for registered locales, date formatting, and palette-based text replacements.
    • Updated palette test documentation with representative values.

claude added 2 commits August 7, 2026 09:27
…ationManager

Expand McRPGLocalizationManagerTest from 20 to 35 tests covering:
- getLocaleChain: all 3 LocaleSetting paths (CLIENT_LOCALE, SERVER_LOCALE,
  SpecificLocaleSetting) with and without Bukkit player available (7 tests)
- getServerDefaultLocale: locale chain head retrieval (1 test)
- getRegisteredLocales: empty, multiple locales, and defensive copy (3 tests)
- formatDisplayDate: English and German locale-aware date formatting (2 tests)
- getPaletteReplacements: map content and size verification (2 tests)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015UdHRdCMsutDyGRaqUcTKu
The comment claimed the test map mirrored config.yml defaults, but it is
a representative subset used to exercise the replacement mechanism.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015UdHRdCMsutDyGRaqUcTKu
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Claude finished @DiamondDagger590's task in 4m 37s —— View job


Review complete — 0 important, 2 nits

Summary: This PR is a test-only change (no src/main files touched), expanding McRPGLocalizationManagerTest with 15 new tests across 5 @Nested classes covering getLocaleChain(), getServerDefaultLocale(), getRegisteredLocales(), formatDisplayDate(), and getPaletteReplacements(). Since no production code changed, only the review-testing lens applies (all other lenses key on src/main/** or resource paths per the routing table). No blocking issues found.

Nits (2)
  • McRPGLocalizationManagerTest.java:454,480formatDisplayDate_englishLocale_formatsInEnglish/formatDisplayDate_germanLocale_formatsInGerman assert exact literal CLDR-produced strings ("Jan 15, 2025", "15.01.2025"). JDK CLDR data has shifted formatting details across releases before. The sibling McRPGDisplayDecimalFormatterTest already avoids this by asserting structural properties (e.g. result.contains(",")) instead of full literals — worth following that established, less brittle convention here. Fix this →
  • McRPGLocalizationManagerTest.java:500getPaletteReplacements_hasOpenAndCloseTags hardcodes the expected map size as the literal 20 instead of deriving it from DEFAULT_PALETTE.size(). If DEFAULT_PALETTE gains/loses a role later, this magic number silently drifts out of sync with its source of truth. Fix this →

Both align with the NIT-level findings the PR description already self-reported (reflection fragility, untested fallback branch) — no new IMPORTANT issues found.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The localization manager test suite now covers locale-chain construction, server defaults, registered locales, locale-specific date formatting, and palette replacement mappings.

Changes

Localization manager test coverage

Layer / File(s) Summary
Locale selection and defaults
src/test/java/us/eunoians/mcrpg/localization/McRPGLocalizationManagerTest.java
Added tests for client, server, specific-locale, fallback, and server-default locale behavior.
Locale access and date formatting
src/test/java/us/eunoians/mcrpg/localization/McRPGLocalizationManagerTest.java
Added tests for registered locale results, defensive set copies, and English and German MEDIUM date formatting.
Palette replacement mappings
src/test/java/us/eunoians/mcrpg/localization/McRPGLocalizationManagerTest.java
Added tests for opening and closing tag mappings across all ten palette roles. Updated the palette fixture documentation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • DiamondDagger590/McRPG#321: Covers overlapping localization manager tests for locale chains, date formatting, server defaults, registered locales, and palette entries.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the added unit tests for locale chains, date formatting, and localization utilities.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/magical-cray-01fkil

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

🟡 Other comments (3)
src/test/java/us/eunoians/mcrpg/localization/McRPGLocalizationManagerTest.java-414-426 (1)

414-426: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Test defensive behavior, not only object identity.

assertNotSame passes if the method returns a new mutable set. It does not verify that later changes to localizationsMap cannot affect result, or that callers cannot mutate result.

Modify localizationsMap after the call and assert that result remains unchanged. Also assert that result.add(...) throws UnsupportedOperationException.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/us/eunoians/mcrpg/localization/McRPGLocalizationManagerTest.java`
around lines 414 - 426, Strengthen
getRegisteredLocales_returnedSetIsDefensiveCopy by verifying behavior rather
than only identity: mutate localizationsMap after obtaining result and assert
result is unchanged, then assert that attempting result.add(...) throws
UnsupportedOperationException.
src/test/java/us/eunoians/mcrpg/localization/McRPGLocalizationManagerTest.java-496-501 (1)

496-501: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert both mappings for every named palette role.

A size of 20 does not prove that all ten required roles have opening and closing mappings. A missing role plus an unrelated mapping still passes this test.

Assert the presence of <role> and </role> for each expected palette role.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/us/eunoians/mcrpg/localization/McRPGLocalizationManagerTest.java`
around lines 496 - 501, Update getPaletteReplacements_hasOpenAndCloseTags to
verify both opening and closing tag mappings for each of the ten expected
palette roles, rather than relying only on the total size assertion. Retain the
existing configured-palette setup and assert presence of every corresponding
<role> and </role> key.
src/test/java/us/eunoians/mcrpg/localization/McRPGLocalizationManagerTest.java-249-254 (1)

249-254: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert that each expected locale chain terminates at English.

These tests do not assert that the final Locale.ENGLISH node has no successor. A chain with an unintended extra fallback locale passes these assertions.

Add assertFalse(...hasNext()) for the final English node in each complete-chain test.

Also applies to: 262-266, 279-283, 296-300, 327-331, 346-352

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/us/eunoians/mcrpg/localization/McRPGLocalizationManagerTest.java`
around lines 249 - 254, Update each complete locale-chain test in
McRPGLocalizationManagerTest, including the cases around the German-to-English
assertions and the listed additional chains, to assert that the final
Locale.ENGLISH node’s hasNext() returns false. Keep the existing locale-order
assertions unchanged and apply the termination assertion to every expected
English endpoint.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Other comments:
In
`@src/test/java/us/eunoians/mcrpg/localization/McRPGLocalizationManagerTest.java`:
- Around line 414-426: Strengthen
getRegisteredLocales_returnedSetIsDefensiveCopy by verifying behavior rather
than only identity: mutate localizationsMap after obtaining result and assert
result is unchanged, then assert that attempting result.add(...) throws
UnsupportedOperationException.
- Around line 496-501: Update getPaletteReplacements_hasOpenAndCloseTags to
verify both opening and closing tag mappings for each of the ten expected
palette roles, rather than relying only on the total size assertion. Retain the
existing configured-palette setup and assert presence of every corresponding
<role> and </role> key.
- Around line 249-254: Update each complete locale-chain test in
McRPGLocalizationManagerTest, including the cases around the German-to-English
assertions and the listed additional chains, to assert that the final
Locale.ENGLISH node’s hasNext() returns false. Keep the existing locale-order
assertions unchanged and apply the termination assertion to every expected
English endpoint.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Pro Plus

Run ID: 8f2c2dec-277b-4415-8b92-fd23deb83f7e

📥 Commits

Reviewing files that changed from the base of the PR and between cc181c0 and b1961d0.

📒 Files selected for processing (1)
  • src/test/java/us/eunoians/mcrpg/localization/McRPGLocalizationManagerTest.java

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.

2 participants