-
Notifications
You must be signed in to change notification settings - Fork 8
refactor: 대학 관련 통합 테스트 데이터 정의 구조 개선 #286
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
Merged
Gyuhyeok99
merged 18 commits into
solid-connection:develop
from
Gyuhyeok99:refactor/285-test-fixture-module
May 11, 2025
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
654233c
refactor: 메서드 체이닝으로 대학 test fixture 생성
Gyuhyeok99 094b7af
refactor: UniversityQueryServiceTest에 임시 반영
Gyuhyeok99 7f4923f
chore: 테스트 환경에서 lombok 사용을 위한 의존성 추가
Gyuhyeok99 14b77d2
test: 메서드 체이닝을 활용하여 대학 관련 Fixture 클래스 추가
Gyuhyeok99 3c3038c
test: 대학 생성을 위한 Fixture Helper 클래스 추가
Gyuhyeok99 89beba0
test: Fixture Helper 클래스 실제 대학 테스트에 적용
Gyuhyeok99 40808c2
chore: 사용하지 않는 BuilderSupporter 클래스 제거
Gyuhyeok99 e5308e4
refactor: 내가 생각한 방향 구현
nayonsoso 3553287
refactor: 테스트 코드 컴포넌트 @TestComponent로 변경
Gyuhyeok99 28ea0cb
refactor: 패키지 구조를 도메인 중심으로 개선
Gyuhyeok99 602e494
feat: RegionFixture에 지역 생성 메서드 추가
Gyuhyeok99 efa0012
feat: CountryFixture에 국가 생성 메서드 추가
Gyuhyeok99 d47db4c
feat: UniversityFixture에 대학 생성 메서드 추가
Gyuhyeok99 c0acfb1
feat: UniversityInfoForApplyFixture에 대학 지원 생성 메서드 추가
Gyuhyeok99 c3a822e
feat: LanguageRequirementFixture에 언어 요구사항 생성 메서드 추가
Gyuhyeok99 974f9eb
test: 추가한 Fixture 함수 테스트에 반영
Gyuhyeok99 02d3efa
chore: 대학 정보 이름 실제 데이터와 일치하게 반영
Gyuhyeok99 d757be8
refactor: 언어 요구사항 데이터 세팅 방식 변경
Gyuhyeok99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/test/java/com/example/solidconnection/country/fixture/CountryFixture.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package com.example.solidconnection.country.fixture; | ||
|
|
||
| import com.example.solidconnection.entity.Country; | ||
| import com.example.solidconnection.region.fixture.RegionFixture; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.boot.test.context.TestComponent; | ||
|
|
||
| @TestComponent | ||
| @RequiredArgsConstructor | ||
| public class CountryFixture { | ||
|
|
||
| private final RegionFixture regionFixture; | ||
| private final CountryFixtureBuilder countryFixtureBuilder; | ||
|
|
||
| public Country 미국() { | ||
| return countryFixtureBuilder.country() | ||
| .code("US") | ||
| .koreanName("미국") | ||
| .region(regionFixture.영미권()) | ||
| .findOrCreate(); | ||
| } | ||
|
|
||
| public Country 캐나다() { | ||
| return countryFixtureBuilder.country() | ||
| .code("CA") | ||
| .koreanName("캐나다") | ||
| .region(regionFixture.영미권()) | ||
| .findOrCreate(); | ||
| } | ||
|
|
||
| public Country 덴마크() { | ||
| return countryFixtureBuilder.country() | ||
| .code("DK") | ||
| .koreanName("덴마크") | ||
| .region(regionFixture.유럽()) | ||
| .findOrCreate(); | ||
| } | ||
|
|
||
| public Country 오스트리아() { | ||
| return countryFixtureBuilder.country() | ||
| .code("AT") | ||
| .koreanName("오스트리아") | ||
| .region(regionFixture.유럽()) | ||
| .findOrCreate(); | ||
| } | ||
|
|
||
| public Country 일본() { | ||
| return countryFixtureBuilder.country() | ||
| .code("JP") | ||
| .koreanName("일본") | ||
| .region(regionFixture.아시아()) | ||
| .findOrCreate(); | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
src/test/java/com/example/solidconnection/country/fixture/CountryFixtureBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package com.example.solidconnection.country.fixture; | ||
|
|
||
| import com.example.solidconnection.entity.Country; | ||
| import com.example.solidconnection.entity.Region; | ||
| import com.example.solidconnection.country.repository.CountryRepositoryForTest; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.boot.test.context.TestComponent; | ||
|
|
||
| @TestComponent | ||
| @RequiredArgsConstructor | ||
| public class CountryFixtureBuilder { | ||
|
|
||
| private final CountryRepositoryForTest countryRepositoryForTest; | ||
|
|
||
| private String code; | ||
| private String koreanName; | ||
| private Region region; | ||
|
|
||
| public CountryFixtureBuilder country() { | ||
| return new CountryFixtureBuilder(countryRepositoryForTest); | ||
| } | ||
|
|
||
| public CountryFixtureBuilder code(String code) { | ||
| this.code = code; | ||
| return this; | ||
| } | ||
|
|
||
| public CountryFixtureBuilder koreanName(String koreanName) { | ||
| this.koreanName = koreanName; | ||
| return this; | ||
| } | ||
|
|
||
| public CountryFixtureBuilder region(Region region) { | ||
| this.region = region; | ||
| return this; | ||
| } | ||
|
|
||
| public Country findOrCreate() { | ||
| return countryRepositoryForTest.findByCode(code) | ||
| .orElseGet(() -> countryRepositoryForTest.save(new Country(code, koreanName, region))); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/test/java/com/example/solidconnection/country/repository/CountryRepositoryForTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.example.solidconnection.country.repository; | ||
|
|
||
| import com.example.solidconnection.entity.Country; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface CountryRepositoryForTest extends JpaRepository<Country, Long> { | ||
|
|
||
| Optional<Country> findByCode(String code); | ||
| } |
33 changes: 33 additions & 0 deletions
33
src/test/java/com/example/solidconnection/region/fixture/RegionFixture.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.example.solidconnection.region.fixture; | ||
|
|
||
| import com.example.solidconnection.entity.Region; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.boot.test.context.TestComponent; | ||
|
|
||
| @TestComponent | ||
| @RequiredArgsConstructor | ||
| public class RegionFixture { | ||
|
|
||
| private final RegionFixtureBuilder regionFixtureBuilder; | ||
|
|
||
| public Region 영미권() { | ||
| return regionFixtureBuilder.region() | ||
| .code("AMERICAS") | ||
| .koreanName("영미권") | ||
| .findOrCreate(); | ||
| } | ||
|
|
||
| public Region 유럽() { | ||
| return regionFixtureBuilder.region() | ||
| .code("EUROPE") | ||
| .koreanName("유럽") | ||
| .findOrCreate(); | ||
| } | ||
|
|
||
| public Region 아시아() { | ||
| return regionFixtureBuilder.region() | ||
| .code("ASIA") | ||
| .koreanName("아시아") | ||
| .findOrCreate(); | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
src/test/java/com/example/solidconnection/region/fixture/RegionFixtureBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package com.example.solidconnection.region.fixture; | ||
|
|
||
| import com.example.solidconnection.entity.Region; | ||
| import com.example.solidconnection.region.repository.RegionRepositoryForTest; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.boot.test.context.TestComponent; | ||
|
|
||
| @TestComponent | ||
| @RequiredArgsConstructor | ||
| public class RegionFixtureBuilder { | ||
|
|
||
| private final RegionRepositoryForTest regionRepositoryForTest; | ||
|
|
||
| private String code; | ||
| private String koreanName; | ||
|
|
||
| public RegionFixtureBuilder region() { | ||
| return new RegionFixtureBuilder(regionRepositoryForTest); | ||
| } | ||
|
|
||
| public RegionFixtureBuilder code(String code) { | ||
| this.code = code; | ||
| return this; | ||
| } | ||
|
|
||
| public RegionFixtureBuilder koreanName(String koreanName) { | ||
| this.koreanName = koreanName; | ||
| return this; | ||
| } | ||
|
|
||
| public Region findOrCreate() { | ||
| return regionRepositoryForTest.findByCode(code) | ||
| .orElseGet(() -> regionRepositoryForTest.save(new Region(code, koreanName))); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/test/java/com/example/solidconnection/region/repository/RegionRepositoryForTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.example.solidconnection.region.repository; | ||
|
|
||
| import com.example.solidconnection.entity.Region; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface RegionRepositoryForTest extends JpaRepository<Region, Long> { | ||
|
|
||
| Optional<Region> findByCode(String code); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/test/java/com/example/solidconnection/university/fixture/LanguageRequirementFixture.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package com.example.solidconnection.university.fixture; | ||
|
|
||
| import com.example.solidconnection.type.LanguageTestType; | ||
| import com.example.solidconnection.university.domain.LanguageRequirement; | ||
| import com.example.solidconnection.university.domain.UniversityInfoForApply; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.boot.test.context.TestComponent; | ||
|
|
||
| @TestComponent | ||
| @RequiredArgsConstructor | ||
| public class LanguageRequirementFixture { | ||
|
|
||
| private final LanguageRequirementFixtureBuilder languageRequirementFixtureBuilder; | ||
|
|
||
| public LanguageRequirement 토플_80(UniversityInfoForApply universityInfo) { | ||
| return languageRequirementFixtureBuilder | ||
| .languageTestType(LanguageTestType.TOEFL_IBT) | ||
| .minScore("80") | ||
| .universityInfoForApply(universityInfo) | ||
| .create(); | ||
| } | ||
|
|
||
| public LanguageRequirement 토플_70(UniversityInfoForApply universityInfo) { | ||
| return languageRequirementFixtureBuilder | ||
| .languageTestType(LanguageTestType.TOEFL_IBT) | ||
| .minScore("70") | ||
| .universityInfoForApply(universityInfo) | ||
| .create(); | ||
| } | ||
|
|
||
| public LanguageRequirement 토익_800(UniversityInfoForApply universityInfo) { | ||
| return languageRequirementFixtureBuilder | ||
| .languageTestType(LanguageTestType.TOEIC) | ||
| .minScore("800") | ||
| .universityInfoForApply(universityInfo) | ||
| .create(); | ||
| } | ||
|
|
||
| public LanguageRequirement 토익_900(UniversityInfoForApply universityInfo) { | ||
| return languageRequirementFixtureBuilder | ||
| .languageTestType(LanguageTestType.TOEIC) | ||
| .minScore("900") | ||
| .universityInfoForApply(universityInfo) | ||
| .create(); | ||
| } | ||
|
|
||
| public LanguageRequirement JLPT_N2(UniversityInfoForApply universityInfo) { | ||
| return languageRequirementFixtureBuilder | ||
| .languageTestType(LanguageTestType.JLPT) | ||
| .minScore("N2") | ||
| .universityInfoForApply(universityInfo) | ||
| .create(); | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
...ava/com/example/solidconnection/university/fixture/LanguageRequirementFixtureBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package com.example.solidconnection.university.fixture; | ||
|
|
||
| import com.example.solidconnection.type.LanguageTestType; | ||
| import com.example.solidconnection.university.domain.LanguageRequirement; | ||
| import com.example.solidconnection.university.domain.UniversityInfoForApply; | ||
| import com.example.solidconnection.university.repository.LanguageRequirementRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.boot.test.context.TestComponent; | ||
|
|
||
| @TestComponent | ||
| @RequiredArgsConstructor | ||
| public class LanguageRequirementFixtureBuilder { | ||
|
|
||
| private final LanguageRequirementRepository languageRequirementRepository; | ||
|
|
||
| private LanguageTestType languageTestType; | ||
| private String minScore; | ||
| private UniversityInfoForApply universityInfoForApply; | ||
|
|
||
| public LanguageRequirementFixtureBuilder languageTestType(LanguageTestType languageTestType) { | ||
| this.languageTestType = languageTestType; | ||
| return this; | ||
| } | ||
|
|
||
| public LanguageRequirementFixtureBuilder minScore(String minScore) { | ||
| this.minScore = minScore; | ||
| return this; | ||
| } | ||
|
|
||
| public LanguageRequirementFixtureBuilder universityInfoForApply(UniversityInfoForApply universityInfoForApply) { | ||
| this.universityInfoForApply = universityInfoForApply; | ||
| return this; | ||
| } | ||
|
|
||
| public LanguageRequirement create() { | ||
| LanguageRequirement languageRequirement = new LanguageRequirement( | ||
| null, | ||
| languageTestType, | ||
| minScore, | ||
| universityInfoForApply | ||
| ); | ||
| universityInfoForApply.addLanguageRequirements(languageRequirement); | ||
| return languageRequirementRepository.save(languageRequirement); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.