Skip to content

[Unit Tests] Add coverage for ChainExpirationHandler, StateTypeWarningLog, and TemplateStageDefinition - #349

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

[Unit Tests] Add coverage for ChainExpirationHandler, StateTypeWarningLog, and TemplateStageDefinition#349
DiamondDagger590 wants to merge 1 commit into
recodefrom
claude/magical-cray-ard23h

Conversation

@DiamondDagger590

@DiamondDagger590 DiamondDagger590 commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • ChainExpirationHandlerTest (16 tests): Covers all four expiration behaviors (fail-chain, retry, restart-chain, skip), retry counter management, and retry key construction. Tests both offline and online player branches, including event firing for QuestChainFailEvent, QuestChainStepAdvanceEvent, and chain state transitions. Uses mock database manager pattern for async DB access paths.
  • StateTypeWarningLogTest (5 tests): Covers the warn-once deduplication behavior — first call logs, duplicate suppressed, different keys both log, throwable cause attached, and null cause produces no thrown on the log record.
  • TemplateStageDefinitionTest (11 tests): Covers the record's defensive copy in the canonical constructor, immutability of the returned list, backward-compatible single-arg constructor defaults, Optional wrapping of nullable condition and objectiveSelection fields, and the withObjectives() copy method preserving existing condition and selection config.

Total: 32 new tests across 3 test files.

Test plan

  • All 32 new tests pass individually
  • Full test suite passes (./gradlew test — 5109+ tests, 0 failures)
  • Testing audit persona (review-testing) run against changes — findings addressed (missing online-player branch coverage added, assertion method corrected)

Generated by Claude Code

Summary by CodeRabbit

  • Tests
    • Added coverage for warning-log suppression, independent warning keys, throwable handling, and null causes.
    • Added tests confirming quest template immutability, optional configuration handling, backward-compatible defaults, and objective replacement.
    • Added comprehensive expiration-flow coverage, including retries, restarts, skips, persistence, events, completion, and invalid-step handling.

…emplateStageDefinition

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

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Claude finished @DiamondDagger590's task in 1m 31s —— View job


Claude is reviewing this PR

  • Gather context (PR diff, changed files)
  • Route to review lenses (test-only PR — review-testing lens applies)
  • Fan out to lens subagent (running)
  • Consolidate findings
  • Post final review

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Team

Run ID: 96cf51da-537c-4c97-847a-ca227a5acdb1

📥 Commits

Reviewing files that changed from the base of the PR and between cc181c0 and 02a2e8f.

📒 Files selected for processing (3)
  • src/test/java/us/eunoians/mcrpg/combat/state/StateTypeWarningLogTest.java
  • src/test/java/us/eunoians/mcrpg/quest/board/template/TemplateStageDefinitionTest.java
  • src/test/java/us/eunoians/mcrpg/quest/chain/ChainExpirationHandlerTest.java

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Warning Log Tests

Layer / File(s) Summary
Warning log behavior
src/test/java/us/eunoians/mcrpg/combat/state/StateTypeWarningLogTest.java
Tests cover first-call warnings, duplicate suppression by key, independent keys, throwable attachment, and null causes.

Template Stage Definition Tests

Layer / File(s) Summary
Template stage contracts
src/test/java/us/eunoians/mcrpg/quest/board/template/TemplateStageDefinitionTest.java
Tests cover defensive copying, immutable objectives, constructor defaults, optional accessors, and withObjectives behavior.

Chain Expiration Handler Tests

Layer / File(s) Summary
Expiration outcomes and retry handling
src/test/java/us/eunoians/mcrpg/quest/chain/ChainExpirationHandlerTest.java
Tests cover setup, fail behavior, retry behavior, retry limits, unlimited retries, invalid steps, and quest-starter failures.
Chain restart and skip transitions
src/test/java/us/eunoians/mcrpg/quest/chain/ChainExpirationHandlerTest.java
Tests cover chain restart, step advancement, completion, persistence, events, and transition failures.
Retry counter scope and key identity
src/test/java/us/eunoians/mcrpg/quest/chain/ChainExpirationHandlerTest.java
Tests cover scoped counter cleanup and RetryKey equality and hash-code behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 02a2e

This change adds localized unit-test coverage without altering production behavior, dependencies, or deployment configuration; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 3 files. 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 concisely identifies the main change: adding unit-test coverage for ChainExpirationHandler, StateTypeWarningLog, and TemplateStageDefinition.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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-ard23h

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.

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