Skip to content

[Tests] Add unit tests for CommandRegistrar, Gui.refreshGUI, improve CorePlayer/CoreBootstrap coverage - #86

Open
DiamondDagger590 wants to merge 1 commit into
developfrom
claude/eager-thompson-cjewpo
Open

[Tests] Add unit tests for CommandRegistrar, Gui.refreshGUI, improve CorePlayer/CoreBootstrap coverage#86
DiamondDagger590 wants to merge 1 commit into
developfrom
claude/eager-thompson-cjewpo

Conversation

@DiamondDagger590

@DiamondDagger590 DiamondDagger590 commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • New: CommandRegistrarTest — tests CommandRegistrar.register() using MockedConstruction to bypass PaperCommandManager runtime dependency. Verifies CoreCommandManager is created and registered in ManagerRegistry with the correct plugin argument.
  • New: GuiRefreshDefaultMethodTest — tests Gui.refreshGUI() default method, which delegates to paintInventory(). Uses a concrete TestGui with an AtomicInteger counter to verify delegation.
  • Improved: CoreBootstrapTest — added PROD-path test using MockedConstruction<CoreCommandManager> to properly cover the CommandRegistrar call without relying on exception-swallowing. Also improved assertion quality (assertEquals over assertTrue for size checks).
  • Improved: CorePlayerTest — added multi-hook isAfk tests (second hook returns true, all hooks return false) and fixed equals/hashCode branch coverage by adding direct player.equals() calls (the original assertNotEquals with reversed argument order never exercised CorePlayer.equals()).

Coverage improvements

Class Before After
CommandRegistrar 50% line 100% line
Gui.refreshGUI() 0% line 100% line
CorePlayer 83.3% branch, 96.7% line 100% branch, 100% line
CoreBootstrap 95.7% line 100% line

Test plan

  • All existing tests pass (./gradlew clean test — BUILD SUCCESSFUL)
  • Shadow jar builds successfully (./gradlew shadowJar)
  • New tests follow project naming convention (methodUnderTest_expectedOutcome_whenCondition)
  • All test methods have @DisplayName annotations
  • RegistryResetExtension used for singleton state management
  • No MockBukkit dependency needed — pure Mockito + JUnit 5
  • Testing audit persona reviewed and all concerns addressed

Generated by Claude Code

Summary by CodeRabbit

  • Tests
    • Added coverage for production startup and command manager registration.
    • Added tests for command registrar setup, teardown, and manager construction.
    • Verified GUI refresh behavior across repeated calls.
    • Expanded AFK status checks for multiple plugin hooks.
    • Improved equality validation for non-player and null values.

…ove CorePlayer/CoreBootstrap coverage

- Add CommandRegistrarTest: verify CoreCommandManager creation and registration
  using MockedConstruction to bypass PaperCommandManager runtime dependency
- Add GuiRefreshDefaultMethodTest: cover Gui.refreshGUI() default method (0% → 100%)
- CoreBootstrapTest: add PROD-path test with MockedConstruction for full line coverage
- CorePlayerTest: add multi-hook isAfk tests and fix equals/hashCode branch coverage
  by using direct player.equals() calls instead of reversed assertNotEquals

Coverage improvements:
- CommandRegistrar: 50% → 100% line
- Gui.refreshGUI: 0% → 100% line
- CorePlayer: 83.3% → 100% branch, 96.7% → 100% line
- CoreBootstrap: 95.7% → 100% line

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

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Claude finished @DiamondDagger590's task in 3m 11s —— View job


McCore PR Review

Verdict: No blocking issues found

This PR is test-only (224 additions, 0 deletions across 4 test files, no src/main/** changes), so only the testing lens applies per the routing rules in .github/claude-review-prompt.md.

  • review-testing: CLEAN — verified the new/modified tests against the production code they exercise (CommandRegistrar, Gui.refreshGUI(), CorePlayer.isAfk()/equals(), PluginHookRegistry, CoreBootstrap.start() PROD branch). MockedConstruction<CoreCommandManager> is used correctly to bypass the PaperCommandManager runtime dependency, RegistryResetExtension is used for singleton state, every test has a @DisplayName, and the second AfkPluginHook test subclass is needed because PluginHookRegistry keys hooks by class. No structural issues (no hand-rolled ExecutorService, no unnecessary MockBukkit usage).

No security/architecture/error-handling/performance/extensibility lenses were run since no src/main/**/*.java files or public API surfaces were touched.

  • Gather PR context (diff, changed files)
  • Route to review lenses — test-only PR, ran review-testing
  • Fan out to persona subagents
  • Consolidate findings
  • Post final review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds tests for command-manager registration during bootstrap, GUI refresh delegation, multiple AFK hooks, and direct CorePlayer.equals(...) results.

Changes

Test coverage expansion

Layer / File(s) Summary
Command registration coverage
src/test/java/com/diamonddagger590/mccore/bootstrap/registrar/CommandRegistrarTest.java, src/test/java/com/diamonddagger590/mccore/bootstrap/CoreBootstrapTest.java
Tests verify CoreCommandManager construction, constructor arguments, registry registration, and PROD bootstrap integration.
GUI refresh delegation coverage
src/test/java/com/diamonddagger590/mccore/gui/GuiRefreshDefaultMethodTest.java
Tests verify that repeated refreshGUI() calls invoke paintInventory() once per call.
CorePlayer behavior coverage
src/test/java/com/diamonddagger590/mccore/player/CorePlayerTest.java
Tests cover multiple AFK hooks and direct equality results for non-player and null values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 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 summarizes the added tests and expanded coverage described in the pull request.
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/eager-thompson-cjewpo

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/com/diamonddagger590/mccore/gui/GuiRefreshDefaultMethodTest.java-50-52 (1)

50-52: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the non-null annotation to the constructor parameter.

Line 50 dereferences paintCount in paintInventory(). Add @NotNull to document the required contract.

Proposed fix
-        TestGui(AtomicInteger paintCount) {
+        TestGui(`@NotNull` AtomicInteger paintCount) {

As per coding guidelines, “Use @NotNull annotation from IntelliJ v12 on all non-null return types and parameters.”

🤖 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/gui/GuiRefreshDefaultMethodTest.java`
around lines 50 - 52, Add the IntelliJ v12 `@NotNull` annotation to the paintCount
parameter of the TestGui constructor, preserving the existing constructor
behavior and imports.

Source: Coding guidelines

src/test/java/com/diamonddagger590/mccore/player/CorePlayerTest.java-57-70 (1)

57-70: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the required nullability annotation and Javadoc.

Line 66 accepts a non-null CorePlayer without @NotNull. Add the annotation and document the public override with @param and @return tags.

As per coding guidelines: Use @NotNull annotation from IntelliJ v12 on all non-null return types and parameters and Write Javadoc on all public methods with @PARAMand@return semantics.

Proposed fix
+    /**
+     * Checks whether this test hook reports the player as AFK.
+     *
+     * `@param` corePlayer the player to check
+     * `@return` the configured AFK result
+     */
     `@Override`
-    public boolean isAfk(CorePlayer corePlayer) {
+    public boolean isAfk(`@NotNull` CorePlayer corePlayer) {
🤖 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/player/CorePlayerTest.java` around
lines 57 - 70, Update SecondTestAfkPluginHook.isAfk(CorePlayer) to annotate its
non-null corePlayer parameter with the project’s IntelliJ v12 `@NotNull`
annotation, and add Javadoc for the public override including `@param` and `@return`
tags.

Source: Coding guidelines

src/test/java/com/diamonddagger590/mccore/player/CorePlayerTest.java-199-206 (1)

199-206: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Avoid the direct equals(null) call.

PMD reports EqualsNull at Line 206. Use Objects.equals(player, null) if branch coverage requires invoking CorePlayer.equals; otherwise remove the redundant direct assertion.

Proposed fix
+import java.util.Objects;
...
-        assertFalse(player.equals(null));
+        assertFalse(Objects.equals(player, null));
🤖 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/player/CorePlayerTest.java` around
lines 199 - 206, Remove the redundant direct player.equals(null) assertion in
equals_returnsFalse_whenComparedToNull, retaining the null-inequality assertion;
if direct CorePlayer.equals coverage is required, replace it with
Objects.equals(player, null) instead.

Source: Linters/SAST tools

🧹 Nitpick comments (1)
src/test/java/com/diamonddagger590/mccore/bootstrap/registrar/CommandRegistrarTest.java (1)

51-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Align the test method names with the repository convention.

Rename register_registersCoreCommandManager to include its condition, such as register_registersCoreCommandManager_whenBootstrapContextProvided.

Rename register_constructsCoreCommandManager_withContextPlugin to register_constructsCoreCommandManager_whenContextPluginProvided.

As per path instructions, test methods must use the methodUnderTest_expectedOutcome_whenCondition convention.

Also applies to: 67-67

🤖 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/bootstrap/registrar/CommandRegistrarTest.java`
at line 51, Rename the test methods to follow the repository convention: change
register_registersCoreCommandManager to
register_registersCoreCommandManager_whenBootstrapContextProvided, and
register_constructsCoreCommandManager_withContextPlugin to
register_constructsCoreCommandManager_whenContextPluginProvided. Do not alter
the test behavior.

Source: 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/gui/GuiRefreshDefaultMethodTest.java`:
- Around line 50-52: Add the IntelliJ v12 `@NotNull` annotation to the paintCount
parameter of the TestGui constructor, preserving the existing constructor
behavior and imports.

In `@src/test/java/com/diamonddagger590/mccore/player/CorePlayerTest.java`:
- Around line 57-70: Update SecondTestAfkPluginHook.isAfk(CorePlayer) to
annotate its non-null corePlayer parameter with the project’s IntelliJ v12
`@NotNull` annotation, and add Javadoc for the public override including `@param`
and `@return` tags.
- Around line 199-206: Remove the redundant direct player.equals(null) assertion
in equals_returnsFalse_whenComparedToNull, retaining the null-inequality
assertion; if direct CorePlayer.equals coverage is required, replace it with
Objects.equals(player, null) instead.

---

Nitpick comments:
In
`@src/test/java/com/diamonddagger590/mccore/bootstrap/registrar/CommandRegistrarTest.java`:
- Line 51: Rename the test methods to follow the repository convention: change
register_registersCoreCommandManager to
register_registersCoreCommandManager_whenBootstrapContextProvided, and
register_constructsCoreCommandManager_withContextPlugin to
register_constructsCoreCommandManager_whenContextPluginProvided. Do not alter
the test behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Pro Plus

Run ID: dbba0dbe-c4f1-4feb-88a6-95b2ed5b7824

📥 Commits

Reviewing files that changed from the base of the PR and between 0fbf220 and 2b158c8.

📒 Files selected for processing (4)
  • src/test/java/com/diamonddagger590/mccore/bootstrap/CoreBootstrapTest.java
  • src/test/java/com/diamonddagger590/mccore/bootstrap/registrar/CommandRegistrarTest.java
  • src/test/java/com/diamonddagger590/mccore/gui/GuiRefreshDefaultMethodTest.java
  • src/test/java/com/diamonddagger590/mccore/player/CorePlayerTest.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