[FIX] nullable 조회 조건으로 인한 홈 API 오류 수정 - #118
Conversation
📝 WalkthroughWalkthrough
Changes재생 기록 조회 흐름
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/test/java/com/mr/domain/history/service/HistoryServiceTest.java (1)
135-148: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
HistoryPeriod.RECENT의 무필터 경로도 직접 검증하세요.현재 테스트는
HistoryPeriod.WEEKLY가findPlayingsByUserAndStatusSince를 선택하는지만 확인합니다.HistoryService.resolveCutoff는RECENT에서null을 반환하므로, 이 경로는findPlayingsByUserAndStatus를 사용해야 합니다. 해당 라우팅이 회귀해도 현재 테스트는 이를 직접 검출하지 못합니다.
RECENT요청에서 status-only 메서드가 호출되고 cutoff 전용 메서드는 호출되지 않는지 검증하세요. 호출 메서드와 인자를 함께 검증하면 분리된 Repository 계약의 회귀를 조기에 찾을 수 있습니다.테스트 보강 예시
+import static org.mockito.Mockito.never; + + `@Test` + `@DisplayName`("getHistories - RECENT는 기간 조건 없는 쿼리를 사용한다") + void getHistories_recent_usesUnfilteredQuery() { + given(playingRepository.findPlayingsByUserAndStatus( + eq(1L), eq(PlayingStatus.COMPLETED), eq(PageRequest.of(0, 10)))) + .willReturn(new SliceImpl<>(List.of(), PageRequest.of(0, 10), false)); + + historyService.getHistories(1L, 0, 10, HistoryPeriod.RECENT); + + verify(playingRepository).findPlayingsByUserAndStatus( + eq(1L), eq(PlayingStatus.COMPLETED), eq(PageRequest.of(0, 10))); + verify(playingRepository, never()).findPlayingsByUserAndStatusSince( + eq(1L), eq(PlayingStatus.COMPLETED), any(LocalDateTime.class), any()); + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/test/java/com/mr/domain/history/service/HistoryServiceTest.java` around lines 135 - 148, Extend getHistories_withPeriod_usesSinceQuery or add a focused test for HistoryPeriod.RECENT that stubs and verifies playingRepository.findPlayingsByUserAndStatus with the expected user, COMPLETED status, and PageRequest, while explicitly verifying findPlayingsByUserAndStatusSince is never called. Keep the assertion that the returned response is empty and validate the repository routing and arguments together.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/test/java/com/mr/domain/history/service/HistoryServiceTest.java`:
- Around line 135-148: Extend getHistories_withPeriod_usesSinceQuery or add a
focused test for HistoryPeriod.RECENT that stubs and verifies
playingRepository.findPlayingsByUserAndStatus with the expected user, COMPLETED
status, and PageRequest, while explicitly verifying
findPlayingsByUserAndStatusSince is never called. Keep the assertion that the
returned response is empty and validate the repository routing and arguments
together.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: bea5527a-b784-419c-b447-00be74011049
📒 Files selected for processing (5)
src/main/java/com/mr/domain/history/service/HistoryService.javasrc/main/java/com/mr/domain/home/service/HomeService.javasrc/main/java/com/mr/domain/playing/repository/PlayingRepository.javasrc/test/java/com/mr/domain/history/service/HistoryServiceTest.javasrc/test/java/com/mr/domain/home/service/HomeServiceTest.java
kimyw1018
left a comment
There was a problem hiding this comment.
버그 원인 쿼리로 깔끔하게 잘 처리 되어있네요! 수고하셨습니다
rkdehdrbs7885-oss
left a comment
There was a problem hiding this comment.
같은 조회 조건에서도 방식에 따라서도 문제가 생길 수 있군요. 승인하겠습니다!
📍 개요
⛓️💥 관련 이슈
🛠️ 작업 내용
🔥 리뷰 요청 사항
✅ 체크리스트
📎 참고 사항
Summary by CodeRabbit
개선 사항
테스트