test: 검색 기능 단위 테스트 추가#307
Conversation
RouteServiceTest (15개): - 루트 검색 기능 (키워드, 북마크, 사용자별) - 장소 목록 및 사진 목록 매핑 검증 - 최대 10개 이미지 제한 검증 - 활성 루트 조회 - 북마크 기능 - 엣지 케이스 (빈 결과, null 처리) SearchFacadeTest (11개): - 장소/루트 검색 통합 기능 - 카카오 API 통합 (일정 생성 페이지) - 검색 히스토리 저장 - 최근 검색어 조회 - 다양한 검색 시나리오 (내부 DB, 외부 API)
Summary of ChangesHello @lovelyAlien, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 RouteService와 SearchFacade의 핵심 검색 기능에 대한 광범위한 단위 테스트를 도입하여 애플리케이션의 검색 로직 견고성과 신뢰성을 크게 향상시키는 것을 목표로 합니다. 다양한 검색 시나리오와 엣지 케이스를 커버하여 기능의 정확성을 보장합니다. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
이번 PR은 검색 기능에 대한 단위 테스트를 추가하는 중요한 작업입니다. RouteService와 SearchFacade에 대한 테스트 케이스를 꼼꼼하게 작성해주셔서 기능의 안정성을 크게 높였습니다. 다양한 시나리오와 엣지 케이스를 커버하는 테스트들이 인상적입니다.
리뷰에서는 주로 테스트 코드의 가독성과 유지보수성을 향상시키기 위한 몇 가지 스타일 개선 사항을 제안했습니다. FQN(Fully Qualified Name) 대신 import를 사용하고, 테스트 데이터 생성을 동적으로 처리하는 방식을 제안드렸습니다.
전반적으로 훌륭한 기여이며, 제안된 내용을 반영하면 코드가 더욱 견고해질 것입니다. 수고하셨습니다!
| private RoutePlaceRepository routePlaceRepository; | ||
|
|
||
| @Mock | ||
| private com.server.domain.photo.repository.PhotoRepository photoRepository; |
There was a problem hiding this comment.
안녕하세요. 코드 가독성을 위해 PhotoRepository를 FQN(Fully Qualified Name)으로 사용하는 대신 import하여 사용하는 것을 제안합니다. import com.server.domain.photo.repository.PhotoRepository;를 추가하고 여기서는 PhotoRepository만 사용하면 코드가 더 깔끔해집니다.
| private com.server.domain.photo.repository.PhotoRepository photoRepository; | |
| private PhotoRepository photoRepository; |
| org.springframework.test.util.ReflectionTestUtils.setField(user, "id", 1L); | ||
| org.springframework.test.util.ReflectionTestUtils.setField(user, "nickname", "테스트 유저"); |
There was a problem hiding this comment.
안녕하세요. ReflectionTestUtils를 FQN으로 사용하고 계십니다. import org.springframework.test.util.ReflectionTestUtils;를 추가하고 클래스 이름을 직접 사용하면 코드가 더 간결해지고 가독성이 좋아집니다.
| org.springframework.test.util.ReflectionTestUtils.setField(user, "id", 1L); | |
| org.springframework.test.util.ReflectionTestUtils.setField(user, "nickname", "테스트 유저"); | |
| ReflectionTestUtils.setField(user, "id", 1L); | |
| org.springframework.test.util.ReflectionTestUtils.setField(user, "nickname", "테스트 유저"); |
| when(photoRepository.findRepresentativePhotosByPlaceIds( | ||
| List.of(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L), PhotoType.PUBLIC)) | ||
| .thenReturn(mockPhotos); |
There was a problem hiding this comment.
안녕하세요. searchRoutesByKeyword_MaximumTenPhotos 테스트에서 장소 ID 목록이 하드코딩되어 있습니다. 테스트의 유연성과 유지보수성을 높이기 위해, 이 목록을 동적으로 생성하는 것을 고려해볼 수 있습니다. 예를 들어, LongStream을 사용하면 장소 개수가 변경되더라도 코드를 수정할 필요가 없습니다.
| when(photoRepository.findRepresentativePhotosByPlaceIds( | |
| List.of(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L), PhotoType.PUBLIC)) | |
| .thenReturn(mockPhotos); | |
| when(photoRepository.findRepresentativePhotosByPlaceIds( | |
| java.util.stream.LongStream.rangeClosed(1, 12).boxed().collect(java.util.stream.Collectors.toList()), PhotoType.PUBLIC)) | |
| .thenReturn(mockPhotos); |
| org.springframework.test.util.ReflectionTestUtils.setField(user, "id", 1L); | ||
| org.springframework.test.util.ReflectionTestUtils.setField(user, "nickname", "테스트 유저"); |
There was a problem hiding this comment.
안녕하세요. ReflectionTestUtils를 FQN으로 사용하고 계십니다. import org.springframework.test.util.ReflectionTestUtils;를 추가하고 클래스 이름을 직접 사용하면 코드가 더 간결해지고 가독성이 좋아집니다.
| org.springframework.test.util.ReflectionTestUtils.setField(user, "id", 1L); | |
| org.springframework.test.util.ReflectionTestUtils.setField(user, "nickname", "테스트 유저"); | |
| ReflectionTestUtils.setField(user, "id", 1L); | |
| org.springframework.test.util.ReflectionTestUtils.setField(user, "nickname", "테스트 유저"); |
작업 내용
RouteServiceTest (15개):
SearchFacadeTest (11개):
관련 이슈
Closes #308