Skip to content

Add unit tests for ArgumentParser and ColorChecker - #355

Merged
dmccoystephenson merged 2 commits into
mainfrom
feature/utils-unit-tests
Oct 2, 2026
Merged

dmccoystephenson merged 2 commits into
mainfrom
feature/utils-unit-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle: characterization tests are added for two utility classes that every chat and card command depends on but that had no tests.

  • ArgumentParserTest (8 tests) — createStringFromFirstArgOnwards (used by the /card setters, /bird, /me//emote) and createStringFromArgs (used by /whisper, /yell, /lo, /title). Joining with single spaces, start index at/past the end returning "", empty arguments kept rather than collapsed, and the ArrayIndexOutOfBoundsException on an empty array (every caller guards args.length first).
  • ColorCheckerTest (6 tests) — getColorByName, which resolves the color options documented in CONFIG.md. All 16 colors resolve from their all-lower-case and all-upper-case names; mixed-case (Red), unknown (pink, dark-red, "") and formatting-code names (bold) fall back to white; null throws NullPointerException.
  • CHANGELOG.md — one Added bullet under [Unreleased].

No production code is changed. The mixed-case fallback is recorded as current behavior, not endorsed; CONFIG.md lists only lower-case examples, so no doc drift was found.

Test plan

  • mvn test — 30 tests run (14 new), 0 failures, BUILD SUCCESS (local JDK 21)
  • CI Build workflow green on the PR head (JDK 8)

Deferred issues

No open issue was picked up this cycle; each was deferred for the reason given:

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

dmccoystephenson and others added 2 commits October 2, 2026 01:16
Characterization tests for how command arguments are joined back into
messages and how config color names resolve to ChatColor, including the
white fallback for mixed-case and unknown names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Matches PluginYmlContractTest; under a Turkish default locale
LIGHT_PURPLE would otherwise lower-case to a dotless-i spelling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (posted as a plain comment; it is not an independent review):

  • Scope: PASS — git diff --name-only origin/main lists only the two new test files and CHANGELOG.md. No production code was touched.
  • Tests-new: PASS (N/A) — no public methods were added. The 14 new tests cover the existing public ArgumentParser methods and ColorChecker.getColorByName.
  • Tests-fix: N/A — no bug fix is included. The tests characterize current behavior, so the stash-and-run FAIL→PASS check does not apply.
  • Sibling structure: PASS — JUnit 4 and org.junit.Assert static imports, mirroring src/main/java/dansplugins/rpsystem/utils, with a class-level Javadoc, as in PluginYmlContractTest and CardWildcardPermissionTest.
  • Sibling renames: N/A — nothing was renamed.
  • Docs: PASS — CHANGELOG.md gained an [Unreleased] → Added bullet. CONFIG.md lists only lower-case color examples, which match the tested behavior. No commands, permissions or config keys changed, so README.md, USER_GUIDE.md, COMMANDS.md and plugin.yml are unaffected.
  • Issue resolution: N/A — no Closes #N. This is a Stage B test-expansion cycle.
  • CI: PASS — Build run 36977884716 on head a813e83 ran on JDK 8: Tests run: 30, Failures: 0, Errors: 0, Skipped: 0, BUILD SUCCESS.
  • JDK 8 compatibility: PASS — the new files use only Java 8 APIs, confirmed by the JDK 8 CI compile.
  • Permissions: N/A — no permission nodes were added or changed.

Findings:

  • src/test/java/dansplugins/rpsystem/utils/ColorCheckerTest.java:25 — the first push called toLowerCase() without a locale. Under a Turkish default locale, LIGHT_PURPLE would lower-case with a dotless ı and the test would fail. This was fixed in a813e83 by pinning Locale.ENGLISH, which matches PluginYmlContractTest.
  • A judgment call, recorded but not changed: mixed-case color names such as Red silently resolve to white, and a null name throws NullPointerException. The tests record this behavior without endorsing it. ConfigService backfills every color option on enable, so null is not expected in practice. No bug issue was filed, because CONFIG.md does not promise case-insensitive matching.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit e43a6c4 into main Oct 2, 2026
1 check passed
@dmccoystephenson
dmccoystephenson deleted the feature/utils-unit-tests branch October 2, 2026 07:19
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.

1 participant