Skip to content

Commit

Permalink
test: develop 브랜치 머치 후, 미변경 사항 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
Kimprodp committed Sep 7, 2024
1 parent d3a615c commit 610b785
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 133 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class 필수가_아닌_답변에_응답하지_않았을_때 {
);

// when
TemplateAnswerResponse reviewDetail = reviewDetailLookupService.getReviewDetail(
ReviewDetailResponse reviewDetail = reviewDetailLookupService.getReviewDetail(
review.getId(), reviewRequestCode, groupAccessCode
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ class ReviewListLookupServiceTest {
@Autowired
private QuestionRepository questionRepository;

@Autowired
private QuestionRepository questionRepository;

@Autowired
private ReviewGroupRepository reviewGroupRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
import static reviewme.fixture.OptionGroupFixture.선택지_그룹;
import static reviewme.fixture.OptionItemFixture.선택지;
import static reviewme.fixture.QuestionFixture.서술형_필수_질문;
import static reviewme.fixture.QuestionFixture.선택형_필수_질문;
import static reviewme.fixture.ReviewGroupFixture.리뷰_그룹;
import static reviewme.fixture.SectionFixture.조건부로_보이는_섹션;
import static reviewme.fixture.SectionFixture.항상_보이는_섹션;
import static reviewme.fixture.TemplateFixture.템플릿;

import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import reviewme.fixture.OptionGroupFixture;
import reviewme.fixture.OptionItemFixture;
import reviewme.fixture.QuestionFixture;
import reviewme.fixture.ReviewGroupFixture;
import reviewme.fixture.SectionFixture;
import reviewme.fixture.TemplateFixture;
import reviewme.question.domain.OptionGroup;
import reviewme.question.domain.OptionItem;
import reviewme.question.domain.Question;
Expand Down Expand Up @@ -59,40 +61,28 @@ class ReviewRegisterServiceTest {
@Autowired
private SectionRepository sectionRepository;


private ReviewGroupFixture reviewGroupFixture = new ReviewGroupFixture();
private OptionItemFixture optionItemFixture = new OptionItemFixture();
private OptionGroupFixture optionGroupFixture = new OptionGroupFixture();
private QuestionFixture questionFixture = new QuestionFixture();
private SectionFixture sectionFixture = new SectionFixture();
private TemplateFixture templateFixture = new TemplateFixture();


@Test
void 요청한_내용으로_리뷰를_등록한다() {
// given
ReviewGroup reviewGroup = reviewGroupRepository.save(reviewGroupFixture.리뷰_그룹());

Question requiredCheckQuestion = questionRepository.save(questionFixture.선택형_필수_질문());
OptionGroup requiredOptionGroup = optionGroupRepository.save(optionGroupFixture.선택지_그룹(requiredCheckQuestion.getId()));
OptionItem requiredOptionItem1 = optionItemRepository.save(optionItemFixture.선택지(requiredOptionGroup.getId()));
OptionItem requiredOptionItem2 = optionItemRepository.save(optionItemFixture.선택지(requiredOptionGroup.getId()));
Section visibleSection = sectionRepository.save(sectionFixture.항상_보이는_섹션(List.of(requiredCheckQuestion.getId()), 1));

Question requiredTextQuestion = questionRepository.save(questionFixture.서술형_필수_질문());
Question conditionalCheckQuestion = questionRepository.save(questionFixture.선택형_필수_질문());
OptionGroup conditionalOptionGroup = optionGroupRepository.save(optionGroupFixture.선택지_그룹(conditionalCheckQuestion.getId()));
OptionItem conditionalOptionItem1 = optionItemRepository.save(optionItemFixture.선택지(conditionalOptionGroup.getId()));
OptionItem conditionalOptionItem2 = optionItemRepository.save(optionItemFixture.선택지(conditionalOptionGroup.getId()));
Section conditionalSection = sectionRepository.save(sectionFixture.조건부로_보이는_섹션(
List.of(requiredCheckQuestion.getId(), requiredTextQuestion.getId(), conditionalCheckQuestion.getId()), requiredOptionItem1.getId(), 2)
ReviewGroup reviewGroup = reviewGroupRepository.save(리뷰_그룹());

Question requiredCheckQuestion = questionRepository.save(선택형_필수_질문());
OptionGroup requiredOptionGroup = optionGroupRepository.save(선택지_그룹(requiredCheckQuestion.getId()));
OptionItem requiredOptionItem1 = optionItemRepository.save(선택지(requiredOptionGroup.getId()));
OptionItem requiredOptionItem2 = optionItemRepository.save(선택지(requiredOptionGroup.getId()));
Section visibleSection = sectionRepository.save(항상_보이는_섹션(List.of(requiredCheckQuestion.getId()), 1));

Question requiredTextQuestion = questionRepository.save(서술형_필수_질문());
Question conditionalCheckQuestion = questionRepository.save(선택형_필수_질문());
OptionGroup conditionalOptionGroup = optionGroupRepository.save(선택지_그룹(conditionalCheckQuestion.getId()));
OptionItem conditionalOptionItem1 = optionItemRepository.save(선택지(conditionalOptionGroup.getId()));
OptionItem conditionalOptionItem2 = optionItemRepository.save(선택지(conditionalOptionGroup.getId()));
Section conditionalSection = sectionRepository.save(조건부로_보이는_섹션(
List.of(requiredCheckQuestion.getId(), requiredTextQuestion.getId(), conditionalCheckQuestion.getId()),
requiredOptionItem1.getId(), 2)
);


Template template = templateRepository.save(templateFixture.템플릿(
List.of(visibleSection.getId(), conditionalSection.getId())
));

Template template = templateRepository.save(템플릿(List.of(visibleSection.getId(), conditionalSection.getId())));

ReviewAnswerRequest requiredCheckQuestionAnswer = new ReviewAnswerRequest(
requiredCheckQuestion.getId(), List.of(requiredOptionItem1.getId()), null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package reviewme.review.service;
package reviewme.review.service.module;

import static org.assertj.core.api.Assertions.assertThatCode;
import static reviewme.fixture.OptionGroupFixture.선택지_그룹;
import static reviewme.fixture.OptionItemFixture.선택지;
import static reviewme.fixture.QuestionFixture.선택형_필수_질문;

import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import reviewme.fixture.OptionGroupFixture;
import reviewme.fixture.QuestionFixture;
import reviewme.fixture.OptionGroupFixture;
import reviewme.fixture.OptionItemFixture;
import reviewme.question.domain.OptionGroup;
import reviewme.question.domain.OptionItem;
import reviewme.question.domain.OptionType;
import reviewme.question.domain.Question;
import reviewme.question.repository.OptionGroupRepository;
import reviewme.question.repository.OptionItemRepository;
Expand Down Expand Up @@ -51,7 +48,7 @@ class CheckBoxAnswerValidatorTest {
}

@Test
void 저장되지_않은_옵션그룹의_답변이면_예외가_발생한다() {
void 옵션_그룹이_지정되지_않은_질문에_대한_답변이면_예외가_발생한다() {
// given
Question savedQuestion = questionRepository.save(선택형_필수_질문());
CheckboxAnswer checkboxAnswer = new CheckboxAnswer(savedQuestion.getId(), List.of(1L));
Expand All @@ -65,8 +62,8 @@ class CheckBoxAnswerValidatorTest {
void 옵션그룹에서_제공하지_않은_옵션아이템을_응답하면_예외가_발생한다() {
// given
Question savedQuestion = questionRepository.save(선택형_필수_질문());
OptionGroup savedOptionGroup = optionGroupRepository.save(OptionGroupFixture.선택지_그룹(savedQuestion.getId()));
OptionItem savedOptionItem = optionItemRepository.save(OptionItemFixture.선택지(savedOptionGroup.getId()));
OptionGroup savedOptionGroup = optionGroupRepository.save(선택지_그룹(savedQuestion.getId()));
OptionItem savedOptionItem = optionItemRepository.save(선택지(savedOptionGroup.getId()));

CheckboxAnswer checkboxAnswer = new CheckboxAnswer(savedQuestion.getId(),
List.of(savedOptionItem.getId() + 1L));
Expand All @@ -83,9 +80,7 @@ class CheckBoxAnswerValidatorTest {
OptionGroup savedOptionGroup = optionGroupRepository.save(
new OptionGroup(savedQuestion.getId(), 2, 3)
);
OptionItem savedOptionItem1 = optionItemRepository.save(
new OptionItem("옵션1", savedOptionGroup.getId(), 1, OptionType.KEYWORD)
);
OptionItem savedOptionItem1 = optionItemRepository.save(선택지(savedOptionGroup.getId()));

CheckboxAnswer checkboxAnswer = new CheckboxAnswer(savedQuestion.getId(), List.of(savedOptionItem1.getId()));

Expand All @@ -101,12 +96,8 @@ class CheckBoxAnswerValidatorTest {
OptionGroup savedOptionGroup = optionGroupRepository.save(
new OptionGroup(savedQuestion.getId(), 1, 1)
);
OptionItem savedOptionItem1 = optionItemRepository.save(
new OptionItem("옵션1", savedOptionGroup.getId(), 1, OptionType.KEYWORD)
);
OptionItem savedOptionItem2 = optionItemRepository.save(
new OptionItem("옵션2", savedOptionGroup.getId(), 2, OptionType.KEYWORD)
);
OptionItem savedOptionItem1 = optionItemRepository.save(선택지(savedOptionGroup.getId(), 1));
OptionItem savedOptionItem2 = optionItemRepository.save(선택지(savedOptionGroup.getId(), 2));

CheckboxAnswer checkboxAnswer = new CheckboxAnswer(
savedQuestion.getId(), List.of(savedOptionItem1.getId(), savedOptionItem2.getId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static reviewme.fixture.OptionGroupFixture.선택지_그룹;
import static reviewme.fixture.OptionItemFixture.선택지;
import static reviewme.fixture.QuestionFixture.서술형_필수_질문;
import static reviewme.fixture.QuestionFixture.선택형_필수_질문;
import static reviewme.fixture.ReviewGroupFixture.리뷰_그룹;
import static reviewme.fixture.SectionFixture.항상_보이는_섹션;
import static reviewme.fixture.TemplateFixture.템플릿;

import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import reviewme.fixture.OptionGroupFixture;
import reviewme.fixture.OptionItemFixture;
import reviewme.fixture.QuestionFixture;
import reviewme.fixture.ReviewGroupFixture;
import reviewme.fixture.SectionFixture;
import reviewme.fixture.TemplateFixture;
import reviewme.question.domain.OptionGroup;
import reviewme.question.domain.OptionItem;
import reviewme.question.domain.Question;
Expand Down Expand Up @@ -54,21 +55,14 @@ class ReviewMapperTest {
@Autowired
private TemplateRepository templateRepository;

private ReviewGroupFixture reviewGroupFixture = new ReviewGroupFixture();
private OptionItemFixture optionItemFixture = new OptionItemFixture();
private OptionGroupFixture optionGroupFixture = new OptionGroupFixture();
private QuestionFixture questionFixture = new QuestionFixture();
private SectionFixture sectionFixture = new SectionFixture();
private TemplateFixture templateFixture = new TemplateFixture();

@Test
void 텍스트가_포함된_리뷰를_생성한다() {
// given
ReviewGroup reviewGroup = reviewGroupRepository.save(reviewGroupFixture.리뷰_그룹());
ReviewGroup reviewGroup = reviewGroupRepository.save(리뷰_그룹());

Question question = questionRepository.save(questionFixture.서술형_필수_질문());
Section section = sectionRepository.save(sectionFixture.항상_보이는_섹션(List.of(question.getId())));
templateRepository.save(templateFixture.템플릿(List.of(section.getId())));
Question question = questionRepository.save(서술형_필수_질문());
Section section = sectionRepository.save(항상_보이는_섹션(List.of(question.getId())));
templateRepository.save(템플릿(List.of(section.getId())));

String expectedTextAnswer = "답".repeat(20);
ReviewAnswerRequest reviewAnswerRequest = new ReviewAnswerRequest(question.getId(), null, expectedTextAnswer);
Expand All @@ -84,15 +78,15 @@ class ReviewMapperTest {
@Test
void 체크박스가_포함된_리뷰를_생성한다() {
// given
ReviewGroup reviewGroup = reviewGroupRepository.save(reviewGroupFixture.리뷰_그룹());
ReviewGroup reviewGroup = reviewGroupRepository.save(리뷰_그룹());

Question question = questionRepository.save(questionFixture.선택형_필수_질문());
OptionGroup optionGroup = optionGroupRepository.save(optionGroupFixture.선택지_그룹(question.getId()));
OptionItem optionItem1 = optionItemRepository.save(optionItemFixture.선택지(optionGroup.getId()));
OptionItem optionItem2 = optionItemRepository.save(optionItemFixture.선택지(optionGroup.getId()));
Question question = questionRepository.save(선택형_필수_질문());
OptionGroup optionGroup = optionGroupRepository.save(선택지_그룹(question.getId()));
OptionItem optionItem1 = optionItemRepository.save(선택지(optionGroup.getId()));
OptionItem optionItem2 = optionItemRepository.save(선택지(optionGroup.getId()));

Section section = sectionRepository.save(sectionFixture.항상_보이는_섹션(List.of(question.getId())));
templateRepository.save(templateFixture.템플릿(List.of(section.getId())));
Section section = sectionRepository.save(항상_보이는_섹션(List.of(question.getId())));
templateRepository.save(템플릿(List.of(section.getId())));

ReviewAnswerRequest reviewAnswerRequest = new ReviewAnswerRequest(question.getId(), List.of(optionItem1.getId()), null);
ReviewRegisterRequest reviewRegisterRequest = new ReviewRegisterRequest(reviewGroup.getReviewRequestCode(), List.of(reviewAnswerRequest));
Expand All @@ -108,7 +102,7 @@ class ReviewMapperTest {
void 잘못된_리뷰_요청_코드로_리뷰를_생성할_경우_예외가_발생한다() {
// given
String reviewRequestCode = "notExistCode";
Question savedQuestion = questionRepository.save(questionFixture.서술형_필수_질문());
Question savedQuestion = questionRepository.save(서술형_필수_질문());
ReviewAnswerRequest emptyTextReviewRequest = new ReviewAnswerRequest(
savedQuestion.getId(), null, "");
ReviewRegisterRequest reviewRegisterRequest = new ReviewRegisterRequest(
Expand All @@ -123,11 +117,11 @@ class ReviewMapperTest {
@Test
void 답변에_해당하는_질문이_없는_리뷰를_생성할_경우_예외가_발생한다() {
// given
ReviewGroup reviewGroup = reviewGroupRepository.save(reviewGroupFixture.리뷰_그룹());
ReviewGroup reviewGroup = reviewGroupRepository.save(리뷰_그룹());

Question question = questionRepository.save(questionFixture.서술형_필수_질문());
Section section = sectionRepository.save(sectionFixture.항상_보이는_섹션(List.of(question.getId())));
templateRepository.save(templateFixture.템플릿(List.of(section.getId())));
Question question = questionRepository.save(서술형_필수_질문());
Section section = sectionRepository.save(항상_보이는_섹션(List.of(question.getId())));
templateRepository.save(템플릿(List.of(section.getId())));

long notSavedQuestionId = 100L;
ReviewAnswerRequest notQuestionAnswerRequest = new ReviewAnswerRequest(
Expand Down
Loading

0 comments on commit 610b785

Please sign in to comment.