Add comprehensive tests for GraphQL mutations layer#618
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Add comprehensive tests for GraphQL mutations layer#618devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Add unit tests for all four GraphQL mutation classes: - ArticleMutationTest: 17 tests covering createArticle, updateArticle, favoriteArticle, unfavoriteArticle, deleteArticle - CommentMutationTest: 9 tests covering createComment, deleteComment - RelationMutationTest: 7 tests covering follow, unfollow - UserMutationTest: 9 tests covering createUser, login, updateUser Each mutation class tests: - Happy path (successful operation) - Authentication required (unauthenticated user) - Authorization checks (e.g., only article author can update/delete) - Resource not found scenarios - Validation errors (ConstraintViolationException in createUser) 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 42 unit tests across 4 new test files for the entire GraphQL mutations layer, which previously had zero test coverage.
Test files added:
ArticleMutationTest.java— 17 tests for createArticle, updateArticle, favoriteArticle, unfavoriteArticle, deleteArticleCommentMutationTest.java— 9 tests for createComment, deleteCommentRelationMutationTest.java— 7 tests for follow, unfollowUserMutationTest.java— 9 tests for createUser, login, updateUserTest scenarios covered for each mutation:
Approach: Pure Mockito unit tests with
@ExtendWith(MockitoExtension.class), mocking dependencies (ArticleRepository,ArticleCommandService, etc.) and usingSecurityContextHolderwithTestingAuthenticationToken/AnonymousAuthenticationTokenfor auth scenarios. Follows existing patterns from REST API tests.All 110 tests pass (68 existing + 42 new).
Review & Testing Checklist for Human
ArticleMutation.java,CommentMutation.java,RelationMutation.java,UserMutation.java./gradlew testlocally to confirm all 110 tests passAnonymousAuthenticationToken)Notes
SecurityContextHolderdirectly rather than Spring Security filter chain since these are unit tests, not integration testsLink to Devin session: https://app.devin.ai/sessions/de1825069d7747b09cae3ecd14fedbb9
Requested by: @choikh0423
Devin Review