Repository navigation
Feature/integration tests - #5
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Spring Boot integration tests around the “like” and “mute” service flows, plus a small repository tweak to support mute creation.
Changes:
- Added
LikeServiceIntegrationTestcovering like/unlike for posts and comments, plus list endpoints. - Added
MuteServiceIntegrationTestcovering mute/unmute and listing mutings. - Updated
MuteRepository#createMuteRelationshipnative insert to also setupdated_at.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/test/java/se/jensen/yuki/springboot/service/MuteServiceIntegrationTest.java |
New integration tests for muting/unmuting and listing mutings. |
src/test/java/se/jensen/yuki/springboot/service/LikeServiceIntegrationTest.java |
New integration tests for post/comment like flows and like list retrieval. |
src/main/java/se/jensen/yuki/springboot/repository/MuteRepository.java |
Adjusts native insert to include updated_at timestamp. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import se.jensen.yuki.springboot.model.Comment; | ||
| import se.jensen.yuki.springboot.model.Post; | ||
| import se.jensen.yuki.springboot.model.User; | ||
| import se.jensen.yuki.springboot.repository.*; |
There was a problem hiding this comment.
Avoid using a wildcard repository import in tests; it makes it harder to see which repositories are actually used and is inconsistent with the other integration tests in this package (which import repositories explicitly). Replace se.jensen.yuki.springboot.repository.* with the specific repository imports used by this test.
| import se.jensen.yuki.springboot.repository.*; | |
| import se.jensen.yuki.springboot.repository.UserRepository; | |
| import se.jensen.yuki.springboot.repository.PostRepository; | |
| import se.jensen.yuki.springboot.repository.CommentRepository; | |
| import se.jensen.yuki.springboot.repository.PostLikeRepository; | |
| import se.jensen.yuki.springboot.repository.CommentLikeRepository; |
|
|
||
| muteService.muteUser(user1.getId(), user2.getId()); | ||
|
|
||
| MuteResponse res = | ||
| muteService.muteUser(user1.getId(), user2.getId()); | ||
|
|
||
| assertThat(res).isNotNull(); |
There was a problem hiding this comment.
This test is named muteUser_shouldNotDuplicate but it only asserts the second call returns non-null; it doesn’t verify that only one mute relationship exists. Consider asserting the mutings list size remains 1 (e.g., via muteService.getMutings(...)) after calling muteUser twice, or otherwise checking the persisted relationship count, so the test actually covers the behavior implied by its name.
| muteService.muteUser(user1.getId(), user2.getId()); | |
| MuteResponse res = | |
| muteService.muteUser(user1.getId(), user2.getId()); | |
| assertThat(res).isNotNull(); | |
| // First mute call creates the relationship | |
| muteService.muteUser(user1.getId(), user2.getId()); | |
| // Second mute call should not create a duplicate | |
| MuteResponse res = | |
| muteService.muteUser(user1.getId(), user2.getId()); | |
| assertThat(res).isNotNull(); | |
| // Verify only one mute relationship exists | |
| Slice<MuteMutingResponse> slice = | |
| muteService.getMutings( | |
| user1.getId(), | |
| PageRequest.of(0, 10) | |
| ); | |
| assertThat(slice).isNotNull(); | |
| assertThat(slice.getContent()).hasSize(1); | |
| assertThat(slice.getContent().get(0).mutedUserId()).isEqualTo(user2.getId()); |
Added LikeService and MuteService integration tests