-
Notifications
You must be signed in to change notification settings - Fork 0
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
feature/#127 about domain, service testcode 구현 #128
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Walkthrough이 변경 사항은 Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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
🧹 Outside diff range and nitpick comments (9)
aics-domain/src/testFixtures/java/about/domain/AboutDomainTest.java (3)
14-32
: 테스트 케이스 보완이 필요합니다.
createAbout_Success
테스트는 기본적인 생성 케이스만 다루고 있습니다. 다음과 같은 추가 테스트 케이스를 고려해 보시기 바랍니다:
- 필수 필드가 null인 경우
- detailCategory가 null인 경우의 정상 동작
- 유효하지 않은 카테고리 조합
테스트 케이스 예시:
@Test @DisplayName("필수 필드가 null일 경우 예외가 발생한다") void createAbout_WithNullRequiredFields() { assertThrows(IllegalArgumentException.class, () -> About.create(null, HISTORY, "test", "content")); }
34-49
: 테스트 메소드 명명 규칙 개선이 필요합니다.현재 테스트 메소드 이름이
updateContent_Success
로 되어 있는데, 더 명확한 의미 전달을 위해shouldUpdateContentSuccessfully
와 같은 형태로 변경하는 것을 추천드립니다.또한 다음과 같은 실패 케이스도 테스트에 포함하면 좋을 것 같습니다:
- null content로 업데이트 시도
- 빈 문자열로 업데이트 시도
1-50
: 테스트 데이터 관리 개선이 필요합니다.테스트 클래스 전반에 걸쳐 테스트 데이터가 하드코딩되어 있습니다. TestFixture나 @beforeeach를 활용하여 테스트 데이터를 중앙 집중화하면 유지보수가 더 용이할 것 같습니다.
예시:
class AboutDomainTest { private MainCategory mainCategory; private SubCategory subCategory; private String detailCategory; private String content; @BeforeEach void setUp() { mainCategory = DEPT_INTRO; subCategory = HISTORY; detailCategory = "test"; content = "testContent"; } // ... 테스트 메소드들 }aics-domain/src/testFixtures/java/mock/FakeAboutRepository.java (1)
16-17
: 동시성 처리 개선 제안
Collections.synchronizedList
와AtomicLong
을 사용한 동시성 처리는 좋은 접근이지만, 더 나은 성능을 위해ConcurrentHashMap
을 고려해 보세요.-private final List<About> data = Collections.synchronizedList(new ArrayList<>()); +private final Map<Long, About> data = new ConcurrentHashMap<>();aics-api/src/main/java/kgu/developers/api/about/application/AboutService.java (2)
Line range hint
34-39
: 카테고리 매핑 개선 제안카테고리 매핑을 별도의 설정 파일이나 enum 내부로 이동하는 것을 고려해 보세요. 현재 구현은 유지보수가 어려울 수 있습니다.
Line range hint
54-54
: System.out.println 제거 필요프로덕션 코드에서
System.out.println
을 제거하고 적절한 로깅 프레임워크를 사용하세요.-System.out.println(detail); +log.debug("Detail parameter: {}", detail);aics-api/src/main/java/kgu/developers/api/about/presentation/AboutController.java (1)
Line range hint
32-33
: API 버전 관리 전략 검토 필요URL에 버전을 하드코딩하는 대신 헤더 기반 버전 관리를 고려해 보세요.
aics-api/src/testFixtures/java/about/application/AboutServiceTest.java (2)
28-39
: 테스트 데이터 상수화 제안테스트의 가독성과 유지보수성을 높이기 위해 초기 테스트 데이터를 상수로 정의하는 것이 좋습니다.
다음과 같이 개선해보세요:
public class AboutServiceTest { + private static final String INIT_DETAIL = "initDetail"; + private static final String INIT_CONTENT = "initContent"; private AboutService aboutService; @BeforeEach public void init() { FakeAboutRepository fakeAboutRepository = new FakeAboutRepository(); this.aboutService = new AboutService(fakeAboutRepository); fakeAboutRepository.save(About.builder() .mainCategory(EDU_ACTIVITIES) .subCategory(CURRICULUM) - .detailCategory("initDetail") - .content("initContent") + .detailCategory(INIT_DETAIL) + .content(INIT_CONTENT) .build()); }
105-122
: updateAbout 테스트의 검증 강화 필요현재 테스트는 content 업데이트만 확인하고 있습니다. 다른 필드들이 변경되지 않았는지도 검증이 필요합니다.
다음과 같이 검증을 강화해보세요:
// then AboutResponse response = aboutService.getAbout(EDU_ACTIVITIES, CURRICULUM, "initDetail"); assertEquals(response.content(), "updateContent"); + assertEquals(response.mainCategory(), EDU_ACTIVITIES); + assertEquals(response.subCategory(), CURRICULUM); + assertEquals(response.detailCategory(), "initDetail");
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (8)
aics-api/src/main/java/kgu/developers/api/about/application/AboutService.java
(2 hunks)aics-api/src/main/java/kgu/developers/api/about/presentation/AboutController.java
(3 hunks)aics-api/src/main/java/kgu/developers/api/about/presentation/request/AboutRequest.java
(1 hunks)aics-api/src/main/java/kgu/developers/api/about/presentation/request/AboutUpdateRequest.java
(1 hunks)aics-api/src/testFixtures/java/about/application/AboutServiceTest.java
(1 hunks)aics-domain/src/testFixtures/java/about/application/AboutServiceTest.java
(1 hunks)aics-domain/src/testFixtures/java/about/domain/AboutDomainTest.java
(1 hunks)aics-domain/src/testFixtures/java/mock/FakeAboutRepository.java
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- aics-domain/src/testFixtures/java/about/application/AboutServiceTest.java
🔇 Additional comments (6)
aics-api/src/main/java/kgu/developers/api/about/presentation/request/AboutUpdateRequest.java (1)
9-14
: 구조가 잘 설계되었습니다!
레코드 클래스의 구조가 명확하고 간단하며, 필요한 유효성 검사와 문서화가 잘 되어 있습니다. Builder 패턴의 사용도 적절합니다.
aics-api/src/main/java/kgu/developers/api/about/presentation/request/AboutRequest.java (1)
10-12
: 필드 사용 여부 검토가 필요합니다.
AboutUpdateRequest
가 도입됨에 따라 AboutRequest
의 일부 필드들이 여전히 필요한지 검토가 필요합니다. 특히 content
필드가 두 클래스에 중복되어 있는 것으로 보입니다.
aics-domain/src/testFixtures/java/mock/FakeAboutRepository.java (2)
35-42
: 조회 메서드 구현이 잘 되었습니다
리포지토리 조회 메서드들이 스트림 API를 적절히 활용하여 깔끔하게 구현되었습니다.
Also applies to: 44-50, 52-57
29-29
: TestEntityUtils 사용 검증 필요
TestEntityUtils.setCreatedAt()
메서드의 구현을 확인하고 테스트해야 합니다.
✅ Verification successful
TestEntityUtils.setCreatedAt() 메서드 검증 완료
TestEntityUtils.setCreatedAt()
메서드는 다음과 같이 안전하게 구현되어 있습니다:
- null 체크를 통한 유효성 검사
- 리플렉션을 사용한 BaseTimeEntity의 createdAt 필드 설정
- 적절한 예외 처리
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# TestEntityUtils 구현 확인
rg -l "class TestEntityUtils"
Length of output: 91
Script:
#!/bin/bash
# TestEntityUtils.setCreatedAt() 메서드 구현 확인
rg -A 10 "setCreatedAt" aics-domain/src/testFixtures/java/mock/TestEntityUtils.java
Length of output: 566
aics-api/src/main/java/kgu/developers/api/about/application/AboutService.java (1)
71-76
: 예외 처리 개선 필요
updateContent
메서드 호출 시 발생할 수 있는 예외에 대한 처리가 필요합니다.
aics-api/src/main/java/kgu/developers/api/about/presentation/AboutController.java (1)
Line range hint 73-78
: 업데이트 API 구현이 깔끔합니다
AboutUpdateRequest
를 사용한 업데이트 구현이 명확하고 간단합니다. 응답 상태 코드도 적절히 사용되었습니다.
aics-api/src/testFixtures/java/about/application/AboutServiceTest.java
Outdated
Show resolved
Hide resolved
aics-api/src/testFixtures/java/about/application/AboutServiceTest.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.
LGTM 👍
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.
리뷰어로 등록이 되어있지 않아서 확인이 늦었습니다!
기존의 미흡했던 API 개선 해주셔서 감사해요 👍
Summary
Tasks
To Reviewer
categoryMatchCheck
메서드 수정기존 코드의 불필요한
return
을 제거하고 조건문을 간결하게 변경하여 가독성과 명확성을 높였습니다. 조건이 맞지 않을 경우 바로 예외를 던지는 구조로 개선하였습니다.updateAbout
메서드 수정수정 작업에는 content 필드만 필요하므로, 불필요한 데이터를 포함한 AboutRequest 대신 AboutUpdateRequest를 사용하도록 변경하였습니다. 또한, 생성(createAbout)과 수정(updateAbout)의 목적에 따라 요청 객체를 분리하여, 필요한 데이터만 포함하도록 설계함으로써 API의 명확성을 높이고 유지보수성을 강화했습니다.