Skip to content

Commit 4ac62fc

Browse files
committed
[#71] refactor: 테스트 코드 수정
멤버 변수 -> 지역 변수로 변경
1 parent e1033b5 commit 4ac62fc

File tree

1 file changed

+26
-36
lines changed

1 file changed

+26
-36
lines changed

jaknaeso-core/src/test/java/org/nexters/jaknaesocore/domain/character/service/CharacterServiceTest.java

+26-36
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.math.BigDecimal;
88
import java.util.List;
99
import org.junit.jupiter.api.AfterEach;
10-
import org.junit.jupiter.api.BeforeEach;
1110
import org.junit.jupiter.api.DisplayName;
1211
import org.junit.jupiter.api.Nested;
1312
import org.junit.jupiter.api.Test;
@@ -68,45 +67,36 @@ void shouldThrowException() {
6867
@DisplayName("유저를 찾으면")
6968
class whenMemberFound {
7069

71-
private static final List<KeywordScore> scores =
72-
List.of(
73-
KeywordScore.builder().keyword(Keyword.SELF_DIRECTION).score(BigDecimal.ONE).build(),
74-
KeywordScore.builder().keyword(Keyword.STABILITY).score(BigDecimal.TWO).build());
75-
76-
private SurveyBundle bundle;
77-
private Survey survey;
78-
79-
private SurveyOption createSurveyOption(final Survey survey, final String content) {
80-
return surveyOptionRepository.save(
81-
SurveyOption.builder().survey(survey).content(content).scores(scores).build());
82-
}
83-
84-
private SurveySubmission createSurveySubmission(
85-
final Member member, final Survey survey, final SurveyOption option) {
86-
return SurveySubmission.builder()
87-
.member(member)
88-
.survey(survey)
89-
.selectedOption(option)
90-
.build();
91-
}
92-
93-
@BeforeEach
94-
void setUp() {
95-
bundle = surveyBundleRepository.save(new SurveyBundle());
96-
survey =
97-
surveyRepository.save(
98-
new BalanceSurvey(
99-
"꿈에 그리던 드림 기업에 입사했다. 연봉도 좋지만, 무엇보다 회사의 근무 방식이 나와 잘 맞는 것 같다. 우리 회사의 근무 방식은...",
100-
bundle));
101-
}
102-
10370
@Test
10471
@DisplayName("회원의 캐릭터 리스트를 반환한다.")
10572
void shouldReturnQuestions() {
10673
final Member member = memberRepository.save(Member.create("홍길동", "[email protected]"));
107-
final SurveyOption option = createSurveyOption(survey, "자율 출퇴근제로 원하는 시간에 근무하며 창의적인 성과 내기");
108-
109-
surveySubmissionRepository.save(createSurveySubmission(member, survey, option));
74+
final SurveyBundle bundle = surveyBundleRepository.save(new SurveyBundle());
75+
final Survey survey =
76+
surveyRepository.save(
77+
new BalanceSurvey(
78+
"꿈에 그리던 드림 기업에 입사했다. 연봉도 좋지만, 무엇보다 회사의 근무 방식이 나와 잘 맞는 것 같다. 우리 회사의 근무 방식은...",
79+
bundle));
80+
final List<KeywordScore> scores =
81+
List.of(
82+
KeywordScore.builder()
83+
.keyword(Keyword.SELF_DIRECTION)
84+
.score(BigDecimal.ONE)
85+
.build(),
86+
KeywordScore.builder().keyword(Keyword.STABILITY).score(BigDecimal.TWO).build());
87+
final SurveyOption option =
88+
surveyOptionRepository.save(
89+
SurveyOption.builder()
90+
.survey(survey)
91+
.content("자율 출퇴근제로 원하는 시간에 근무하며 창의적인 성과 내기")
92+
.scores(scores)
93+
.build());
94+
surveySubmissionRepository.save(
95+
SurveySubmission.builder()
96+
.member(member)
97+
.survey(survey)
98+
.selectedOption(option)
99+
.build());
110100

111101
List<CharacterResponse> actual = sut.getCharacters(member.getId());
112102

0 commit comments

Comments
 (0)