Skip to content

Add comprehensive tests for GraphQL mutations layer#618

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1779700257-graphql-mutation-tests
Open

Add comprehensive tests for GraphQL mutations layer#618
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1779700257-graphql-mutation-tests

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented May 25, 2026

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, deleteArticle
  • CommentMutationTest.java — 9 tests for createComment, deleteComment
  • RelationMutationTest.java — 7 tests for follow, unfollow
  • UserMutationTest.java — 9 tests for createUser, login, updateUser

Test scenarios covered for each mutation:

  • Happy path (successful operation)
  • Authentication required (unauthenticated user gets AuthenticationException)
  • Authorization checks (e.g., only article author can update/delete)
  • Resource not found scenarios
  • Validation errors (ConstraintViolationException in createUser)
  • Edge cases (null tag list, comment author vs article author authorization)

Approach: Pure Mockito unit tests with @ExtendWith(MockitoExtension.class), mocking dependencies (ArticleRepository, ArticleCommandService, etc.) and using SecurityContextHolder with TestingAuthenticationToken/AnonymousAuthenticationToken for auth scenarios. Follows existing patterns from REST API tests.

All 110 tests pass (68 existing + 42 new).

Review & Testing Checklist for Human

  • Verify test coverage matches the mutation methods in each class — cross-check ArticleMutation.java, CommentMutation.java, RelationMutation.java, UserMutation.java
  • Run ./gradlew test locally to confirm all 110 tests pass
  • Spot-check that auth tests properly simulate unauthenticated state (using AnonymousAuthenticationToken)

Notes

  • Spotless (code formatting) has a pre-existing issue with google-java-format on the Java version in this environment — unrelated to this PR
  • Tests use SecurityContextHolder directly rather than Spring Security filter chain since these are unit tests, not integration tests

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


Devin Review

Status Commit
⚪ Not started

Run Devin Review

💡 Connect your GitHub account to enable automatic code reviews.

Open in Devin Review (Staging)
Open in Devin Review

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>
@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 4 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