Skip to content

test: add direct unit test for ProjectService - #54

Merged
dmccoystephenson merged 1 commit into
mainfrom
feat/project-service-unit-test
Sep 27, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feat/project-service-unit-test

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • ProjectServiceTest is added as a direct Mockito unit test for ProjectService, which previously had no test class of its own and was only exercised indirectly through the command tests. This continues the per-layer coverage started for ProjectRepository in test: add direct unit test for ProjectRepository #53.
  • The following behavior of ProjectService is pinned:
    • createProject maps every argument onto the built Project. Distinct score values 1–5 are used, so a transposed argument would be caught. The same instance is passed to ProjectRepository.add and returned.
    • usageReporter.projectCreated() is called only after add succeeds (verified with InOrder). It is not called when add throws NameTakenException, which is propagated to the caller.
    • getProjects, getProject and deleteProject delegate to the repository. ProjectNotFoundException is propagated unchanged, and deleting a project reports no usage.
    • isNameTaken returns true when the lookup succeeds and false when it throws ProjectNotFoundException.
  • These are characterization tests. No production code was changed.

No tracking issue: the gap was found during triage (Stage B, unit-test expansion). No bug was found while the tests were being written.

Test plan

  • ./gradlew test on JDK 21 ran 124 tests with 0 failures, 0 errors and 0 skipped (counted from build/test-results/test/*.xml). 10 of them are the new ProjectServiceTest tests.
  • CI (Build and Test, CI Pipeline) is green on the PR head.

Deferred issues

These open issues were left out of this cycle:

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

ProjectService had no test class of its own; it was only exercised
indirectly through command tests. Pin its delegation to
ProjectRepository, field mapping in createProject, and the rule that
usage is reported only after a project is successfully added.

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

Copy link
Copy Markdown

Test Results

124 tests  +10   124 ✅ +10   2s ⏱️ -1s
 19 suites + 1     0 💤 ± 0 
 19 files   + 1     0 ❌ ± 0 

Results for commit 2e81d28. ± Comparison against base commit 5f56cb8.

@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric for PR #54:

  • Scope: PASS. gh pr diff 54 shows one added file, src/test/java/com/preponderous/parpt/service/ProjectServiceTest.java. No production code, docs or build files are touched.
  • Tests-new: PASS (N/A). No new public methods were added. Every existing public method of ProjectService (createProject, getProjects, getProject, deleteProject, isNameTaken) now has at least one direct test.
  • Tests-fix: N/A. This is a characterization cycle with no bug fix, so the stash-and-run check had nothing to revert.
  • Sibling structure: PASS. The file mirrors repo/ProjectRepositoryTest from test: add direct unit test for ProjectRepository #53: @ExtendWith(MockitoExtension.class), @Mock collaborators, a @BeforeEach constructor wiring, AssertJ assertions and methodName_ShouldExpectedBehavior names. It sits in service/, matching the class under test.
  • Sibling renames: N/A. Nothing was renamed.
  • Docs: PASS. The README feature list and Roadmap, and CONTRIBUTING.md's ./gradlew test instruction, are unaffected by a test-only change.
  • Issue resolution: N/A. No Closes reference; the gap was found during triage.
  • Manual validation: PASS. Locally, ./gradlew test on JDK 21 ran 124 tests with 0 failures (10 new). On the PR head, CI build (21), test and Test Results all pass.
  • Shell command tests / round-trip coverage / I/O behind an interface: N/A. No @ShellComponent, Project field or I/O code was changed.

Findings:

  • src/test/java/com/preponderous/parpt/service/ProjectServiceTest.java:111: deleteProject_WithUnknownName_ShouldPropagateNotFound asserts only the exception type. The getProject sibling also asserts the message. This is low value because the service passes the repository's exception through unchanged, so it was left as is.
  • src/test/java/com/preponderous/parpt/service/ProjectServiceTest.java:56: the ordering guarantee (usage is reported only after add succeeds) is enforced by InOrder together with the NameTakenException test. It was checked by reasoning, not by a mutation run.
  • The repository and reporter are mocked as concrete classes, not interfaces. This works with Mockito's default inline mock maker, but it is a divergence from the repo's interface-plus-impl pattern for I/O. That divergence belongs to production code, so it is out of scope here.

Summary: a test-only addition that is green locally and in CI, with no blocking findings.

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


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit d8ea99d into main Sep 27, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the feat/project-service-unit-test branch September 27, 2026 07:43
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