[Tests] Add unit tests for database events, ManagerKey, and improve Pair/Parser coverage#52
Conversation
WalkthroughAdds new JUnit 5 test classes and methods across four modules: ChangesTest Coverage Expansion
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
Extensibility ReviewBreaking change risk: NONE — this diff contains only test code additions with no changes to production source files. No extensibility concerns found. All changes in this diff are confined to the |
Testing ReviewI'll systematically apply every checklist item to the diff. FindingsCONCERN: CONCERN: CONCERN: CONCERN: CONCERN: CONCERN: CONCERN: No tests cover the production-side logic of SummaryProduction files changed: Test files present:
Coverage gaps:
|
Security ReviewNo security concerns found. The diff contains exclusively test code ( |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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.
Inline comments:
In
`@src/test/java/com/diamonddagger590/mccore/event/database/DatabaseTableEventsTest.java`:
- Around line 100-111: The test in DatabaseTableEventsTest only checks that the
HandlerList values from PreTablesCreateEvent, TablesCreatedEvent,
PreTablesUpdateEvent, and TablesUpdatedEvent are non-null, but it does not
verify they are actually distinct. Update
allDatabaseEvents_handlerLists_areDistinctPerType to assert pairwise
non-identity between the handler lists returned by each getHandlerList() call so
the test fails if any event class shares the same static HandlerList instance.
In `@src/test/java/com/diamonddagger590/mccore/parser/ParserTest.java`:
- Around line 437-443: The new tests are too weak for their stated behavior: in
ParserTest, getInputString_returnsSanitizedInput_whenCalled should assert the
actual sanitized value returned by Parser.getInputString(), not just that it is
non-empty, and the caching-related test around the tree comparison should verify
Parser’s cache-specific behavior directly instead of only comparing evaluation
results. Tighten the assertions so they fail if sanitization or caching
regresses, using the existing Parser, getInputString, and tree-evaluation
helpers already present in this test file.
In
`@src/test/java/com/diamonddagger590/mccore/registry/manager/ManagerKeyTest.java`:
- Line 16: Rename the affected tests in ManagerKeyTest to follow the repository
convention methodUnderTest_expectedOutcome_whenCondition, since the current
names like command_managerClass_returnsCoreCommandManagerClass omit the required
_whenCondition suffix. Update each of the test method names referenced in the
diff so they clearly encode the condition, while keeping the method-under-test
and expected-outcome parts intact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0962c4dd-5c5c-405d-8066-512398cbdcb6
📒 Files selected for processing (4)
src/test/java/com/diamonddagger590/mccore/event/database/DatabaseTableEventsTest.javasrc/test/java/com/diamonddagger590/mccore/pair/PairTest.javasrc/test/java/com/diamonddagger590/mccore/parser/ParserTest.javasrc/test/java/com/diamonddagger590/mccore/registry/manager/ManagerKeyTest.java
…er coverage - Add DatabaseTableEventsTest covering PreTablesCreateEvent, TablesCreatedEvent, PreTablesUpdateEvent, TablesUpdatedEvent (0% → 100%) - Add ManagerKeyTest covering COMMAND, RELOADABLE_CONTENT, CHAT_RESPONSE constants (0% → 100%) - Improve PairTest with direct equals() calls for non-Pair objects and null handling in hashCode (94.1% → 100%) - Improve ParserTest with error path coverage for trailing tokens, unmatched parentheses, and missing function brackets (96.7% → 98.0%) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X2Mb9p5PuTL2bSW5RMWcWF
- DatabaseTableEventsTest: Add assertNotSame pairwise checks to verify each event type has its own distinct HandlerList instance - ParserTest: Strengthen getInputString test to assert exact sanitized value, and getTree caching test to use assertSame for identity check - ManagerKeyTest: Rename methods to follow methodUnderTest_expectedOutcome_whenCondition convention Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X2Mb9p5PuTL2bSW5RMWcWF
8196a21 to
8fee6f6
Compare
Extensibility ReviewBreaking change risk: NONE — this diff contains only new test classes and test method additions with no changes to production source code. No extensibility concerns found. All changes are confined to |
Testing ReviewI'll systematically apply every checklist item to the diff. AnalysisProduction files changedThe diff contains only test file additions/modifications — no production source files are changed. This means I must evaluate:
FindingsCONCERN: CONCERN: CONCERN: CONCERN: The CONCERN: CONCERN: CONCERN: CONCERN: CONCERN: None of the new test files place any shared fixtures in SummaryProduction files changed: None (diff contains only test additions) Test files present:
Coverage gaps:
|
Security ReviewNo security concerns found. The diff contains exclusively test code additions and modifications ( |
Summary
PreTablesCreateEvent,TablesCreatedEvent,PreTablesUpdateEvent,TablesUpdatedEvent) — tests construction,getHandlers(),getHandlerList(), verifies handler list sharing across instances, and asserts pairwise distinctness across event types. Coverage: 0% → 100%.ManagerKeyconstants (COMMAND,RELOADABLE_CONTENT,CHAT_RESPONSE), verifying each resolves to the correct manager class. Coverage: 0% → 100%.equals()calls for non-Pair objects and null to cover the!(obj instanceof Pair)branch, plus null-handling tests forhashCode(). Coverage: 94.1% → 100%.getInputStringto assert exact sanitized value andgetTreecaching to verify object identity. Coverage: 96.7% → 98.0%.Overall line coverage improved from 33.0% to 33.5% (1338 → 1360 lines covered out of 4055).
Test plan
./gradlew test)🤖 Generated with Claude Code
https://claude.ai/code/session_01X2Mb9p5PuTL2bSW5RMWcWF