Skip to content

[Unit Tests] Add tests for quest chain events and LocaleSetting#307

Open
DiamondDagger590 wants to merge 1 commit into
recodefrom
claude/magical-cray-nformz
Open

[Unit Tests] Add tests for quest chain events and LocaleSetting#307
DiamondDagger590 wants to merge 1 commit into
recodefrom
claude/magical-cray-nformz

Conversation

@DiamondDagger590

@DiamondDagger590 DiamondDagger590 commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add unit tests for 5 previously untested quest chain event classes: QuestChainFailEvent, QuestChainExpireEvent, QuestChainRestartEvent, QuestChainStepRetryEvent, QuestChainAbandonEvent
  • Add unit tests for LocaleSetting enum (previously at 13% coverage with no direct test class)
  • ~37 test executions across 6 new test files

Classes Covered

Class Key coverage
QuestChainFailEvent Constructor getters, null player (offline), HandlerList
QuestChainExpireEvent Constructor getters, empty Optional when offline, cancellation toggle, HandlerList
QuestChainRestartEvent Constructor getters, null player, HandlerList, parameterized RestartReason enum
QuestChainStepRetryEvent Constructor getters (step, retryNumber, maxRetries), null player, unlimited retries (-1), HandlerList
QuestChainAbandonEvent Constructor getters, null player (offline), HandlerList
LocaleSetting fromString exact/case-insensitive/unknown/empty, parameterized enum matching, getSettingKey consistency, enum values/valueOf

Test plan

  • All 6 new test files pass individually
  • Full test suite passes with no regressions (only pre-existing failures in QuestRewardDistributionResolverPotBehaviorTest)
  • Testing audit persona applied — no concerns found

🤖 Generated with Claude Code

https://claude.ai/code/session_01G8PV45naRjtoHhr7ecZKVW


Generated by Claude Code

Summary by CodeRabbit

  • Tests
    • Added comprehensive automated coverage for quest chain abandonment, expiration, failure, restart, and step retry events.
    • Verified event data, offline-player handling, cancellation behavior, restart reasons, retry details, and handler registration.
    • Added coverage for locale setting parsing, case handling, valid values, and setting keys.

Cover 6 previously untested/undertested classes:
- QuestChainFailEvent (non-cancellable chain failure event)
- QuestChainExpireEvent (cancellable event with Optional<Player>)
- QuestChainRestartEvent (non-cancellable with RestartReason enum)
- QuestChainStepRetryEvent (retry tracking with step/retryNumber/maxRetries)
- QuestChainAbandonEvent (non-cancellable chain abandon event)
- LocaleSetting (enum fromString, getSettingKey, enum values)

~37 test executions covering constructor getters, null/offline player
paths, HandlerList conformance, cancellation toggle, and parameterized
enum coverage.

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

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds JUnit 5 coverage for quest-chain events and LocaleSetting, including getters, offline-player handling, cancellation, retry metadata, restart reasons, locale parsing, setting keys, and enum contracts.

Changes

Quest-chain event tests

Layer / File(s) Summary
Event getter contracts
src/test/java/us/eunoians/mcrpg/event/quest/chain/QuestChainAbandonEventTest.java, src/test/java/us/eunoians/mcrpg/event/quest/chain/QuestChainFailEventTest.java
Tests constructor values, offline-player behavior, chain definitions, and handler lists for abandon and fail events.
Expiration and restart event behavior
src/test/java/us/eunoians/mcrpg/event/quest/chain/QuestChainExpireEventTest.java, src/test/java/us/eunoians/mcrpg/event/quest/chain/QuestChainRestartEventTest.java
Tests expiration cancellation state, optional players, restart reasons, getters, and handler lists.
Step retry event contract
src/test/java/us/eunoians/mcrpg/event/quest/chain/QuestChainStepRetryEventTest.java
Tests retry event metadata, offline players, unlimited retries, initial retry values, and handler lists.

Locale setting tests

Layer / File(s) Summary
Locale parsing and enum contract
src/test/java/us/eunoians/mcrpg/setting/impl/LocaleSettingTest.java
Tests locale parsing, invalid inputs, setting-key consistency, enum ordering, and value lookup.

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

🚥 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 accurately summarizes the main change: new unit tests for quest chain events and LocaleSetting.
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/magical-cray-nformz

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.

@github-actions

Copy link
Copy Markdown

Extensibility Review

Breaking change risk: NONE — This diff contains only test classes; no production API surface is modified.

After reviewing all five new files in this diff, every changed file is located under src/test/java/ and exercises existing production classes (QuestChainAbandonEvent, QuestChainExpireEvent, QuestChainFailEvent, QuestChainRestartEvent, QuestChainStepRetryEvent, LocaleSetting) without altering any of them.

No extensibility concerns found.

The test code is, however, indirectly informative to addon developers in two ways worth noting (these are observations, not actionable concerns):

  1. QuestChainAbandonEvent.getPlayer() and QuestChainFailEvent.getPlayer() return a raw nullable Player (tests assert assertNull), while QuestChainExpireEvent.getPlayer() returns Optional<Player> (tests assert Optional.empty()). This inconsistency in the production API is visible through these tests but is not introduced by this diff — it pre-exists. Addon developers listening to these events must remember the different null-safety contracts per event type.

  2. The QuestChainStepRetryEvent test documents that getMaxRetries() returns -1 for unlimited retries as a sentinel value rather than an Optional<Integer>. Again, pre-existing, not introduced here.

No production interfaces, abstract classes, registries, NamespacedKey constants, or getDatabaseName() implementations are touched by this diff.

@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: 1

🤖 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/setting/impl/LocaleSettingTest.java`:
- Around line 8-19: Convert LocaleSettingTest from extending McRPGBaseTest to a
plain JUnit test by removing the McRPGBaseTest import and inheritance. Preserve
its existing test methods and assertions unchanged.
🪄 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: 7ff6b6cc-04ba-4feb-8388-4bab549c9f7b

📥 Commits

Reviewing files that changed from the base of the PR and between 6cd90a4 and bcc00cb.

📒 Files selected for processing (6)
  • src/test/java/us/eunoians/mcrpg/event/quest/chain/QuestChainAbandonEventTest.java
  • src/test/java/us/eunoians/mcrpg/event/quest/chain/QuestChainExpireEventTest.java
  • src/test/java/us/eunoians/mcrpg/event/quest/chain/QuestChainFailEventTest.java
  • src/test/java/us/eunoians/mcrpg/event/quest/chain/QuestChainRestartEventTest.java
  • src/test/java/us/eunoians/mcrpg/event/quest/chain/QuestChainStepRetryEventTest.java
  • src/test/java/us/eunoians/mcrpg/setting/impl/LocaleSettingTest.java

Comment on lines +8 to +19
import us.eunoians.mcrpg.McRPGBaseTest;

import java.util.Optional;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Tests for {@link LocaleSetting}.
*/
public class LocaleSettingTest 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.

📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Convert to a plain JUnit test.

This test class does not use MockBukkit server interaction or McRPGPlayer tracking. As per coding guidelines, a test that extends McRPGBaseTest but uses neither of these should be converted to a plain JUnit test.

♻️ Proposed refactor
-import us.eunoians.mcrpg.McRPGBaseTest;
-
 import java.util.Optional;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Tests for {`@link` LocaleSetting}.
  */
-public class LocaleSettingTest extends McRPGBaseTest {
+public class LocaleSettingTest {
📝 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
import us.eunoians.mcrpg.McRPGBaseTest;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for {@link LocaleSetting}.
*/
public class LocaleSettingTest extends McRPGBaseTest {
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for {`@link` LocaleSetting}.
*/
public class LocaleSettingTest {
🤖 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/setting/impl/LocaleSettingTest.java` around
lines 8 - 19, Convert LocaleSettingTest from extending McRPGBaseTest to a plain
JUnit test by removing the McRPGBaseTest import and inheritance. Preserve its
existing test methods and assertions unchanged.

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