-
Notifications
You must be signed in to change notification settings - Fork 0
test: 코드래빗 테스트용 코드 추가 #11
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
Walkthrough새로운 GET 엔드포인트 Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant GroupController
participant QueryGroupService
participant CommandGroupService
participant GroupRepository
Client->>GroupController: GET /api/v1/group/get?groupToken=...
GroupController->>QueryGroupService: findGroupIdByToken(groupToken)
QueryGroupService-->>GroupController: groupId
GroupController->>CommandGroupService: read(groupId)
CommandGroupService->>GroupRepository: getById(groupId)
GroupRepository-->>CommandGroupService: Group
CommandGroupService-->>GroupController: Group
GroupController-->>Client: 200 OK + Group
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
📝 테스트 커버리지 리포트입니다!
|
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/main/java/com/dnd/moddo/domain/group/controller/GroupController.java(2 hunks)src/main/java/com/dnd/moddo/domain/group/service/CommandGroupService.java(3 hunks)src/main/resources/config(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/main/resources/config (1)
Learnt from: sudhdkso
PR: #5
File: src/main/java/com/dnd/moddo/global/config/KakaoProperties.java:5-13
Timestamp: 2025-07-15T06:25:52.363Z
Learning: The project uses git submodules for configuration management (src/main/resources/config), where sensitive values like Kakao adminKey and clientId are managed separately from the main codebase for security purposes.
🧬 Code Graph Analysis (1)
src/main/java/com/dnd/moddo/domain/group/controller/GroupController.java (3)
src/main/java/com/dnd/moddo/domain/character/controller/CharacterController.java (2)
CharacterController(16-34)getCharacter(25-33)src/test/java/com/dnd/moddo/domain/group/controller/GroupControllerTest.java (2)
getGroup(72-89)GroupControllerTest(28-126)src/main/java/com/dnd/moddo/domain/groupMember/controller/GroupMemberController.java (1)
getGroupMembers(35-42)
🔇 Additional comments (3)
src/main/java/com/dnd/moddo/domain/group/service/CommandGroupService.java (1)
3-3: GroupRepository 의존성 추가가 적절합니다.새로운 의존성 주입이 올바르게 구현되었습니다.
Also applies to: 34-34
src/main/java/com/dnd/moddo/domain/group/controller/GroupController.java (1)
3-3: Group 엔티티 임포트가 적절합니다.새로운 엔드포인트를 위한 필요한 임포트입니다.
src/main/resources/config (1)
1-1: src/main/resources/config 서브모듈 접근 실패: URL 및 커밋 확인 필요
CI 파이프라인에서 아래 스크립트를 실행한 결과, 원격 레포지토리 클론에 실패하여 커밋 존재 여부를 검증할 수 없었습니다.git submodule update --init --recursive # → 오류: https://github.com/sudhdkso/moddo-infra-config.git 레포지토리를 찾을 수 없음 git submodule status src/main/resources/config # → -6515d7b8afc3d52cef1f35923ab9cf0429b9302e확인 및 조치 사항:
.gitmodules에 설정된 URL(https://github.com/sudhdkso/moddo-infra-config.git) 이 올바른지, 또는 SSH(URL, 권한) 로 접근해야 하는지 점검- 서브모듈 레포지토리가 private일 경우, CI 에서 사용할 인증 방식(Token/SSH 키) 설정
- 원격 레포지토리에 커밋
6515d7b8afc3d52cef1f35923ab9cf0429b9302e가 실제로 존재하는지 확인위 내용을 검토한 뒤, 올바른 서브모듈 URL 및 커밋으로 업데이트 부탁드립니다.
| @GetMapping("/get") | ||
| public ResponseEntity<Group> groupGet( | ||
| @RequestParam("groupToken") String code) { | ||
| Long groupId = queryGroupService.findIdByCode(code); | ||
| Group response = commandGroupService.read(groupId); | ||
| return ResponseEntity.ok(response); | ||
| } |
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.
🛠️ Refactor suggestion
엔티티 직접 반환과 인증 누락 문제가 있습니다.
이 엔드포인트에는 몇 가지 개선이 필요한 부분이 있습니다:
- 엔티티 직접 반환: Group 엔티티를 직접 반환하면 내부 구조가 노출됩니다.
- 인증 누락: 다른 엔드포인트와 달리 HttpServletRequest와 인증 로직이 없습니다.
- 엔드포인트 경로:
/get은 명확하지 않은 경로명입니다.
다음과 같이 수정하는 것을 권장합니다:
@GetMapping("/get")
-public ResponseEntity<Group> groupGet(
- @RequestParam("groupToken") String code) {
+public ResponseEntity<GroupResponse> groupGet(
+ HttpServletRequest request,
+ @RequestParam("groupToken") String code) {
+ Long userId = jwtService.getUserId(request);
Long groupId = queryGroupService.findIdByCode(code);
- Group response = commandGroupService.read(groupId);
+ GroupResponse response = queryGroupService.findOne(groupId, userId);
return ResponseEntity.ok(response);
}또는 기존 getGroup() 메서드와 중복되므로 제거를 고려해보세요.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @GetMapping("/get") | |
| public ResponseEntity<Group> groupGet( | |
| @RequestParam("groupToken") String code) { | |
| Long groupId = queryGroupService.findIdByCode(code); | |
| Group response = commandGroupService.read(groupId); | |
| return ResponseEntity.ok(response); | |
| } | |
| @GetMapping("/get") | |
| public ResponseEntity<GroupResponse> groupGet( | |
| HttpServletRequest request, | |
| @RequestParam("groupToken") String code) { | |
| // 인증된 사용자 ID 조회 | |
| Long userId = jwtService.getUserId(request); | |
| // 토큰으로 그룹 ID 조회 | |
| Long groupId = queryGroupService.findIdByCode(code); | |
| // 사용자 권한 검증을 포함해 DTO 반환 | |
| GroupResponse response = queryGroupService.findOne(groupId, userId); | |
| return ResponseEntity.ok(response); | |
| } |
🤖 Prompt for AI Agents
In src/main/java/com/dnd/moddo/domain/group/controller/GroupController.java
around lines 97 to 103, the method directly returns the Group entity, lacks
authentication handling, and uses an unclear endpoint path "/get". To fix this,
replace the direct entity return with a DTO that exposes only necessary data,
add HttpServletRequest parameter and implement authentication checks consistent
with other endpoints, and rename the endpoint to a more descriptive path or
consider removing this method if it duplicates existing functionality like
getGroup().
| public Group read(Long groupId) { | ||
| return groupRepository.getById(groupId); | ||
| } |
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.
🛠️ Refactor suggestion
getById() 사용 시 잠재적 문제점이 있습니다.
groupRepository.getById(groupId)는 엔티티가 존재하지 않을 때 LazyInitializationException을 발생시킬 수 있습니다. 더 안전한 방법을 사용하는 것을 권장합니다.
다음 중 하나의 방법으로 수정하는 것을 권장합니다:
public Group read(Long groupId) {
- return groupRepository.getById(groupId);
+ return groupRepository.findById(groupId)
+ .orElseThrow(() -> new EntityNotFoundException("Group not found with id: " + groupId));
}또는 기존 GroupReader를 활용:
public Group read(Long groupId) {
- return groupRepository.getById(groupId);
+ return groupReader.read(groupId);
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public Group read(Long groupId) { | |
| return groupRepository.getById(groupId); | |
| } | |
| public Group read(Long groupId) { | |
| return groupRepository.findById(groupId) | |
| .orElseThrow(() -> new EntityNotFoundException("Group not found with id: " + groupId)); | |
| } |
🤖 Prompt for AI Agents
In src/main/java/com/dnd/moddo/domain/group/service/CommandGroupService.java
around lines 56 to 58, replace the use of groupRepository.getById(groupId) with
a safer alternative like groupRepository.findById(groupId) that returns an
Optional to avoid LazyInitializationException when the entity does not exist.
Alternatively, use the existing GroupReader component if available to safely
retrieve the Group entity. Adjust the method to handle the Optional properly or
delegate to GroupReader to ensure safe entity access.
#️⃣연관된 이슈
#10
🔀반영 브랜치
feat/#10-codeRabbit-test -> 없음
🔧변경 사항
💬리뷰 요구사항(선택)
Summary by CodeRabbit
/api/v1/group/get)가 추가되었습니다.