Skip to content

Add service layer test coverage for ArticleCommandService, CommentQueryService, and UserService [COG-187]#533

Open
devin-ai-integration[bot] wants to merge 1 commit intochoikh-test-coverage-demofrom
devin/COG-187-1775708863
Open

Add service layer test coverage for ArticleCommandService, CommentQueryService, and UserService [COG-187]#533
devin-ai-integration[bot] wants to merge 1 commit intochoikh-test-coverage-demofrom
devin/COG-187-1775708863

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot commented Apr 9, 2026

Summary

Adds integration tests for three application service classes that previously had little or no direct test coverage:

  • ArticleCommandServiceTest (new, 8 tests): Covers createArticle (happy path, empty tags), updateArticle (title-only, description+body), and @Validated validation failures (blank title/body/description, duplicated title via @DuplicatedArticleConstraint).
  • CommentQueryServiceTest (extended, +7 tests): Covers findByArticleIdWithCursor — empty results, with/without authenticated user, following-author enrichment, hasExtra pagination flag (both true and false), and Direction.PREV reversal.
  • UserServiceTest (new, 11 tests): Covers createUser (happy path, password encoding), updateUser (happy path, same-email-and-username allowed), and validation branches — blank email/username/password, invalid email format, duplicated email/username on register, and @UpdateUserConstraint conflict detection on update.

All tests follow the existing DbTestBase pattern (@MybatisTest + in-memory SQLite). To enable @Validated / ConstraintViolationException testing in the @MybatisTest slice, ValidationAutoConfiguration is explicitly imported.

Review & Testing Checklist for Human

  • Verify UpdateArticleParam constructor arg order — field declaration order is (title, body, description), so new UpdateArticleParam("", "new body", "new description") in should_update_article_description_and_body must map correctly. Confirm the assertions match.
  • Assess should_reverse_comments_for_prev_direction — this test only asserts the result is non-empty and hasNext is false; it does not verify actual ordering. Consider whether a stronger assertion is needed.
  • Run ./gradlew test locally to confirm all 94 tests pass (verified in session on Java 17 + SQLite in-memory).

Notes

  • ValidationAutoConfiguration import is new to this test suite — it's needed because @MybatisTest doesn't load Spring's method-validation infrastructure by default. This is intentional and scoped to the two test classes that need it.
  • A test for invalid email on updateUser was intentionally omitted: UpdateUserCommand does not cascade @Valid to its UpdateUserParam field, so the @Email constraint on UpdateUserParam.email is unreachable through UserService.updateUser.
  • gradle.properties with JVM --add-exports args was created locally to fix a pre-existing spotlessApply issue on Java 17 but is not included in this PR.

Link to Devin session: https://app.devin.ai/sessions/2c48af32d9e54f28b4fb009984c55354
Requested by: @choikh0423


Open with Devin

…ryService, and UserService

- ArticleCommandServiceTest: tests for createArticle, updateArticle, validation
  failures (blank title/body/description), and duplicated title validation
- CommentQueryServiceTest: extended with findByArticleIdWithCursor tests covering
  empty results, with/without user, hasExtra pagination, and reverse direction
- UserServiceTest: tests for createUser, updateUser, validation failures (blank
  fields, invalid email, duplicated email/username), and update conflict detection

COG-187

Co-Authored-By: Kyu Choi <kyuhwanchoi0423@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Author

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

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