Add JUnit 5 tests for 5 least-covered service/API classes#137
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Add JUnit 5 tests for 5 least-covered service/API classes#137devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
- ArticleCommandServiceTest: tests create/update article flows - CommentQueryServiceCursorTest: tests cursor pagination, following status - CustomizeExceptionHandlerTest: tests all exception handler methods - UserServiceTest: tests user creation and update operations - CursorPagerTest: tests pagination direction, cursors, edge cases Coverage improved from 33% to 37% instruction coverage. New tests: 42 test methods covering happy path, error, and edge cases.
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 unit tests for the 5 least-covered classes in the service layer and API exception handling, identified via JaCoCo coverage analysis. All tests are additive — no production code was modified.
Baseline coverage: 33% instruction coverage → 37% after these tests (110 tests total, up from 68).
ArticleCommandServiceTest(7 tests)ArticleCommandService@Mock/@InjectMocksCommentQueryServiceCursorTest(9 tests)CommentQueryServicefindByArticleIdWithCursorCustomizeExceptionHandlerTest(7 tests)CustomizeExceptionHandlerUserServiceTest(8 tests)UserServicePasswordEncoderCursorPagerTest(11 tests)CursorPagerEach test class covers happy path, error cases, and edge cases (e.g., null user, empty lists, nested constraint violation paths).
Review & Testing Checklist for Human
ArticleCommandServiceTest.should_create_article_with_null_tag_listassertsNullPointerException— this documents current behavior wherenulltag list causes an NPE inArticleconstructor. Verify this is acceptable rather than masking a bug that should be fixed with graceful handling.UserServiceTestmocks bypass Spring's@Validated— the@UpdateUserConstraintvalidator logic (UpdateUserValidator) is never exercised by these tests. The tests verifyUser.update()delegation but not duplicate-email/username validation. This is by design for unit tests but worth noting.CustomizeExceptionHandlerTestdoes NOT coverhandleMethodArgumentNotValid(the@Overridemethod). The handler has 4 exception-handling methods but only 3 are tested. Consider whether this gap matters../gradlew test jacocoTestReportlocally and verify all 110 tests pass. The build will report a JaCoCo verification failure (37% < 80% threshold) which is expected — overall coverage is still dragged down by the untested GraphQL layer.Notes
@SuppressWarnings("unchecked")usage inCustomizeExceptionHandlerTestis necessary due to Mockito's generic type limitations when mockingConstraintViolation<?>andConstraintDescriptor<?>. ThedoReturn().when()pattern is used instead ofwhen().thenReturn()to work around wildcard capture issues.Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/2bbc0116e91f42988ece07e935d863af