Skip to content
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

[BE] feat: 섹션 이름 조회 API 구현 #801

Merged
merged 5 commits into from
Oct 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static reviewme.fixture.ReviewGroupFixture.리뷰_그룹;
import static reviewme.fixture.SectionFixture.조건부로_보이는_섹션;
import static reviewme.fixture.SectionFixture.항상_보이는_섹션;
import static reviewme.fixture.TemplateFixture.템플릿;

import java.util.List;
Expand All @@ -15,7 +13,7 @@
import reviewme.reviewgroup.repository.ReviewGroupRepository;
import reviewme.support.ServiceTest;
import reviewme.template.domain.Section;
import reviewme.template.domain.Template;
import reviewme.template.domain.VisibleType;
import reviewme.template.repository.SectionRepository;
import reviewme.template.repository.TemplateRepository;
import reviewme.template.service.dto.response.SectionNameResponse;
Expand All @@ -39,20 +37,24 @@ class SectionServiceTest {
@Test
void 템플릿에_있는_섹션_이름_목록을_응답한다() {
// given
Section visibleSection1 = sectionRepository.save(항상_보이는_섹션(List.of(1L), 1));
Section visibleSection2 = sectionRepository.save(항상_보이는_섹션(List.of(2L), 2));
Section nonVisibleSection = sectionRepository.save(조건부로_보이는_섹션(List.of(3L), 1L, 3));
Template template = templateRepository.save(템플릿(
List.of(nonVisibleSection.getId(), visibleSection2.getId(), visibleSection1.getId())));
Section visibleSection1 = sectionRepository.save(
new Section(VisibleType.ALWAYS, List.of(1L), null, "섹션1", "헤더", 1));
Section visibleSection2 = sectionRepository.save(
new Section(VisibleType.ALWAYS, List.of(2L), null, "섹션2", "헤더", 2));
Section nonVisibleSection = sectionRepository.save(
new Section(VisibleType.CONDITIONAL, List.of(1L), 1L, "섹션3", "헤더", 3));
templateRepository.save(
템플릿(List.of(nonVisibleSection.getId(), visibleSection2.getId(), visibleSection1.getId())));

ReviewGroup reviewGroup = reviewGroupRepository.save(리뷰_그룹());

// when
SectionNamesResponse actual = sectionService.getSectionNames(reviewGroup.getReviewRequestCode());

// then
assertThat(actual.sections()).extracting(SectionNameResponse::id)
.containsExactly(visibleSection1.getId(), visibleSection2.getId(), nonVisibleSection.getId());
assertThat(actual.sections()).extracting(SectionNameResponse::name)
.containsExactly(visibleSection1.getSectionName(), visibleSection2.getSectionName(),
nonVisibleSection.getSectionName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repository에 저장한 걸로 검증하는 거라, 조금 더 명확하게 할 거면 저장하기 전에 섹션 이름을 미리 뽑아 놓고 검증하는 게 더 알맞으려나요? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

검증하려는 부분이 섹션 이름이니 강조할 수 있게 맨 상단에 따로 빼는 것이 가독성이 더 좋겠네요~
바로 반영했슴다👍

}

@Test
Expand Down