-
Notifications
You must be signed in to change notification settings - Fork 0
test: 사진 조회 관련 테스트 코드 작성 #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAlbumService에 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/test/java/com/cheeeese/photo/integration/PhotoQueryServiceIntegrationTest.java (1)
71-76: testPhoto 참조가 반복문에서 덮어씌워집니다.반복문에서 3개의 사진을 생성하지만,
testPhoto변수는 마지막 사진만 참조하게 됩니다. 이후 Line 77-78에서testPhotoHistory와testPhotoLikes도 마지막 사진만 사용합니다.의도한 동작이라면 명확성을 위해 변수명을
lastPhoto로 변경하거나 주석을 추가하는 것을 권장합니다.+ Photo lastPhoto = null; for (int i = 1; i <= 3; i++) { - testPhoto = FixtureFactory.createCompletedPhoto(testUser, testAlbum, LocalDateTime.now()); - testPhoto.updateImageUrl("album/" + testAlbum.getId() + "/original/photo_" + i + ".jpg"); - photoRepository.save(testPhoto); + lastPhoto = FixtureFactory.createCompletedPhoto(testUser, testAlbum, LocalDateTime.now()); + lastPhoto.updateImageUrl("album/" + testAlbum.getId() + "/original/photo_" + i + ".jpg"); + photoRepository.save(lastPhoto); } + testPhoto = lastPhoto;src/test/java/com/cheeeese/fixture/FixtureFactory.java (1)
105-114: 파라미터명을 명확하게 변경하는 것을 권장합니다.파라미터명이
now로 되어 있지만, 실제로는 캡처 시각으로 사용됩니다.createPhoto메서드와의 일관성을 위해captureTime으로 변경하는 것이 좋습니다.- public static Photo createCompletedPhoto(User user, Album album, LocalDateTime now) { + public static Photo createCompletedPhoto(User user, Album album, LocalDateTime captureTime) { return Photo.builder() .user(user) .album(album) .imageUrl(null) .thumbnailUrl(null) - .captureTime(now) + .captureTime(captureTime) .status(PhotoStatus.COMPLETED) .build(); }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/main/java/com/cheeeese/photo/infrastructure/mapper/PhotoMapper.java(0 hunks)src/test/java/com/cheeeese/album/AlbumServiceTest.java(3 hunks)src/test/java/com/cheeeese/fixture/FixtureFactory.java(2 hunks)src/test/java/com/cheeeese/photo/PhotoServiceTest.java(3 hunks)src/test/java/com/cheeeese/photo/integration/PhotoQueryServiceIntegrationTest.java(1 hunks)
💤 Files with no reviewable changes (1)
- src/main/java/com/cheeeese/photo/infrastructure/mapper/PhotoMapper.java
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-11-13T12:56:22.161Z
Learnt from: dahyun24
Repo: Say-Cheeeese/BE PR: 58
File: src/main/java/com/cheeeese/cheese4cut/application/Cheese4cutService.java:149-156
Timestamp: 2025-11-13T12:56:22.161Z
Learning: In src/main/java/com/cheeeese/cheese4cut/application/Cheese4cutService.java, the finalizeCheese4cut method intentionally re-sorts photos using findAllByIdInOrderByLikesDescCreatedDesc(request.photoIds()) instead of preserving the client's requested order. This is a defensive measure to ensure photos are always ordered by likes (DESC) and creation time (DESC), regardless of what order the client sends, preventing incorrect ordering from client errors.
Applied to files:
src/test/java/com/cheeeese/photo/PhotoServiceTest.javasrc/test/java/com/cheeeese/fixture/FixtureFactory.javasrc/test/java/com/cheeeese/photo/integration/PhotoQueryServiceIntegrationTest.java
📚 Learning: 2025-10-31T13:17:52.523Z
Learnt from: dahyun24
Repo: Say-Cheeeese/BE PR: 35
File: src/main/java/com/cheeeese/photo/application/PhotoService.java:46-52
Timestamp: 2025-10-31T13:17:52.523Z
Learning: In src/main/java/com/cheeeese/photo/application/PhotoService.java, the getRecentThumbnailUrls method intentionally returns only the first thumbnail URL when photos.size() < 5, rather than returning all available thumbnails. This is according to product requirements: 0 photos → empty list, 1-4 photos → single thumbnail (most recent), 5 photos → all 5 thumbnails.
Applied to files:
src/test/java/com/cheeeese/photo/PhotoServiceTest.java
📚 Learning: 2025-11-05T03:06:41.855Z
Learnt from: zyovn
Repo: Say-Cheeeese/BE PR: 44
File: src/main/java/com/cheeeese/photo/infrastructure/persistence/PhotoHistoryRepository.java:36-36
Timestamp: 2025-11-05T03:06:41.855Z
Learning: PhotoHistoryRepository의 existsByUserIdAndPhotoIdAndCreatedAt 메서드는 정확한 타임스탬프 일치를 확인하는 시그니처로, "1시간 이내 다운로드" 체크에는 부적합합니다. Spring Data JPA에서는 existsByUserIdAndPhotoIdAndCreatedAtAfter를 사용하여 >= 비교를 수행해야 합니다.
Applied to files:
src/test/java/com/cheeeese/photo/PhotoServiceTest.javasrc/test/java/com/cheeeese/photo/integration/PhotoQueryServiceIntegrationTest.java
📚 Learning: 2025-11-26T16:49:59.252Z
Learnt from: dahyun24
Repo: Say-Cheeeese/BE PR: 104
File: src/main/java/com/cheeeese/album/application/logger/AlbumLogger.java:37-37
Timestamp: 2025-11-26T16:49:59.252Z
Learning: In AlbumLogger.java, the method logAlbumJoined() hardcodes is_first_join=true because it is only called when a new user joins an album for the first time, not for re-visits.
Applied to files:
src/test/java/com/cheeeese/album/AlbumServiceTest.java
🧬 Code graph analysis (1)
src/test/java/com/cheeeese/photo/integration/PhotoQueryServiceIntegrationTest.java (1)
src/test/java/com/cheeeese/fixture/FixtureFactory.java (1)
FixtureFactory(27-129)
🔇 Additional comments (4)
src/test/java/com/cheeeese/album/AlbumServiceTest.java (1)
4-5: LGTM! 의존성 추가가 올바르게 반영되었습니다.AlbumService의 생성자 시그니처 변경에 맞춰 테스트 코드가 정확하게 업데이트되었습니다. AlbumReader와 AlbumLogger가 Mock으로 선언되고 생성자에 전달되고 있습니다.
Also applies to: 59-60, 74-76
src/test/java/com/cheeeese/photo/integration/PhotoQueryServiceIntegrationTest.java (1)
81-133: 테스트 메서드들이 잘 작성되었습니다.네 가지 주요 사진 조회 시나리오를 커버하는 통합 테스트가 잘 구성되어 있습니다. CDN URL 변환, 페이징, 좋아요 기능 등 핵심 기능들을 적절히 검증하고 있습니다.
src/test/java/com/cheeeese/photo/PhotoServiceTest.java (1)
27-27: LGTM! FileInfo 생성자 시그니처 변경이 정확히 반영되었습니다.
PhotoPresignedUrlRequest.FileInfo생성자에LocalDateTime타임스탬프 파라미터가 추가된 것에 맞춰 모든 테스트 코드가 올바르게 업데이트되었습니다.Also applies to: 60-60, 102-103
src/test/java/com/cheeeese/fixture/FixtureFactory.java (1)
116-128: LGTM! PhotoHistory와 PhotoLikes 픽스처 메서드가 잘 구현되었습니다.두 메서드 모두 적절한 매퍼를 사용하여 엔티티를 생성하고 있으며, 테스트 데이터 설정에 유용하게 사용될 것입니다.
src/test/java/com/cheeeese/photo/integration/PhotoQueryServiceIntegrationTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/test/java/com/cheeeese/fixture/FixtureFactory.java (1)
105-114: 파라미터 이름을 더 명확하게 변경하는 것을 권장합니다.파라미터 이름이
now로 되어 있지만 실제로는 사진 촬영 시간(captureTime)을 나타냅니다.now는 "현재 시간"을 의미하므로, 과거나 미래의 특정 시간을 설정하는 테스트에서 혼란을 줄 수 있습니다.다음과 같이 수정하세요:
- public static Photo createCompletedPhoto(User user, Album album, LocalDateTime now) { + public static Photo createCompletedPhoto(User user, Album album, LocalDateTime captureTime) { return Photo.builder() .user(user) .album(album) .imageUrl(null) .thumbnailUrl(null) - .captureTime(now) + .captureTime(captureTime) .status(PhotoStatus.COMPLETED) .build(); }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/test/java/com/cheeeese/fixture/FixtureFactory.java(2 hunks)src/test/java/com/cheeeese/photo/integration/PhotoQueryServiceIntegrationTest.java(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/test/java/com/cheeeese/photo/integration/PhotoQueryServiceIntegrationTest.java
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-13T12:56:22.161Z
Learnt from: dahyun24
Repo: Say-Cheeeese/BE PR: 58
File: src/main/java/com/cheeeese/cheese4cut/application/Cheese4cutService.java:149-156
Timestamp: 2025-11-13T12:56:22.161Z
Learning: In src/main/java/com/cheeeese/cheese4cut/application/Cheese4cutService.java, the finalizeCheese4cut method intentionally re-sorts photos using findAllByIdInOrderByLikesDescCreatedDesc(request.photoIds()) instead of preserving the client's requested order. This is a defensive measure to ensure photos are always ordered by likes (DESC) and creation time (DESC), regardless of what order the client sends, preventing incorrect ordering from client errors.
Applied to files:
src/test/java/com/cheeeese/fixture/FixtureFactory.java
🧬 Code graph analysis (1)
src/test/java/com/cheeeese/fixture/FixtureFactory.java (3)
src/main/java/com/cheeeese/photo/infrastructure/mapper/PhotoHistoryMapper.java (1)
PhotoHistoryMapper(7-15)src/main/java/com/cheeeese/photo/infrastructure/mapper/PhotoLikesMapper.java (1)
PhotoLikesMapper(7-15)src/main/java/com/cheeeese/photo/infrastructure/mapper/PhotoMapper.java (1)
PhotoMapper(14-179)
🔇 Additional comments (3)
src/test/java/com/cheeeese/fixture/FixtureFactory.java (3)
97-103: 이전 리뷰 피드백이 반영되었습니다!
captureTime파라미터를 올바르게 사용하도록 수정되었습니다. 이제 호출자가 제공한 시간을 정확히 사용합니다.
116-121: 잘 구현되었습니다.
PhotoHistoryMapper를 올바르게 사용하고 있으며, 간결하고 명확한 구현입니다.
123-128: 잘 구현되었습니다.
PhotoLikesMapper를 올바르게 사용하고 있으며, 간결하고 명확한 구현입니다.
dahyun24
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
통합테스트까지!!! 굳굳 수고하셨어유~
🔗 연관된 이슈
🚀 변경 유형
📝 작업 내용
📸 스크린샷
💬 리뷰 요구사항
📜 리뷰 규칙
Reviewer는 아래 P5 Rule을 참고하여 리뷰를 진행합니다.
P5 Rule을 통해 Reviewer는 Reviewee에게 리뷰의 의도를 보다 정확히 전달할 수 있습니다.
Summary by CodeRabbit
릴리스 노트
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.