Skip to content

[Unit Tests] Add quest objective type tests for advancement, enchant, and loadout equip - #334

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

[Unit Tests] Add quest objective type tests for advancement, enchant, and loadout equip#334
DiamondDagger590 wants to merge 1 commit into
recodefrom
claude/magical-cray-2y35ri

Conversation

@DiamondDagger590

@DiamondDagger590 DiamondDagger590 commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • AdvancementCompleteObjectiveTypeTest: Added 5 describeObjective tests covering the ANY, SINGLE, and MULTI locale key branches with proper localization manager stubs and placeholder verification (e.g. extractDisplayName strips namespace and replaces underscores)
  • EnchantItemObjectiveTypeTest: Added 7 describeObjective tests for all filter combinations — any, single item, multi item, single enchantment, multi enchantment, single both, and multi both — with blanket localization manager stub
  • LoadoutEquipObjectiveTypeTest: Expanded from 5 to 15 tests covering Identity, CanProcess, ParseConfig (no filters, ability-type PASSIVE/ACTIVE, specific ability key, priority when both configured), and ProcessProgress (wrong context, unconfigured, type mismatch, key mismatch, INNATE type match). Registered AbilityRegistry in test setup to support ability lookup in processProgress
  • LoadoutEquipQuestContextTest: New test class with 4 tests covering getAbilityKey for EQUIP, SWAP, and UNEQUIP (throws NoSuchElementException) events, plus getPlayerUUID

Test plan

  • All 5100 tests pass with 0 failures and 0 errors
  • ./gradlew test completes successfully
  • JaCoCo coverage report generated
  • No regressions in existing tests

Generated by Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded automated coverage for localized advancement and enchantment objective descriptions.
    • Added validation for loadout equipment filtering, ability matching, context handling, and progress processing.
    • Added tests for loadout equip and swap event contexts, including invalid unequip scenarios.
    • Improved test organization and coverage of single- and multi-value objective configurations.

…equip

Expand test coverage for three quest objective types:

- AdvancementCompleteObjectiveTypeTest: add describeObjective tests
  covering ANY, SINGLE, and MULTI locale key branches with proper
  localization manager stubs and placeholder verification
- EnchantItemObjectiveTypeTest: add describeObjective tests for all
  seven filter combinations (any, single item, multi item, single
  enchantment, multi enchantment, single both, multi both)
- LoadoutEquipObjectiveTypeTest: expand from 5 to 15 tests covering
  identity, canProcess, parseConfig, and processProgress with proper
  AbilityRegistry setup for ability type/key filter matching
- LoadoutEquipQuestContextTest: new test class covering getAbilityKey
  for equip/swap/unequip events and getPlayerUUID

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

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

Claude finished @DiamondDagger590's task in 5m 10s —— View job


Review: 2 important, 3 nits

Test-only PR (no src/main/** changes), so the applicable lens is review-testing. The new AdvancementCompleteObjectiveTypeTest and LoadoutEquipQuestContextTest coverage is solid — real localization key/placeholder verification, correct describeObjective branch coverage, and good use of McRPGPlayerExtension. A couple of gaps are worth closing before merge, though.

Important findings:

  • EnchantItemObjectiveTypeTest.java:51-52 — The blanket lenient().when(localizationManager.getLocalizedMessage(any(McRPGPlayer.class), any(Route.class), anyMap())).thenReturn("localized text") stub means every DescribeObjective test (lines 313-415) gets the same return value no matter which LocalizationKey/placeholder map is actually passed. Those tests only assert assertNotNull/assertFalse(isEmpty())/contains("\n"), so a regression that swaps the wrong locale key or drops a placeholder in EnchantItemObjectiveType.describeObjective (src/main/java/.../EnchantItemObjectiveType.java:169-270, which branches into ANY/single-item/multi-item/single-enchantment/multi-enchantment/both) would still pass every test. The sibling AdvancementCompleteObjectiveTypeTest added in this same PR shows the stronger pattern already available: stub each key individually and verify() the exact key + placeholder map.

  • LoadoutEquipObjectiveTypeTest.java — Thorough parseConfig/processProgress/canProcess coverage was added, but there's no test for LoadoutEquipObjectiveType.describeObjective (src/main/java/.../LoadoutEquipObjectiveType.java:134-161), which branches over specific-ability resolution, a PASSIVE/ACTIVE/INNATE switch, a default fallthrough, and an ANY fallback — none of it exercised. Separately, processProgress calls AbilityRegistry.getRegisteredAbility(...), which throws AbilityNotRegisteredException for an unregistered key (src/main/java/us/eunoians/mcrpg/ability/AbilityRegistry.java:234-240); every test pre-registers the ability via mockAbilityRegistry(...), so this reachable failure path is untested.

Nits
  • AdvancementCompleteObjectiveTypeTest.java:32,35 — Static imports ArgumentMatchers.any and Mockito.lenient are added but never used anywhere in the file (verified via grep — no any(/lenient( calls exist). Remove them.
  • LoadoutEquipObjectiveTypeTest.java:77-85(ish, parseConfig_noFilters_createsEmptyFilter) — Only asserts assertNotNull(configured), which is tautological for a factory method that never returns null. Either drop it (already covered by processProgress_returnsOne_whenUnconfigured) or strengthen it to assert the EMPTY filter actually matches.
  • EnchantItemObjectiveTypeTest.java — Missing a class-level @DisplayName, unlike the two sibling classes touched in this PR (AdvancementCompleteObjectiveTypeTest, LoadoutEquipObjectiveTypeTest), which both got one.

Inline comments posted on the two Important findings above.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds localized description tests for advancement and enchantment objectives. It also expands loadout objective tests for configuration, context handling, ability filters, and progress, and adds context extraction tests.

Changes

Quest objective tests

Layer / File(s) Summary
Localized objective descriptions
src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/AdvancementCompleteObjectiveTypeTest.java, src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/EnchantItemObjectiveTypeTest.java
Test setup now initializes localization services. Tests cover empty, single-value, multi-value, combined, namespace, and formatting cases.
Loadout context behavior
src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/LoadoutEquipQuestContextTest.java
Tests verify ability-key and player-UUID extraction, including the exception for unequip events without a replacement ability.
Loadout objective filtering and progress
src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/LoadoutEquipObjectiveTypeTest.java
Tests cover identity, accepted context types, configuration parsing, ability-type and key filters, filter precedence, registry helpers, and progress results.

Estimated code review effort: 3 (Moderate) | ~20 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 unit tests for advancement, enchantment, and loadout equipment quest objectives.
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-2y35ri

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.

localizationManager = RegistryAccess.registryAccess()
.registry(RegistryKey.MANAGER)
.manager(McRPGManagerKey.LOCALIZATION);
lenient().when(localizationManager.getLocalizedMessage(any(McRPGPlayer.class), any(Route.class), anyMap()))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Important — testing: The blanket lenient().when(localizationManager.getLocalizedMessage(any(McRPGPlayer.class), any(Route.class), anyMap())).thenReturn("localized text") stub makes every describeObjective in this class indistinguishable — all 7 DescribeObjective tests below (lines 313-415) only assert assertNotNull/assertFalse(isEmpty())/contains("\n"), so a regression that swaps SINGLE_ITEM for SINGLE_ENCHANTMENT, drops a placeholder, or picks the wrong locale key would still pass every test.

EnchantItemObjectiveType.describeObjective (src/main/java/.../EnchantItemObjectiveType.java:169-270) branches into ANY / single-item / multi-item / single-enchantment / multi-enchantment / both — real logic worth locking down. The sibling AdvancementCompleteObjectiveTypeTest added in this same PR shows the stronger pattern: stub each LocalizationKey individually and verify() the exact key + placeholder map passed. Recommend applying that same pattern here instead of the blanket stub.

Fix this →


Ability passiveAbility = mock(Ability.class);
when(passiveAbility.getAbilityType()).thenReturn(AbilityType.PASSIVE);
NamespacedKey passiveKey = new NamespacedKey("mcrpg", "test_passive");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Important — testing: This PR adds thorough parseConfig/processProgress coverage but no test for LoadoutEquipObjectiveType.describeObjective (src/main/java/.../LoadoutEquipObjectiveType.java:134-161), which has real branching: specific-ability name resolution, a switch over PASSIVE/ACTIVE/INNATE each hitting a distinct LocalizationKey, a default warning-log fallthrough, and a final ANY fallback. None of it is exercised, so a regression swapping any of the four locale keys or breaking the fallthrough would go undetected. Both sibling objective types touched in this PR got dedicated describeObjective coverage — this one should too.

Also worth adding: processProgress for an ability key that isn't registered in AbilityRegistry currently throws AbilityNotRegisteredException (src/main/java/us/eunoians/mcrpg/ability/AbilityRegistry.java:234-240) — every existing test pre-registers the ability via mockAbilityRegistry(...), so this reachable failure path (e.g. a stale ability key from an event) has no test asserting the current behavior.

Fix this →

@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

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/us/eunoians/mcrpg/quest/objective/type/builtin/LoadoutEquipObjectiveTypeTest.java-77-180 (1)

77-180: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert parseConfig behavior for empty and malformed filters.

Line 84 only verifies that parseConfig returns an object. It does not verify that an empty configuration accepts a registered ability.

Add a progress assertion for the empty configuration. Add cases for an invalid "ability-type" and an invalid "ability" value. Assert that both configured objectives return zero progress for a registered ability.

As per coding guidelines, "Cover relevant edge cases, including ... malformed or missing configuration values."

🤖 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/quest/objective/type/builtin/LoadoutEquipObjectiveTypeTest.java`
around lines 77 - 180, Expand
LoadoutEquipObjectiveTypeTest.parseConfig_noFilters_createsEmptyFilter to
register an ability and assert processProgress returns one for the empty
configuration. Add tests covering invalid ability-type and invalid ability
values; register a matching ability/context and assert each configured objective
returns zero progress, using the existing mockAbilityRegistry and
mockContextWithAbility helpers.

Source: Coding guidelines

🤖 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/quest/objective/type/builtin/AdvancementCompleteObjectiveTypeTest.java`:
- Around line 265-287: Strengthen localization verification across the affected
tests: in
src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/AdvancementCompleteObjectiveTypeTest.java
lines 265-287, verify the multi header route and capture/assert all formatted
advancement placeholder maps; in
src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/EnchantItemObjectiveTypeTest.java
lines 51-52, remove the broad default localization response; and in lines
313-415, assert each expected localization route plus its count, item, and
enchantment placeholder map.

---

Other comments:
In
`@src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/LoadoutEquipObjectiveTypeTest.java`:
- Around line 77-180: Expand
LoadoutEquipObjectiveTypeTest.parseConfig_noFilters_createsEmptyFilter to
register an ability and assert processProgress returns one for the empty
configuration. Add tests covering invalid ability-type and invalid ability
values; register a matching ability/context and assert each configured objective
returns zero progress, using the existing mockAbilityRegistry and
mockContextWithAbility helpers.
🪄 Autofix

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: QUIET

Plan: Pro Plus

Run ID: 8e08531c-8809-49e1-a60a-3a056e2ec7cd

📥 Commits

Reviewing files that changed from the base of the PR and between cc181c0 and 528e051.

📒 Files selected for processing (4)
  • src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/AdvancementCompleteObjectiveTypeTest.java
  • src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/EnchantItemObjectiveTypeTest.java
  • src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/LoadoutEquipObjectiveTypeTest.java
  • src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/LoadoutEquipQuestContextTest.java

Comment on lines +265 to +287
@Test
@DisplayName("uses MULTI locale keys when multiple advancements configured")
void describeObjective_usesMultiKeys_whenMultipleAdvancements(McRPGPlayer player) {
Section section = mock(Section.class);
when(section.contains("advancements")).thenReturn(true);
when(section.getStringList("advancements")).thenReturn(List.of(
"minecraft:story/iron_tools",
"minecraft:nether/find_fortress"
));
AdvancementCompleteObjectiveType configured = type.parseConfig(section);

when(localizationManager.getLocalizedMessage(eq(player),
eq(LocalizationKey.QUEST_OBJECTIVE_ADVANCEMENT_COMPLETE_MULTI_HEADER), anyMap()))
.thenReturn("Complete 2 advancements");
when(localizationManager.getLocalizedMessage(eq(player),
eq(LocalizationKey.QUEST_OBJECTIVE_ADVANCEMENT_COMPLETE_MULTI_ITEM), anyMap()))
.thenReturn(" - advancement");

String description = configured.describeObjective(player, 2);
assertNotNull(description);
assertTrue(description.startsWith("Complete 2 advancements"));
assertTrue(description.contains("\n"));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Verify localization routes and placeholder maps, not only output shape. The new tests can pass when a description uses the wrong localization route or omits filter data.

  • src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/AdvancementCompleteObjectiveTypeTest.java#L265-L287: verify the multi header and capture all formatted advancement placeholders.
  • src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/EnchantItemObjectiveTypeTest.java#L51-L52: remove the broad default response for cases that need route-specific verification.
  • src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/EnchantItemObjectiveTypeTest.java#L313-L415: assert each expected route, count, item, and enchantment placeholder map.
📍 Affects 2 files
  • src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/AdvancementCompleteObjectiveTypeTest.java#L265-L287 (this comment)
  • src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/EnchantItemObjectiveTypeTest.java#L51-L52
  • src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/EnchantItemObjectiveTypeTest.java#L313-L415
🤖 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/quest/objective/type/builtin/AdvancementCompleteObjectiveTypeTest.java`
around lines 265 - 287, Strengthen localization verification across the affected
tests: in
src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/AdvancementCompleteObjectiveTypeTest.java
lines 265-287, verify the multi header route and capture/assert all formatted
advancement placeholder maps; in
src/test/java/us/eunoians/mcrpg/quest/objective/type/builtin/EnchantItemObjectiveTypeTest.java
lines 51-52, remove the broad default localization response; and in lines
313-415, assert each expected localization route plus its count, item, and
enchantment placeholder map.

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