[Tests] Improve branch coverage for OperatorNode, FunctionNode, PaginatedGui, TableVersionHistoryDAO - #87
Conversation
… TableVersionHistoryDAO Add targeted tests to reach 100% branch coverage on four classes not covered by existing open PRs: - OperatorNode: cover default switch paths in getValue() and needBrackets() using an unsupported operator character - FunctionNode: cover default switch path in getValue() using an out-of-range function index - PaginatedGui: cover the Preconditions branch in setPage() when getMaximumPage() < 1 - TableVersionHistoryDAO: cover the false branch of the version-0 check in updateTable() using a negative stored version Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018GHx1mkRzHLV6Gox72jXvX
📝 WalkthroughWalkthroughThe test suite adds regression coverage for invalid table versions, invalid pagination bounds, out-of-range function indexes, and unsupported operators. ChangesEdge-case regression tests
Estimated code review effort: 2 (Simple) | ~10 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 |
|
Claude finished @DiamondDagger590's task in 1m 46s —— View job Claude PR Review — in progress
|
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/database/table/impl/TableVersionHistoryDAOTest.java-226-229 (1)
226-229: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winVerify that the history query executes.
The test stubs
executeQuery()but does not verify that it was called. Add this assertion so the test proves that-1was read from the history table beforeupdateTableskips the update.Suggested assertion
verify(mockStatement).setString(1, "table_history"); + verify(mockStatement).executeQuery(); verify(mockStatement, never()).executeUpdate();Also applies to: 231-234
🤖 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/database/table/impl/TableVersionHistoryDAOTest.java` around lines 226 - 229, Update the test around the mocked history query in TableVersionHistoryDAOTest to verify that mockStatement.executeQuery() is invoked before updateTable skips the update. Keep the existing result-set stubbing and -1 table_version assertion setup unchanged.
🤖 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/database/table/impl/TableVersionHistoryDAOTest.java`:
- Around line 226-229: Update the test around the mocked history query in
TableVersionHistoryDAOTest to verify that mockStatement.executeQuery() is
invoked before updateTable skips the update. Keep the existing result-set
stubbing and -1 table_version assertion setup unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: QUIET
Plan: Pro Plus
Run ID: 37fe57a6-0bbc-40b7-9715-56fc9fadc7f5
📒 Files selected for processing (4)
src/test/java/com/diamonddagger590/mccore/database/table/impl/TableVersionHistoryDAOTest.javasrc/test/java/com/diamonddagger590/mccore/gui/PaginatedGuiTest.javasrc/test/java/com/diamonddagger590/mccore/parser/FunctionNodeTest.javasrc/test/java/com/diamonddagger590/mccore/parser/OperatorNodeTest.java

Summary
getValue()andneedBrackets()using an unsupported operator character ('!'). Branch coverage: 95.7% → 100%getValue()using an out-of-range function index (FUNCTIONS.length). Branch coverage: 97.6% → 100%setPage()whengetMaximumPage() < 1to cover the firstPreconditions.checkArgumentbranch. Branch coverage: 90% → 100%updateTable()when the stored version is negative, covering the false branch of thelatestStoredVersion == 0check. Branch coverage: 87.5% → 100%All four classes now have 100% branch coverage. Overall project branch coverage improved from 70.7% to 71.0%.
Test plan
./gradlew test)Generated by Claude Code
Summary by CodeRabbit