Feat: getBody 전체 조회 API 구현 - #332
Conversation
📝 Walkthrough개요getBodies API에서 petProblem 매개변수를 선택사항으로 변경하여 null일 때 전체 body 리스트를 반환하도록 수정했습니다. 새로운 에러 메시지 상수와 null-안전 처리 로직이 추가되었습니다. 변경 사항
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 (2)
src/test/java/com/cocos/cocos/body/BodyServiceTest.java (1)
110-122: 브랜치 선택까지 검증하면 회귀 방지에 더 좋습니다.지금 테스트는 결과만 비교해서, null 경로에서
findAll()외 조회가 추가돼도 우연히 같은 결과면 통과할 수 있습니다. 이 케이스의 핵심 의도가 “Line 119에서 null이면 전체 조회 branch를 탄다”인 만큼,findAll()호출과findAllById(...)미호출까지 같이 검증해 두면 테스트가 더 단단해집니다.예시
//then Assertions.assertThat(actual).usingRecursiveComparison().isEqualTo(expected); + BDDMockito.then(bodyRepository).should().findAll(); + BDDMockito.then(bodyRepository).should(never()).findAllById(any()); + BDDMockito.then(diseaseRepository).shouldHaveNoInteractions();필요하면
import static org.mockito.Mockito.never;도 추가해 주세요.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/com/cocos/cocos/body/BodyServiceTest.java` around lines 110 - 122, The test only asserts the returned BodiesResponse but doesn't verify which repository branch was used; update the test around the call to bodyService.getBodies(null) to explicitly verify that bodyRepository.findAll() was invoked and that bodyRepository.findAllById(...) was never invoked (use Mockito.verify(bodyRepository).findAll() and Mockito.verify(bodyRepository, never()).findAllById(...)), and add the static import for Mockito.never if needed; this ensures the null branch behavior in getBodies(...) is enforced.src/main/java/com/cocos/cocos/api/body/controller/BodyControllerSwagger.java (1)
21-21: 선택적 매개변수의 동작을 설명에 추가하세요.Line 21의
petProblem이required = false인데, 현재 설명 "반려동물 문제(DISEASE or SYMPTOM)"에는 이 매개변수를 생략할 때의 동작(전체 조회)이 나타나지 않습니다. 사용자 입장에서 Swagger 문서를 볼 때 이 매개변수를 전달하지 않으면 어떻게 되는지 명확히 알 수 있도록 설명을 개선하는 것이 좋습니다.예:
"반려동물 문제(DISEASE or SYMPTOM). 미입력 시 전체 조회"참고:
schema =@Schema(type = "String")설정은 enum 값 노출을 막지 않으므로 현재 상태로도 Swagger에는 허용 enum 값이 제대로 표시됩니다.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/com/cocos/cocos/api/body/controller/BodyControllerSwagger.java` at line 21, 주석의 `@Parameter`(name = "petProblem", ...) 설명이 선택적(required = false)일 때의 동작을 명시하지 않으므로 BodyControllerSwagger.java의 petProblem Parameter 설명을 "반려동물 문제(DISEASE or SYMPTOM). 미입력 시 전체 조회"처럼 수정해 생략 시 전체 조회된다는 동작을 명확히 적어주고, 기존 schema = `@Schema`(type = "String") 설정은 유지하여 enum 노출에는 영향이 없음을 확인하세요.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@src/main/java/com/cocos/cocos/api/body/controller/BodyControllerSwagger.java`:
- Line 21: 주석의 `@Parameter`(name = "petProblem", ...) 설명이 선택적(required = false)일
때의 동작을 명시하지 않으므로 BodyControllerSwagger.java의 petProblem Parameter 설명을 "반려동물
문제(DISEASE or SYMPTOM). 미입력 시 전체 조회"처럼 수정해 생략 시 전체 조회된다는 동작을 명확히 적어주고, 기존 schema
= `@Schema`(type = "String") 설정은 유지하여 enum 노출에는 영향이 없음을 확인하세요.
In `@src/test/java/com/cocos/cocos/body/BodyServiceTest.java`:
- Around line 110-122: The test only asserts the returned BodiesResponse but
doesn't verify which repository branch was used; update the test around the call
to bodyService.getBodies(null) to explicitly verify that
bodyRepository.findAll() was invoked and that bodyRepository.findAllById(...)
was never invoked (use Mockito.verify(bodyRepository).findAll() and
Mockito.verify(bodyRepository, never()).findAllById(...)), and add the static
import for Mockito.never if needed; this ensures the null branch behavior in
getBodies(...) is enforced.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2465562a-1f54-43c7-93eb-b2825375793b
📒 Files selected for processing (6)
src/main/java/com/cocos/cocos/api/body/controller/BodyController.javasrc/main/java/com/cocos/cocos/api/body/controller/BodyControllerSwagger.javasrc/main/java/com/cocos/cocos/api/body/service/BodyService.javasrc/main/java/com/cocos/cocos/enums/message/FailMessage.javasrc/main/java/com/cocos/cocos/enums/pet/PetProblem.javasrc/test/java/com/cocos/cocos/body/BodyServiceTest.java
🔥Pull requests
⛳️ 작업한 브랜치
👷 작업한 내용
🚨 참고 사항
Summary by CodeRabbit
릴리스 노트
새로운 기능
버그 수정
테스트