[DDING-125-2] 섹션 여러 개일 경우 사용자 폼지 조회 수정#296
Conversation
Walkthrough이번 변경사항은 두 개의 파일에 걸쳐 메서드 시그니처와 상수 사용을 단순화하는 리팩토링 작업입니다. Changes
Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches
🪧 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
Documentation and Community
|
KoSeonJe
left a comment
There was a problem hiding this comment.
테스트 코드 한번 작성해보면 좋을 것 같아요..!
MonkeyFixture를 연관관계 주입되는 엔터티에만 안쓰면 에러안나드라구요!
넵 알겠습니다! 작성해보겠습니다! |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/test/java/ddingdong/ddingdongBE/domain/form/service/FacadeUserFormServiceImplTest.java (1)
93-107: 폼 조회 테스트가 정확하게 구현되었습니다.특정 섹션의 폼 필드를 조회하는 기능이 잘 구현되어 있습니다. 다만, 테스트 커버리지를 향상시킬 수 있는 몇 가지 제안사항이 있습니다:
- 현재는 첫 번째 섹션에 대한 테스트만 있습니다. 두 번째 섹션에 대한 테스트도 추가하면 좋을 것 같습니다.
- 존재하지 않는 섹션을 요청했을 때의 처리(예외 발생 또는 빈 결과 반환)에 대한 테스트 케이스를 추가하면 좋을 것 같습니다.
- 현재 테스트는 첫 번째 폼 필드만 확인하고 있는데, 모든 폼 필드가 올바르게 반환되는지 검증할 수 있습니다.
@DisplayName("다른 섹션 선택 시 해당 섹션의 폼 필드만 조회된다.") @Test void getFormWithDifferentSection() { // given FormField savedFormField1 = createFormField("질문1", 1, savedSections.get(0), savedForm); FormField savedFormField2 = createFormField("질문2", 2, savedSections.get(1), savedForm); String selectedSection = savedSections.get(1); // when UserFormQuery userFormQuery = facadeUserFormService.getUserForm(savedForm.getId(), selectedSection); // then assertThat(userFormQuery.formFields()).hasSize(1); assertThat(userFormQuery.formFields().get(0).id()).isEqualTo(savedFormField2.getId()); } @DisplayName("존재하지 않는 섹션을 요청할 경우 빈 폼 필드 목록이 반환된다.") @Test void getFormWithNonExistingSection() { // given FormField savedFormField1 = createFormField("질문1", 1, savedSections.get(0), savedForm); FormField savedFormField2 = createFormField("질문2", 2, savedSections.get(1), savedForm); String nonExistingSection = "non-existing-section"; // when UserFormQuery userFormQuery = facadeUserFormService.getUserForm(savedForm.getId(), nonExistingSection); // then assertThat(userFormQuery.formFields()).isEmpty(); }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/test/java/ddingdong/ddingdongBE/domain/form/service/FacadeUserFormServiceImplTest.java(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build and analyze
🔇 Additional comments (3)
src/test/java/ddingdong/ddingdongBE/domain/form/service/FacadeUserFormServiceImplTest.java (3)
45-79: 데이터 설정 방식이 명확하고 가독성이 좋습니다.테스트 데이터 설정 코드가 명확하고 이해하기 쉽게 구성되어 있습니다. FixtureMonkey 대신 Builder 패턴을 사용하여 엔티티를 명시적으로 생성한 것이 좋습니다.
다만, 몇 가지 개선할 수 있는 부분이 있습니다:
- 엔티티 ID를 명시적으로 설정(1L)하는 것보다 데이터베이스의 자동 생성 기능을 활용하는 것이 더 자연스러울 수 있습니다.
- Club 엔티티에서 여러 필드를 명시적으로 null로 설정하는 것보다 빈 컬렉션이나 기본값을 사용하는 것이 좋습니다.
- User user = User.builder() - .id(1L) - .role(Role.CLUB) - .build(); + User user = User.builder() + .role(Role.CLUB) + .build(); - Club club = Club.builder() - .id(1L) - .user(savedUser) - .score(null) - .clubMembers(null) - .deletedAt(null) - .build(); + Club club = Club.builder() + .user(savedUser) + .build();
81-91: 테스트 코드가 간결하고 목적이 명확합니다.Given-When-Then 구조가 명확하고, 섹션 조회 기능을 잘 검증하고 있습니다.
109-119: 폼 필드 생성 헬퍼 메서드가 잘 구현되었습니다.폼 필드를 생성하는 헬퍼 메서드가 테스트 코드를 간결하게 만들어주고 있습니다.
|
(cherry picked from commit 62024ba)



🚀 작업 내용
섹션 여러 개일 경우 사용자 폼지 조회 기능 수정하였습니다.
🤔 고민했던 내용
💬 리뷰 중점사항
Summary by CodeRabbit