Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -24,7 +24,7 @@ public class HostUniversity extends BaseEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false, length = 100)
@Column(nullable = false, unique = true, length = 100)
private String koreanName;

@Column(nullable = false, length = 100)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE host_university
ADD CONSTRAINT uk_host_university_korean_name UNIQUE (korean_name);
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void setUp() {
mentorApplication8 = mentorApplicationFixture.거절된_멘토신청(user8.getId(), UniversitySelectType.OTHER, null);

user = siteUserFixture.사용자(9, "test9");
university = universityFixture.메이지_대학();
university = universityFixture.네바다주립_대학_라스베이거스();
}

@Nested
Expand Down Expand Up @@ -468,7 +468,7 @@ class 멘토_지원서에_대학_매핑 {
void OTHER_타입의_멘토_지원서에_대학을_매핑하면_대학이_할당되고_타입이_CATALOG로_변경된다() {
// given
long otherTypeMentorApplicationId = mentorApplication7.getId();
HostUniversity university = universityFixture.메이지_대학();
HostUniversity university = universityFixture.아칸소_주립_대학();

// when
adminMentorApplicationService.assignUniversity(otherTypeMentorApplicationId, university.getId());
Expand All @@ -485,7 +485,7 @@ class 멘토_지원서에_대학_매핑 {
void 존재하지_않는_멘토_지원서에_대학을_매핑하면_예외_응답을_반환한다() {
// given
long nonExistentId = 99999L;
HostUniversity university = universityFixture.메이지_대학();
HostUniversity university = universityFixture.메모리얼_대학_세인트존스();

// when & then
assertThatCode(() -> adminMentorApplicationService.assignUniversity(nonExistentId, university.getId()))
Expand All @@ -497,7 +497,7 @@ class 멘토_지원서에_대학_매핑 {
void CATALOG_타입의_멘토_지원서에_대학을_매핑하면_예외_응답을_반환한다() {
// given
long catalogTypeMentorApplicationId = mentorApplication2.getId();
HostUniversity university = universityFixture.메이지_대학();
HostUniversity university = universityFixture.서던덴마크_대학();

// when & then
assertThatCode(() -> adminMentorApplicationService.assignUniversity(catalogTypeMentorApplicationId, university.getId()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ApplicationQueryServiceTest {
private LanguageTestScore languageTestScore3;

private UnivApplyInfo 괌대학_A_지원_정보;
private UnivApplyInfo 괌대학_B_지원_정보;
private UnivApplyInfo 버지니아공과대학_지원_정보;
private UnivApplyInfo 서던덴마크대학교_지원_정보;

private Term term;
Expand All @@ -94,7 +94,7 @@ void setUp() {
languageTestScore3 = languageTestScoreFixture.어학_점수(VerifyStatus.APPROVED, user3);

괌대학_A_지원_정보 = univApplyInfoFixture.괌대학_A_지원_정보(term.getId());
괌대학_B_지원_정보 = univApplyInfoFixture.괌대학_B_지원_정보(term.getId());
버지니아공과대학_지원_정보 = univApplyInfoFixture.버지니아공과대학_지원_정보(term.getId());
서던덴마크대학교_지원_정보 = univApplyInfoFixture.서던덴마크대학교_지원_정보(term.getId());
}

Expand All @@ -120,7 +120,7 @@ class 지원자_목록_조회_테스트 {
term.getId(),
gpaScore2.getGpa(),
languageTestScore2.getLanguageTest(),
괌대학_B_지원_정보.getId(),
버지니아공과대학_지원_정보.getId(),
null,
null
);
Expand All @@ -146,7 +146,7 @@ class 지원자_목록_조회_테스트 {
assertThat(response.firstChoice()).containsAll(List.of(
ApplicantsResponse.of(괌대학_A_지원_정보,
List.of(application1), user1),
ApplicantsResponse.of(괌대학_B_지원_정보,
ApplicantsResponse.of(버지니아공과대학_지원_정보,
List.of(application2), user1),
ApplicantsResponse.of(서던덴마크대학교_지원_정보,
List.of(application3), user1)
Expand All @@ -172,7 +172,7 @@ class 지원자_목록_조회_테스트 {
term.getId(),
gpaScore2.getGpa(),
languageTestScore2.getLanguageTest(),
괌대학_B_지원_정보.getId(),
버지니아공과대학_지원_정보.getId(),
null,
null
);
Expand All @@ -198,7 +198,7 @@ class 지원자_목록_조회_테스트 {
assertThat(response.firstChoice()).containsExactlyInAnyOrder(
ApplicantsResponse.of(괌대학_A_지원_정보,
List.of(application1), user1),
ApplicantsResponse.of(괌대학_B_지원_정보,
ApplicantsResponse.of(버지니아공과대학_지원_정보,
List.of(application2), user1)
);
}
Expand All @@ -222,7 +222,7 @@ class 지원자_목록_조회_테스트 {
term.getId(),
gpaScore2.getGpa(),
languageTestScore2.getLanguageTest(),
괌대학_B_지원_정보.getId(),
버지니아공과대학_지원_정보.getId(),
null,
null
);
Expand All @@ -241,14 +241,14 @@ class 지원자_목록_조회_테스트 {
ApplicationsResponse response = applicationQueryService.getApplicants(
user1.getId(),
null,
""
"미국"
);

// then
assertThat(response.firstChoice()).containsExactlyInAnyOrder(
ApplicantsResponse.of(괌대학_A_지원_정보,
List.of(application1), user1),
ApplicantsResponse.of(괌대학_B_지원_정보,
ApplicantsResponse.of(버지니아공과대학_지원_정보,
List.of(application2), user1)
);
}
Expand Down Expand Up @@ -289,7 +289,7 @@ class 지원자_목록_조회_테스트 {
// then
assertThat(response.firstChoice()).containsExactlyInAnyOrder(
ApplicantsResponse.of(괌대학_A_지원_정보, List.of(currentApplication), user1),
ApplicantsResponse.of(괌대학_B_지원_정보, List.of(), user1),
ApplicantsResponse.of(버지니아공과대학_지원_정보, List.of(), user1),
ApplicantsResponse.of(서던덴마크대학교_지원_정보, List.of(), user1)
);
}
Expand All @@ -315,7 +315,7 @@ class 지원자_목록_조회_테스트 {
term.getId(),
gpaScore1.getGpa(),
languageTestScore1.getLanguageTest(),
괌대학_B_지원_정보.getId(),
버지니아공과대학_지원_정보.getId(),
null,
null
);
Expand Down Expand Up @@ -401,7 +401,7 @@ class 경쟁자_목록_조회_테스트 {
gpaScore2.getGpa(),
languageTestScore2.getLanguageTest(),
괌대학_A_지원_정보.getId(),
괌대학_B_지원_정보.getId(),
버지니아공과대학_지원_정보.getId(),
서던덴마크대학교_지원_정보.getId()
);
Application application3 = applicationFixture.지원서(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ApplicationSubmissionServiceTest {

private SiteUser user;
private UnivApplyInfo 괌대학_A_지원_정보;
private UnivApplyInfo 괌대학_B_지원_정보;
private UnivApplyInfo 버지니아공과대학_지원_정보;
private UnivApplyInfo 서던덴마크대학교_지원_정보;

private Term term;
Expand All @@ -69,7 +69,7 @@ void setUp() {

user = siteUserFixture.사용자();
괌대학_A_지원_정보 = univApplyInfoFixture.괌대학_A_지원_정보(term.getId());
괌대학_B_지원_정보 = univApplyInfoFixture.괌대학_B_지원_정보(term.getId());
버지니아공과대학_지원_정보 = univApplyInfoFixture.버지니아공과대학_지원_정보(term.getId());
서던덴마크대학교_지원_정보 = univApplyInfoFixture.서던덴마크대학교_지원_정보(term.getId());
}

Expand All @@ -80,7 +80,7 @@ void setUp() {
LanguageTestScore languageTestScore = languageTestScoreFixture.어학_점수(VerifyStatus.APPROVED, user);
UnivApplyInfoChoiceRequest univApplyInfoChoiceRequest = new UnivApplyInfoChoiceRequest(
괌대학_A_지원_정보.getId(),
괌대학_B_지원_정보.getId(),
버지니아공과대학_지원_정보.getId(),
서던덴마크대학교_지원_정보.getId()
);
ApplyRequest request = new ApplyRequest(gpaScore.getId(), languageTestScore.getId(), univApplyInfoChoiceRequest);
Expand All @@ -98,7 +98,7 @@ void setUp() {
() -> assertThat(response.appliedUniversities().firstChoiceUnivApplyInfo())
.isEqualTo(괌대학_A_지원_정보.getKoreanName()),
() -> assertThat(response.appliedUniversities().secondChoiceUnivApplyInfo())
.isEqualTo(괌대학_B_지원_정보.getKoreanName()),
.isEqualTo(버지니아공과대학_지원_정보.getKoreanName()),
() -> assertThat(response.appliedUniversities().thirdChoiceUnivApplyInfo())
.isEqualTo(서던덴마크대학교_지원_정보.getKoreanName()),
() -> assertThat(savedApplication.getVerifyStatus())
Expand All @@ -108,7 +108,7 @@ void setUp() {
() -> assertThat(savedApplication.getFirstChoiceUnivApplyInfoId())
.isEqualTo(괌대학_A_지원_정보.getId()),
() -> assertThat(savedApplication.getSecondChoiceUnivApplyInfoId())
.isEqualTo(괌대학_B_지원_정보.getId()),
.isEqualTo(버지니아공과대학_지원_정보.getId()),
() -> assertThat(savedApplication.getThirdChoiceUnivApplyInfoId())
.isEqualTo(서던덴마크대학교_지원_정보.getId())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void setUp() {
SiteUser mentorUser1 = siteUserFixture.사용자(2, "멘토1");
SiteUser mentorUser2 = siteUserFixture.사용자(3, "멘토2");
asiaUniversity = universityFixture.메이지_대학();
europeUniversity = universityFixture.린츠_카톨릭_대학();
europeUniversity = universityFixture.그라츠공과_대학();
asiaMentor = mentorFixture.멘토(mentorUser1.getId(), asiaUniversity.getId());
europeMentor = mentorFixture.멘토(mentorUser2.getId(), europeUniversity.getId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.example.solidconnection.term.fixture.TermFixture;
import com.example.solidconnection.university.domain.LikedUnivApplyInfo;
import com.example.solidconnection.university.domain.HostUniversity;
import com.example.solidconnection.university.domain.UnivApplyInfo;
import com.example.solidconnection.university.fixture.UnivApplyInfoFixture;
import com.example.solidconnection.university.repository.LikedUnivApplyInfoRepository;
import java.time.LocalDateTime;
Expand Down Expand Up @@ -105,11 +106,20 @@ class MyPageServiceTest {

private SiteUser user;
private Term term;
private Long 괌대학_A_지원_정보_ID;
private Long 메이지대학_지원_정보_ID;
private Long 코펜하겐IT대학_지원_정보_ID;
private HostUniversity 괌대학;

@BeforeEach
void setUp() {
user = siteUserFixture.사용자();
term = termFixture.현재_학기("2025-2");
UnivApplyInfo 괌대학_A_지원_정보 = univApplyInfoFixture.괌대학_A_지원_정보(term.getId());
괌대학_A_지원_정보_ID = 괌대학_A_지원_정보.getId();
괌대학 = 괌대학_A_지원_정보.getUniversity();
메이지대학_지원_정보_ID = univApplyInfoFixture.메이지대학_지원_정보(term.getId()).getId();
코펜하겐IT대학_지원_정보_ID = univApplyInfoFixture.코펜하겐IT대학_지원_정보(term.getId()).getId();
}

@Test
Expand Down Expand Up @@ -141,8 +151,7 @@ void setUp() {
void 멘토의_마이페이지_정보를_조회한다() {
// given
SiteUser mentorUser = siteUserFixture.멘토(1, "mentor");
HostUniversity university = univApplyInfoFixture.괌대학_A_지원_정보(term.getId()).getUniversity();
mentorFixture.멘토(mentorUser.getId(), university.getId());
mentorFixture.멘토(mentorUser.getId(), 괌대학.getId());
int likedUnivApplyInfoCount = createLikedUnivApplyInfos(mentorUser);

// when
Expand All @@ -157,15 +166,15 @@ void setUp() {
// () -> assertThat(response.likedPostCount()).isEqualTo(user.getLikedPostList().size()),
// todo : 좋아요한 게시물 수 반환 기능 추가와 함께 수정요망
() -> assertThat(response.likedUnivApplyInfoCount()).isEqualTo(likedUnivApplyInfoCount),
() -> assertThat(response.attendedUniversity()).isEqualTo(university.getKoreanName()),
() -> assertThat(response.attendedUniversity()).isEqualTo(괌대학.getKoreanName()),
() -> assertThat(response.interestedCountries()).isNull()
);
}

private int createLikedUnivApplyInfos(SiteUser testUser) {
LikedUnivApplyInfo likedUnivApplyInfo1 = new LikedUnivApplyInfo(null, univApplyInfoFixture.괌대학_A_지원_정보(term.getId()).getId(), testUser.getId());
LikedUnivApplyInfo likedUnivApplyInfo2 = new LikedUnivApplyInfo(null, univApplyInfoFixture.메이지대학_지원_정보(term.getId()).getId(), testUser.getId());
LikedUnivApplyInfo likedUnivApplyInfo3 = new LikedUnivApplyInfo(null, univApplyInfoFixture.코펜하겐IT대학_지원_정보(term.getId()).getId(), testUser.getId());
LikedUnivApplyInfo likedUnivApplyInfo1 = new LikedUnivApplyInfo(null, 괌대학_A_지원_정보_ID, testUser.getId());
LikedUnivApplyInfo likedUnivApplyInfo2 = new LikedUnivApplyInfo(null, 메이지대학_지원_정보_ID, testUser.getId());
LikedUnivApplyInfo likedUnivApplyInfo3 = new LikedUnivApplyInfo(null, 코펜하겐IT대학_지원_정보_ID, testUser.getId());

likedUnivApplyInfoRepository.save(likedUnivApplyInfo1);
likedUnivApplyInfoRepository.save(likedUnivApplyInfo2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public class UnivApplyInfoFixture {
.create();
}

public UnivApplyInfo 괌대학_B_지원_정보(long termId) {
public UnivApplyInfo 버지니아공과대학_지원_정보(long termId) {
return univApplyInfoFixtureBuilder.univApplyInfo()
.termId(termId)
.koreanName("괌대학(B형)")
.university(universityFixture.괌_대학())
.koreanName("버지니아공과대학")
.university(universityFixture.버지니아_공과_대학())
.homeUniversity(homeUniversityFixture.인하대학교())
.create();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,13 @@ public final class UniversityFixture {
.region(regionFixture.아시아())
.create();
}

public HostUniversity 버지니아_공과_대학() {
return universityFixtureBuilder.university()
.koreanName("버지니아 공과 대학")
.englishName("Virginia Tech")
.country(countryFixture.미국())
.region(regionFixture.영미권())
.create();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
import com.example.solidconnection.location.country.domain.Country;
import com.example.solidconnection.location.region.domain.Region;
import com.example.solidconnection.university.domain.HostUniversity;
import com.example.solidconnection.university.repository.HostUniversityRepository;
import com.example.solidconnection.university.repository.HostUniversityRepositoryForTest;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.test.context.TestComponent;

@TestComponent
@RequiredArgsConstructor
public class UniversityFixtureBuilder {

private final HostUniversityRepository hostUniversityRepository;
private final HostUniversityRepositoryForTest hostUniversityRepositoryForTest;

private String koreanName;
private String englishName;
private Country country;
private Region region;

public UniversityFixtureBuilder university() {
return new UniversityFixtureBuilder(hostUniversityRepository);
return new UniversityFixtureBuilder(hostUniversityRepositoryForTest);
}

public UniversityFixtureBuilder koreanName(String koreanName) {
Expand Down Expand Up @@ -53,6 +53,6 @@ public HostUniversity create() {
"https://background-image-url",
null, country, region
);
return hostUniversityRepository.save(university);
return hostUniversityRepositoryForTest.save(university);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.solidconnection.university.repository;

import com.example.solidconnection.university.domain.HostUniversity;
import org.springframework.data.jpa.repository.JpaRepository;

public interface HostUniversityRepositoryForTest extends JpaRepository<HostUniversity, Long> {
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

Choose a reason for hiding this comment

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

아마 유니크키를 달면서 중복생성하면 예외가 터지니 존재하면 find하도록 바꾸신 거 같은데 맞나요?

Copy link
Member Author

Choose a reason for hiding this comment

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

맞습니다 ! 테스트 코드에서 korean_name이 같은 객체를 생성해서 존재하면 이미 존재하는 객체를 가져오도록 했습니다.

지금 다시 생각해보니, 그냥 애초에 korean_name 이 같은 객체가 존재하지 않도록 변경하는 것이 더 좋을 거 같아 그렇게 수정했습니다.

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void setUp() {
term = termFixture.현재_학기("2025-2");

univApplyInfoFixture.괌대학_A_지원_정보(term.getId());
univApplyInfoFixture.괌대학_B_지원_정보(term.getId());
univApplyInfoFixture.버지니아공과대학_지원_정보(term.getId());
univApplyInfoFixture.네바다주립대학_라스베이거스_지원_정보(term.getId());
univApplyInfoFixture.메모리얼대학_세인트존스_A_지원_정보(term.getId());
univApplyInfoFixture.서던덴마크대학교_지원_정보(term.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class 각각의_검색_대상에_대해_검색한다 {
// given
String text = "미국";
UnivApplyInfo 괌대학_A_지원_정보 = univApplyInfoFixture.괌대학_A_지원_정보(term.getId());
UnivApplyInfo 괌대학_B_지원_정보 = univApplyInfoFixture.괌대학_B_지원_정보(term.getId());
UnivApplyInfo 버지니아공과대학_지원_정보 = univApplyInfoFixture.버지니아공과대학_지원_정보(term.getId());
univApplyInfoFixture.메이지대학_지원_정보(term.getId());

// when
Expand All @@ -148,7 +148,7 @@ class 각각의_검색_대상에_대해_검색한다 {
assertThat(response.univApplyInfoPreviews())
.containsExactly(
UnivApplyInfoPreviewResponse.of(괌대학_A_지원_정보, term.getName()),
UnivApplyInfoPreviewResponse.of(괌대학_B_지원_정보, term.getName())
UnivApplyInfoPreviewResponse.of(버지니아공과대학_지원_정보, term.getName())
);
}

Expand Down
Loading
Loading