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
Conversation
…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>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds integration tests for three application service classes that previously had little or no direct test coverage:
ArticleCommandServiceTest(new, 8 tests): CoverscreateArticle(happy path, empty tags),updateArticle(title-only, description+body), and@Validatedvalidation failures (blank title/body/description, duplicated title via@DuplicatedArticleConstraint).CommentQueryServiceTest(extended, +7 tests): CoversfindByArticleIdWithCursor— empty results, with/without authenticated user, following-author enrichment,hasExtrapagination flag (both true and false), andDirection.PREVreversal.UserServiceTest(new, 11 tests): CoverscreateUser(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@UpdateUserConstraintconflict detection on update.All tests follow the existing
DbTestBasepattern (@MybatisTest+ in-memory SQLite). To enable@Validated/ConstraintViolationExceptiontesting in the@MybatisTestslice,ValidationAutoConfigurationis explicitly imported.Review & Testing Checklist for Human
UpdateArticleParamconstructor arg order — field declaration order is(title, body, description), sonew UpdateArticleParam("", "new body", "new description")inshould_update_article_description_and_bodymust map correctly. Confirm the assertions match.should_reverse_comments_for_prev_direction— this test only asserts the result is non-empty andhasNextis false; it does not verify actual ordering. Consider whether a stronger assertion is needed../gradlew testlocally to confirm all 94 tests pass (verified in session on Java 17 + SQLite in-memory).Notes
ValidationAutoConfigurationimport is new to this test suite — it's needed because@MybatisTestdoesn't load Spring's method-validation infrastructure by default. This is intentional and scoped to the two test classes that need it.updateUserwas intentionally omitted:UpdateUserCommanddoes not cascade@Validto itsUpdateUserParamfield, so the@Emailconstraint onUpdateUserParam.emailis unreachable throughUserService.updateUser.gradle.propertieswith JVM--add-exportsargs was created locally to fix a pre-existingspotlessApplyissue on Java 17 but is not included in this PR.Link to Devin session: https://app.devin.ai/sessions/2c48af32d9e54f28b4fb009984c55354
Requested by: @choikh0423