[Tests] Improve edge-case coverage for FailSafeTransaction, NoLocalizationContainsMessageException, ReloadableTask - #92
Conversation
…ssageException, and ReloadableTask - FailSafeTransaction: test commit() failure triggers rollback, verify failureCause wraps original exception, confirm state remains COMMITTED when autocommit-reset fails in finally block - NoLocalizationContainsMessageException: test getMessage() with empty locale set (Optional.empty branch of reduce), test comma-separated formatting with multiple locales - ReloadableTask: test that runTask is called during construction, document that async flag defaults to false during construction due to super() calling reloadContent() before field assignment Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NHqScGEamnTLCWBP46meWG
|
Claude finished @DiamondDagger590's task in 2m 35s —— View job Reviewing PR #92Verdict: No blocking issues found This PR only adds new test methods to three existing test files (
|
📝 WalkthroughWalkthroughChangesTask Initialization
Fail-Safe Transactions
Localized Exception Messages
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
🟡 Other comments (1)
src/test/java/com/diamonddagger590/mccore/exception/localization/NoLocalizationContainsMessageExceptionTest.java-78-88 (1)
78-88: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAssert the comma separator explicitly.
The test name states that locale names are comma-separated, but the assertions only check that both names appear. An implementation that joins them with spaces would pass. Assert either locale order with a comma because
Set.of(...)does not guarantee iteration order.Proposed test assertion
String message = ex.getMessage(); assertNotNull(message); - assertTrue(message.contains(Locale.ENGLISH.getDisplayName())); - assertTrue(message.contains(Locale.FRENCH.getDisplayName())); + String english = Locale.ENGLISH.getDisplayName(); + String french = Locale.FRENCH.getDisplayName(); + assertTrue(message.contains(english + "," + french) + || message.contains(french + "," + english));🤖 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/com/diamonddagger590/mccore/exception/localization/NoLocalizationContainsMessageExceptionTest.java` around lines 78 - 88, Update getMessage_containsCommaSeparatedLocaleNames_whenConstructedWithMultipleLocales to assert that the two locale display names occur with a comma between them, accepting either order because Set.of does not guarantee iteration order.
🧹 Nitpick comments (1)
src/test/java/com/diamonddagger590/mccore/configuration/task/ReloadableTaskTest.java (1)
127-129: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAlign the new test identifiers with project conventions.
Rename
constructor_callsRunTaskOnInitialTaskto include its condition, for exampleconstructor_callsRunTaskOnInitialTask_whenFirstConstructed. Renamedocandrto descriptive callback parameters;ris a single-letter name outside a loop.As per coding guidelines, use meaningful variable names and avoid single-letter names except for loop counters. As per path instructions, test methods under
src/test/**/*.javausemethodUnderTest_expectedOutcome_whenCondition.Also applies to: 140-140
🤖 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/com/diamonddagger590/mccore/configuration/task/ReloadableTaskTest.java` around lines 127 - 129, Rename the test method constructor_callsRunTaskOnInitialTask to follow the methodUnderTest_expectedOutcome_whenCondition convention, such as constructor_callsRunTaskOnInitialTask_whenFirstConstructed. In the BiFunction callback, replace the abbreviated parameters doc and r with descriptive names that identify the YAML document and route.Sources: Coding guidelines, Path instructions
🤖 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/com/diamonddagger590/mccore/exception/localization/NoLocalizationContainsMessageExceptionTest.java`:
- Around line 78-88: Update
getMessage_containsCommaSeparatedLocaleNames_whenConstructedWithMultipleLocales
to assert that the two locale display names occur with a comma between them,
accepting either order because Set.of does not guarantee iteration order.
---
Nitpick comments:
In
`@src/test/java/com/diamonddagger590/mccore/configuration/task/ReloadableTaskTest.java`:
- Around line 127-129: Rename the test method
constructor_callsRunTaskOnInitialTask to follow the
methodUnderTest_expectedOutcome_whenCondition convention, such as
constructor_callsRunTaskOnInitialTask_whenFirstConstructed. In the BiFunction
callback, replace the abbreviated parameters doc and r with descriptive names
that identify the YAML document and route.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: QUIET
Plan: Pro Plus
Run ID: 5d98ee36-9f82-44a4-8587-a7c28f576a9c
📒 Files selected for processing (3)
src/test/java/com/diamonddagger590/mccore/configuration/task/ReloadableTaskTest.javasrc/test/java/com/diamonddagger590/mccore/database/transaction/FailSafeTransactionTest.javasrc/test/java/com/diamonddagger590/mccore/exception/localization/NoLocalizationContainsMessageExceptionTest.java
Summary
Test plan
./gradlew test— BUILD SUCCESSFUL)review-testing) run against changes — one dead variable flagged and fixedGenerated by Claude Code
Summary by CodeRabbit