Skip to content

[Unit Tests] Board events, ContentPackRegisteredEvent, and FakeBlockBreakEvent coverage#246

Open
DiamondDagger590 wants to merge 1 commit into
recodefrom
claude/brave-goldberg-d1ag44
Open

[Unit Tests] Board events, ContentPackRegisteredEvent, and FakeBlockBreakEvent coverage#246
DiamondDagger590 wants to merge 1 commit into
recodefrom
claude/brave-goldberg-d1ag44

Conversation

@DiamondDagger590

@DiamondDagger590 DiamondDagger590 commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • BoardEventCoverageTest — 42 tests across 6 @Nested classes covering all board event DTOs (BoardOfferingAcceptEvent, BoardOfferingExpireEvent, BoardOfferingGenerateEvent, BoardRotationEvent, PersonalOfferingGenerateEvent, TemplateQuestGenerateEvent). Tests cover constructor storage, getter delegation, Cancellable contract, HandlerList identity, list mutability/immutability contracts, and defensive copy verification.
  • ContentPackRegisteredEventTest — 4 tests covering getContentPack(), getHandlers(), and getHandlerList() identity.
  • FakeBlockBreakEventTest — 4 tests covering hasPassedChecks default value, setPassedChecks toggle, revertibility, and BlockBreakEvent inheritance.

All three packages (event/board/, event/content/, event/fake/) were previously at 0-17% coverage.

Test plan

https://claude.ai/code/session_01B6qDw2LWgyf67eaqa6V4y2


Generated by Claude Code

Summary by CodeRabbit

  • Tests
    • Added comprehensive test suite for board offering and quest events, verifying event creation, cancellation behavior, and handler list management.
    • Added test coverage for content pack registration event initialization and handler retrieval.
    • Added test suite for fake block break event state management and inheritance verification.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Three new test files add comprehensive JUnit 5 coverage for event system components. BoardEventCoverageTest validates six board and quest event types; ContentPackRegisteredEventTest covers content pack event accessors; FakeBlockBreakEventTest verifies mutable state and Bukkit inheritance. All tests use mocks for setup and assert constructor injection, handler lists, and behavioral contracts.

Changes

Event System Test Coverage

Layer / File(s) Summary
Board and quest event coverage
src/test/java/us/eunoians/mcrpg/event/board/BoardEventCoverageTest.java
Setup with mocked QuestBoard and BoardRotation fixtures, followed by nested tests for BoardOfferingAcceptEvent, BoardOfferingExpireEvent, BoardOfferingGenerateEvent, BoardRotationEvent, PersonalOfferingGenerateEvent, and TemplateQuestGenerateEvent. Tests validate field getters, cancellation toggling, handler list identity, and mutable/immutable list semantics for offerings.
Content pack event test
src/test/java/us/eunoians/mcrpg/event/content/ContentPackRegisteredEventTest.java
Tests ContentPackRegisteredEvent constructor injection, content pack retrieval, and consistency between instance getHandlers() and static getHandlerList() accessors.
Fake block break event test
src/test/java/us/eunoians/mcrpg/event/fake/FakeBlockBreakEventTest.java
Tests FakeBlockBreakEvent initialization with mocked Bukkit Block and Player, default hasPassedChecks() state, setPassedChecks() toggling, and Bukkit BlockBreakEvent inheritance.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding unit tests for three event classes (Board events, ContentPackRegisteredEvent, and FakeBlockBreakEvent), which aligns perfectly with the changeset that adds 407 + 49 + 51 lines of test code across three test files.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/brave-goldberg-d1ag44

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 and usage tips.

@github-actions

Copy link
Copy Markdown

Extensibility Review

Breaking change risk: NONE — This diff adds only test classes with no changes to production API surface.

After reviewing all modified files, every change is confined to the src/test/java tree. No production source files, public interfaces, abstract classes, event classes, registry constants, NamespacedKey values, or getDatabaseName() implementations are touched.

No extensibility concerns found.

@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.

Actionable comments posted: 2

🤖 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/us/eunoians/mcrpg/event/content/ContentPackRegisteredEventTest.java`:
- Line 14: The test class ContentPackRegisteredEventTest should not extend
McRPGBaseTest; remove the "extends McRPGBaseTest" from the class declaration and
any unused imports brought in by that inheritance, and ensure no reliance on
inherited fixtures or setup (remove or replace any references to McRPGBaseTest
methods/fields in ContentPackRegisteredEventTest so it remains a plain unit test
of the event POJO).

In `@src/test/java/us/eunoians/mcrpg/event/fake/FakeBlockBreakEventTest.java`:
- Around line 20-21: In FakeBlockBreakEventTest replace the Mockito-created
Bukkit mocks with MockBukkit implementations: stop using mock(Block.class) and
mock(Player.class) and instead instantiate a BlockMock and PlayerMock (e.g., new
PlayerMock(...) and new BlockMock(...) or obtain them from the MockBukkit
server/arena setup used in your tests) so Bukkit behavior is simulated
correctly; update imports to use be.seeseemelk.mockbukkit.* (or the project's
MockBukkit package) and adjust any stubbing/assertions that relied on
Mockito-specific behavior to use the MockBukkit API (for example methods on
PlayerMock and BlockMock) so the test runs under MockBukkit lifecycle.
🪄 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: fd572b9c-bdd5-4f78-b595-79e375344b3e

📥 Commits

Reviewing files that changed from the base of the PR and between 9b47c9a and 8cec1d8.

📒 Files selected for processing (3)
  • src/test/java/us/eunoians/mcrpg/event/board/BoardEventCoverageTest.java
  • src/test/java/us/eunoians/mcrpg/event/content/ContentPackRegisteredEventTest.java
  • src/test/java/us/eunoians/mcrpg/event/fake/FakeBlockBreakEventTest.java

import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.mock;

class ContentPackRegisteredEventTest extends McRPGBaseTest {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Remove McRPGBaseTest extension for faster test execution.

This test doesn't require Bukkit server interaction or McRPGPlayer infrastructure—it only validates a simple event POJO. Extending McRPGBaseTest adds unnecessary bootstrap overhead (server mock, plugin initialization). As per coding guidelines, McRPGBaseTest is required only for tests that need those facilities.

⚡ Proposed fix to remove the extension
-class ContentPackRegisteredEventTest extends McRPGBaseTest {
+class ContentPackRegisteredEventTest {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
class ContentPackRegisteredEventTest extends McRPGBaseTest {
class ContentPackRegisteredEventTest {
🤖 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/event/content/ContentPackRegisteredEventTest.java`
at line 14, The test class ContentPackRegisteredEventTest should not extend
McRPGBaseTest; remove the "extends McRPGBaseTest" from the class declaration and
any unused imports brought in by that inheritance, and ensure no reliance on
inherited fixtures or setup (remove or replace any references to McRPGBaseTest
methods/fields in ContentPackRegisteredEventTest so it remains a plain unit test
of the event POJO).

Comment on lines +20 to +21
Block mockBlock = mock(Block.class);
Player mockPlayer = mock(Player.class);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Prefer MockBukkit implementations over Mockito mocks for Bukkit classes.

Use PlayerMock and BlockMock from MockBukkit instead of Mockito mock() for better Bukkit behavior simulation and alignment with project test conventions.

♻️ Proposed refactor
+import be.seeseemelk.mockbukkit.block.BlockMock;
+import be.seeseemelk.mockbukkit.entity.PlayerMock;
+
 import org.bukkit.block.Block;
 import org.bukkit.entity.Player;
 import org.junit.jupiter.api.BeforeEach;
     `@BeforeEach`
     void setUp() {
-        Block mockBlock = mock(Block.class);
-        Player mockPlayer = mock(Player.class);
+        Block mockBlock = new BlockMock(org.bukkit.Material.STONE);
+        Player mockPlayer = new PlayerMock(server, "testPlayer");
         event = new FakeBlockBreakEvent(mockBlock, mockPlayer);
     }
🤖 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/event/fake/FakeBlockBreakEventTest.java`
around lines 20 - 21, In FakeBlockBreakEventTest replace the Mockito-created
Bukkit mocks with MockBukkit implementations: stop using mock(Block.class) and
mock(Player.class) and instead instantiate a BlockMock and PlayerMock (e.g., new
PlayerMock(...) and new BlockMock(...) or obtain them from the MockBukkit
server/arena setup used in your tests) so Bukkit behavior is simulated
correctly; update imports to use be.seeseemelk.mockbukkit.* (or the project's
MockBukkit package) and adjust any stubbing/assertions that relied on
Mockito-specific behavior to use the MockBukkit API (for example methods on
PlayerMock and BlockMock) so the test runs under MockBukkit lifecycle.

Source: Coding guidelines

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