Skip to content

Commit ac0f60e

Browse files
authored
refactor: Application 관련 통합 테스트 데이터 fixture 메서드로 변경 (#329)
* feat: ApplicationFixture에 지원서 생성 메서드 추가 * refactor: 지원서 데이터 Fixture 메서드로 변경 * refactor: 불필요한 성적 요구사항 세팅 제거
1 parent ab9092b commit ac0f60e

4 files changed

Lines changed: 468 additions & 227 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.example.solidconnection.application.fixture;
2+
3+
import com.example.solidconnection.application.domain.Application;
4+
import com.example.solidconnection.application.domain.Gpa;
5+
import com.example.solidconnection.application.domain.LanguageTest;
6+
import com.example.solidconnection.siteuser.domain.SiteUser;
7+
import com.example.solidconnection.university.domain.UniversityInfoForApply;
8+
import lombok.RequiredArgsConstructor;
9+
import org.springframework.boot.test.context.TestComponent;
10+
11+
@TestComponent
12+
@RequiredArgsConstructor
13+
public class ApplicationFixture {
14+
15+
private final ApplicationFixtureBuilder applicationFixtureBuilder;
16+
17+
public Application 지원서(
18+
SiteUser siteUser,
19+
String nicknameForApply,
20+
String term,
21+
Gpa gpa,
22+
LanguageTest languageTest,
23+
UniversityInfoForApply firstChoiceUniversity,
24+
UniversityInfoForApply secondChoiceUniversity,
25+
UniversityInfoForApply thirdChoiceUniversity
26+
) {
27+
return applicationFixtureBuilder.application()
28+
.siteUser(siteUser)
29+
.gpa(gpa)
30+
.languageTest(languageTest)
31+
.nicknameForApply(nicknameForApply)
32+
.term(term)
33+
.firstChoiceUniversity(firstChoiceUniversity)
34+
.secondChoiceUniversity(secondChoiceUniversity)
35+
.thirdChoiceUniversity(thirdChoiceUniversity)
36+
.create();
37+
}
38+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package com.example.solidconnection.application.fixture;
2+
3+
import com.example.solidconnection.application.domain.Application;
4+
import com.example.solidconnection.application.domain.Gpa;
5+
import com.example.solidconnection.application.domain.LanguageTest;
6+
import com.example.solidconnection.application.domain.VerifyStatus;
7+
import com.example.solidconnection.application.repository.ApplicationRepository;
8+
import com.example.solidconnection.siteuser.domain.SiteUser;
9+
import com.example.solidconnection.university.domain.UniversityInfoForApply;
10+
import lombok.RequiredArgsConstructor;
11+
import org.springframework.boot.test.context.TestComponent;
12+
13+
@TestComponent
14+
@RequiredArgsConstructor
15+
public class ApplicationFixtureBuilder {
16+
17+
private final ApplicationRepository applicationRepository;
18+
19+
private Gpa gpa;
20+
private LanguageTest languageTest;
21+
private UniversityInfoForApply firstChoiceUniversity;
22+
private UniversityInfoForApply secondChoiceUniversity;
23+
private UniversityInfoForApply thirdChoiceUniversity;
24+
private SiteUser siteUser;
25+
private String nicknameForApply;
26+
private String term;
27+
28+
public ApplicationFixtureBuilder application() {
29+
return new ApplicationFixtureBuilder(applicationRepository);
30+
}
31+
32+
public ApplicationFixtureBuilder gpa(Gpa gpa) {
33+
this.gpa = gpa;
34+
return this;
35+
}
36+
37+
public ApplicationFixtureBuilder languageTest(LanguageTest languageTest) {
38+
this.languageTest = languageTest;
39+
return this;
40+
}
41+
42+
public ApplicationFixtureBuilder firstChoiceUniversity(UniversityInfoForApply firstChoiceUniversity) {
43+
this.firstChoiceUniversity = firstChoiceUniversity;
44+
return this;
45+
}
46+
47+
public ApplicationFixtureBuilder secondChoiceUniversity(UniversityInfoForApply secondChoiceUniversity) {
48+
this.secondChoiceUniversity = secondChoiceUniversity;
49+
return this;
50+
}
51+
52+
public ApplicationFixtureBuilder thirdChoiceUniversity(UniversityInfoForApply thirdChoiceUniversity) {
53+
this.thirdChoiceUniversity = thirdChoiceUniversity;
54+
return this;
55+
}
56+
57+
public ApplicationFixtureBuilder siteUser(SiteUser siteUser) {
58+
this.siteUser = siteUser;
59+
return this;
60+
}
61+
62+
public ApplicationFixtureBuilder nicknameForApply(String nicknameForApply) {
63+
this.nicknameForApply = nicknameForApply;
64+
return this;
65+
}
66+
67+
public ApplicationFixtureBuilder term(String term) {
68+
this.term = term;
69+
return this;
70+
}
71+
72+
public Application create() {
73+
Application application = new Application(
74+
siteUser,
75+
gpa,
76+
languageTest,
77+
term,
78+
firstChoiceUniversity,
79+
secondChoiceUniversity,
80+
thirdChoiceUniversity,
81+
nicknameForApply
82+
);
83+
application.setVerifyStatus(VerifyStatus.APPROVED);
84+
return applicationRepository.save(application);
85+
}
86+
}

0 commit comments

Comments
 (0)