From baf96bd75825c678ad5cf7afa3bd06d259b67c0f Mon Sep 17 00:00:00 2001 From: seokjin8678 Date: Wed, 10 Apr 2024 01:14:17 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=97=94=ED=8B=B0=ED=8B=B0=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EC=9E=90=20=ED=94=BD=EC=8A=A4=EC=B3=90=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EB=B0=8F=20=EC=9D=BC=EB=B6=80=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EA=B0=80=EB=8F=85=EC=84=B1=20=ED=96=A5=EC=83=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/festago/member/domain/Member.java | 4 - ...ageCountV1QueryServiceIntegrationTest.java | 125 +++++++++++------- ...stSearchV1QueryServiceIntegrationTest.java | 31 ++--- .../ArtistBookmarkCommandServiceTest.java | 16 ++- .../FestivalBookmarkCommandServiceTest.java | 10 +- .../SchoolBookmarkCommandServiceTest.java | 26 +++- .../repository/MemberFCMRepositoryTest.java | 4 +- ...stivalQueryInfoArtistRenewServiceTest.java | 12 +- .../command/FestivalDeleteServiceTest.java | 4 +- .../FestivalSearchV1QueryServiceTest.java | 8 +- .../application/StudentServiceTest.java | 2 +- .../ticketing/domain/MemberTicketTest.java | 4 +- 12 files changed, 154 insertions(+), 92 deletions(-) diff --git a/backend/src/main/java/com/festago/member/domain/Member.java b/backend/src/main/java/com/festago/member/domain/Member.java index e8d64f922..6a338fe4b 100644 --- a/backend/src/main/java/com/festago/member/domain/Member.java +++ b/backend/src/main/java/com/festago/member/domain/Member.java @@ -63,10 +63,6 @@ public class Member extends BaseTimeEntity { private LocalDateTime deletedAt = null; - public Member(Long id) { - this.id = id; - } - public Member(String socialId, SocialType socialType, String nickname, String profileImage) { this(null, socialId, socialType, nickname, profileImage); } diff --git a/backend/src/test/java/com/festago/artist/application/integration/ArtistSearchStageCountV1QueryServiceIntegrationTest.java b/backend/src/test/java/com/festago/artist/application/integration/ArtistSearchStageCountV1QueryServiceIntegrationTest.java index d7a2fd474..e4c568b5f 100644 --- a/backend/src/test/java/com/festago/artist/application/integration/ArtistSearchStageCountV1QueryServiceIntegrationTest.java +++ b/backend/src/test/java/com/festago/artist/application/integration/ArtistSearchStageCountV1QueryServiceIntegrationTest.java @@ -7,21 +7,22 @@ import com.festago.artist.domain.Artist; import com.festago.artist.dto.ArtistSearchStageCountV1Response; import com.festago.artist.repository.ArtistRepository; -import com.festago.festival.domain.Festival; import com.festago.festival.repository.FestivalRepository; -import com.festago.school.domain.School; import com.festago.school.domain.SchoolRegion; import com.festago.school.repository.SchoolRepository; import com.festago.stage.domain.Stage; -import com.festago.stage.domain.StageArtist; import com.festago.stage.repository.StageArtistRepository; import com.festago.stage.repository.StageRepository; import com.festago.support.ApplicationIntegrationTest; +import com.festago.support.fixture.ArtistFixture; +import com.festago.support.fixture.FestivalFixture; +import com.festago.support.fixture.SchoolFixture; +import com.festago.support.fixture.StageArtistFixture; +import com.festago.support.fixture.StageFixture; +import java.time.Clock; import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.LocalTime; import java.util.List; -import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; @@ -34,22 +35,25 @@ class ArtistSearchStageCountV1QueryServiceIntegrationTest extends ApplicationIntegrationTest { @Autowired - private ArtistSearchStageCountV1QueryService artistSearchStageCountV1QueryService; + ArtistSearchStageCountV1QueryService artistSearchStageCountV1QueryService; @Autowired - private FestivalRepository festivalRepository; + FestivalRepository festivalRepository; @Autowired - private ArtistRepository artistRepository; + ArtistRepository artistRepository; @Autowired - private StageRepository stageRepository; + StageRepository stageRepository; @Autowired - private StageArtistRepository stageArtistRepository; + StageArtistRepository stageArtistRepository; @Autowired - private SchoolRepository schoolRepository; + SchoolRepository schoolRepository; + + @Autowired + Clock clock; @Nested class 검색 { @@ -57,72 +61,99 @@ class 검색 { Artist 아이유; Artist 아이브; Artist 아이들; - Stage 어제_공연; - Stage 오늘_공연; - Stage 내일_공연; - LocalDate today = LocalDate.now(); - School school; + Stage _6월_15일_공연; + Stage _6월_16일_공연; + Stage _6월_17일_공연; + LocalDate _6월_15일 = LocalDate.parse("2077-06-15"); + LocalDate _6월_16일 = LocalDate.parse("2077-06-16"); + LocalDate _6월_17일 = LocalDate.parse("2077-06-17"); @BeforeEach void setUp() { - 아이유 = artistRepository.save(new Artist("아이유", "www.IU-profileImage.png")); - 아이브 = artistRepository.save(new Artist("아이브", "www.IVE-profileImage.png")); - 아이들 = artistRepository.save(new Artist("아이들", "www.Idle-profileImage.png")); - school = schoolRepository.save(new School("knu.ac.kr", "경북대", SchoolRegion.대구)); - var festivalA = festivalRepository.save( - new Festival("축제", today.minusDays(1), today.plusDays(10L), school)); - - var yesterdayDateTime = LocalDateTime.of(festivalA.getStartDate(), LocalTime.MIN); - 어제_공연 = stageRepository.save(new Stage(yesterdayDateTime, yesterdayDateTime.minusHours(1), festivalA)); - 오늘_공연 = stageRepository.save( - new Stage(yesterdayDateTime.plusDays(1), yesterdayDateTime.minusHours(1), festivalA)); - 내일_공연 = stageRepository.save( - new Stage(yesterdayDateTime.plusDays(2), yesterdayDateTime.minusHours(1), festivalA)); + 아이유 = artistRepository.save(ArtistFixture.builder().name("아이유").build()); + 아이브 = artistRepository.save(ArtistFixture.builder().name("아이브").build()); + 아이들 = artistRepository.save(ArtistFixture.builder().name("아이들").build()); + var school = schoolRepository.save( + SchoolFixture.builder() + .domain("knu.ac.kr") + .name("경북대") + .region(SchoolRegion.대구) + .build() + ); + var festival = festivalRepository.save( + FestivalFixture.builder() + .name("축제") + .startDate(_6월_15일) + .endDate(_6월_17일) + .school(school) + .build() + ); + + _6월_15일_공연 = stageRepository.save(StageFixture.builder() + .startTime(_6월_15일.atStartOfDay()) + .festival(festival) + .build() + ); + _6월_16일_공연 = stageRepository.save(StageFixture.builder() + .startTime(_6월_16일.atStartOfDay()) + .festival(festival) + .build() + ); + _6월_17일_공연 = stageRepository.save(StageFixture.builder() + .startTime(_6월_17일.atStartOfDay()) + .festival(festival) + .build() + ); } @Test void 아티스트의_당일_및_예정_공연_갯수를_조회한다() { // given - saveStageArtist(아이유, 오늘_공연); + LocalDateTime today = _6월_16일.atStartOfDay(); + + saveStageArtist(아이유, _6월_16일_공연); var 아이유_공연_갯수 = new ArtistSearchStageCountV1Response(1, 0); - saveStageArtist(아이브, 오늘_공연); - saveStageArtist(아이브, 내일_공연); + saveStageArtist(아이브, _6월_16일_공연); + saveStageArtist(아이브, _6월_17일_공연); var 아이브_공연_갯수 = new ArtistSearchStageCountV1Response(1, 1); - saveStageArtist(아이들, 어제_공연); - saveStageArtist(아이들, 내일_공연); + saveStageArtist(아이들, _6월_15일_공연); + saveStageArtist(아이들, _6월_17일_공연); var 아이들_공연_갯수 = new ArtistSearchStageCountV1Response(0, 1); - List artistIds = List.of(아이브.getId(), 아이유.getId(), 아이들.getId()); - // when - Map actual = artistSearchStageCountV1QueryService.findArtistsStageCountAfterDateTime( - artistIds, today.atStartOfDay()); + List artistIds = List.of(아이브.getId(), 아이유.getId(), 아이들.getId()); + var actual = artistSearchStageCountV1QueryService.findArtistsStageCountAfterDateTime( + artistIds, today + ); assertSoftly(softly -> { - softly.assertThat(actual.get(아이유.getId())).isEqualTo(아이유_공연_갯수); - softly.assertThat(actual.get(아이브.getId())).isEqualTo(아이브_공연_갯수); - softly.assertThat(actual.get(아이들.getId())).isEqualTo(아이들_공연_갯수); + softly.assertThat(actual).containsEntry(아이유.getId(), 아이유_공연_갯수); + softly.assertThat(actual).containsEntry(아이브.getId(), 아이브_공연_갯수); + softly.assertThat(actual).containsEntry(아이들.getId(), 아이들_공연_갯수); }); } @Test void 아티스트가_오늘_이후_공연이_없으면_0개() { - saveStageArtist(아이브, 어제_공연); - List artistIds = List.of(아이브.getId()); + LocalDateTime today = _6월_16일.atStartOfDay(); + + saveStageArtist(아이브, _6월_15일_공연); var 아이브_공연_갯수 = new ArtistSearchStageCountV1Response(0, 0); // when - Map actual = artistSearchStageCountV1QueryService.findArtistsStageCountAfterDateTime( - artistIds, today.atStartOfDay()); + List artistIds = List.of(아이브.getId()); + var actual = artistSearchStageCountV1QueryService.findArtistsStageCountAfterDateTime( + artistIds, today + ); // then - assertThat(actual.get(아이브.getId())).isEqualTo(아이브_공연_갯수); + assertThat(actual).containsEntry(아이브.getId(), 아이브_공연_갯수); } } private void saveStageArtist(Artist artist, Stage stage) { - stageArtistRepository.save(new StageArtist(stage.getId(), artist.getId())); + stageArtistRepository.save(StageArtistFixture.builder(stage.getId(), artist.getId()).build()); } } diff --git a/backend/src/test/java/com/festago/artist/application/integration/ArtistSearchV1QueryServiceIntegrationTest.java b/backend/src/test/java/com/festago/artist/application/integration/ArtistSearchV1QueryServiceIntegrationTest.java index 79f92582c..b1836c3e8 100644 --- a/backend/src/test/java/com/festago/artist/application/integration/ArtistSearchV1QueryServiceIntegrationTest.java +++ b/backend/src/test/java/com/festago/artist/application/integration/ArtistSearchV1QueryServiceIntegrationTest.java @@ -10,6 +10,7 @@ import com.festago.artist.repository.ArtistRepository; import com.festago.common.exception.BadRequestException; import com.festago.support.ApplicationIntegrationTest; +import com.festago.support.fixture.ArtistFixture; import java.util.List; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; @@ -29,9 +30,9 @@ class ArtistSearchV1QueryServiceIntegrationTest extends ApplicationIntegrationTe @Test void 검색어가_한글자면_동등검색을_한다() { // given - artistRepository.save(new Artist("난못", "www.profileImage.png")); - artistRepository.save(new Artist("못난", "www.profileImage.png")); - artistRepository.save(new Artist("못", "www.profileImage.png")); + artistRepository.save(ArtistFixture.builder().name("난못").build()); + artistRepository.save(ArtistFixture.builder().name("못난").build()); + artistRepository.save(ArtistFixture.builder().name("못").build()); // when List actual = artistSearchV1QueryService.findAllByKeyword("못"); @@ -46,12 +47,12 @@ class ArtistSearchV1QueryServiceIntegrationTest extends ApplicationIntegrationTe @Test void 검색어가_두글자_이상이면_like검색을_한다() { // given - artistRepository.save(new Artist("에이핑크", "www.profileImage.png")); - artistRepository.save(new Artist("블랙핑크", "www.profileImage.png")); - artistRepository.save(new Artist("핑크", "www.profileImage.png")); - artistRepository.save(new Artist("핑크 플로이드", "www.profileImage.png")); - artistRepository.save(new Artist("핑", "www.profileImage.png")); - artistRepository.save(new Artist("크", "www.profileImage.png")); + artistRepository.save(ArtistFixture.builder().name("에이핑크").build()); + artistRepository.save(ArtistFixture.builder().name("블랙핑크").build()); + artistRepository.save(ArtistFixture.builder().name("핑크").build()); + artistRepository.save(ArtistFixture.builder().name("핑크 플로이드").build()); + artistRepository.save(ArtistFixture.builder().name("핑").build()); + artistRepository.save(ArtistFixture.builder().name("크").build()); // when List actual = artistSearchV1QueryService.findAllByKeyword("핑크"); @@ -63,10 +64,10 @@ class ArtistSearchV1QueryServiceIntegrationTest extends ApplicationIntegrationTe @Test void 아티스트명은_영어_한국어_순으로_오름차순_정렬된다() { // given - Artist 세번째 = artistRepository.save(new Artist("가_아티스트", "www.profileImage.png")); - Artist 첫번째 = artistRepository.save(new Artist("A_아티스트", "www.profileImage.png")); - Artist 네번째 = artistRepository.save(new Artist("나_아티스트", "www.profileImage.png")); - Artist 두번째 = artistRepository.save(new Artist("C_아티스트", "www.profileImage.png")); + Artist 가_아티스트 = artistRepository.save(ArtistFixture.builder().name("가_아티스트").build()); + Artist A_아티스트 = artistRepository.save(ArtistFixture.builder().name("A_아티스트").build()); + Artist 나_아티스트 = artistRepository.save(ArtistFixture.builder().name("나_아티스트").build()); + Artist C_아티스트 = artistRepository.save(ArtistFixture.builder().name("C_아티스트").build()); // when List actual = artistSearchV1QueryService.findAllByKeyword("아티스트"); @@ -75,14 +76,14 @@ class ArtistSearchV1QueryServiceIntegrationTest extends ApplicationIntegrationTe List result = actual.stream() .map(ArtistSearchV1Response::id) .toList(); - assertThat(result).isEqualTo(List.of(첫번째.getId(), 두번째.getId(), 세번째.getId(), 네번째.getId())); + assertThat(result).isEqualTo(List.of(A_아티스트.getId(), C_아티스트.getId(), 가_아티스트.getId(), 나_아티스트.getId())); } @Test void 검색결과가_10개_이상이면_예외() { // given for (int i = 0; i < 10; i++) { - artistRepository.save(new Artist("핑크", "www.profileImage.png")); + artistRepository.save(ArtistFixture.builder().name("핑크").build()); } // when && then diff --git a/backend/src/test/java/com/festago/bookmark/application/command/ArtistBookmarkCommandServiceTest.java b/backend/src/test/java/com/festago/bookmark/application/command/ArtistBookmarkCommandServiceTest.java index 731d7ec8c..e44bca38b 100644 --- a/backend/src/test/java/com/festago/bookmark/application/command/ArtistBookmarkCommandServiceTest.java +++ b/backend/src/test/java/com/festago/bookmark/application/command/ArtistBookmarkCommandServiceTest.java @@ -6,7 +6,6 @@ import com.festago.artist.domain.Artist; import com.festago.artist.repository.ArtistRepository; import com.festago.artist.repository.MemoryArtistRepository; -import com.festago.bookmark.domain.Bookmark; import com.festago.bookmark.domain.BookmarkType; import com.festago.bookmark.repository.BookmarkRepository; import com.festago.bookmark.repository.MemoryBookmarkRepository; @@ -14,6 +13,7 @@ import com.festago.common.exception.ErrorCode; import com.festago.common.exception.NotFoundException; import com.festago.support.fixture.ArtistFixture; +import com.festago.support.fixture.BookmarkFixture; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; @@ -61,7 +61,13 @@ class 북마크_저장 { // given for (int i = 0; i < 12; i++) { Artist artist = artistRepository.save(ArtistFixture.builder().build()); - bookmarkRepository.save(new Bookmark(BookmarkType.ARTIST, artist.getId(), 회원_식별자)); + bookmarkRepository.save( + BookmarkFixture.builder() + .bookmarkType(BookmarkType.ARTIST) + .resourceId(artist.getId()) + .memberId(회원_식별자) + .build() + ); } // when & then @@ -100,7 +106,11 @@ class 북마크_삭제 { @Test void 북마크를_삭제한다() { // given - bookmarkRepository.save(new Bookmark(BookmarkType.ARTIST, 브라운.getId(), 회원_식별자)); + bookmarkRepository.save(BookmarkFixture.builder() + .bookmarkType(BookmarkType.ARTIST) + .resourceId(브라운.getId()) + .memberId(회원_식별자) + .build()); // when artistBookmarkCommandService.delete(브라운.getId(), 회원_식별자); diff --git a/backend/src/test/java/com/festago/bookmark/application/command/FestivalBookmarkCommandServiceTest.java b/backend/src/test/java/com/festago/bookmark/application/command/FestivalBookmarkCommandServiceTest.java index b76029be8..d07c870b8 100644 --- a/backend/src/test/java/com/festago/bookmark/application/command/FestivalBookmarkCommandServiceTest.java +++ b/backend/src/test/java/com/festago/bookmark/application/command/FestivalBookmarkCommandServiceTest.java @@ -4,7 +4,6 @@ import static org.assertj.core.api.Assertions.assertThatNoException; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import com.festago.bookmark.domain.Bookmark; import com.festago.bookmark.domain.BookmarkType; import com.festago.bookmark.repository.BookmarkRepository; import com.festago.bookmark.repository.MemoryBookmarkRepository; @@ -14,6 +13,7 @@ import com.festago.festival.domain.Festival; import com.festago.festival.repository.FestivalRepository; import com.festago.festival.repository.MemoryFestivalRepository; +import com.festago.support.fixture.BookmarkFixture; import com.festago.support.fixture.FestivalFixture; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; @@ -58,7 +58,13 @@ class 북마크_저장 { // given for (long i = 1; i <= 12; i++) { Festival festival = festivalRepository.save(FestivalFixture.builder().build()); - bookmarkRepository.save(new Bookmark(BookmarkType.FESTIVAL, festival.getId(), 회원_식별자)); + bookmarkRepository.save( + BookmarkFixture.builder() + .bookmarkType(BookmarkType.FESTIVAL) + .resourceId(festival.getId()) + .memberId(회원_식별자) + .build() + ); } // when & then diff --git a/backend/src/test/java/com/festago/bookmark/application/command/SchoolBookmarkCommandServiceTest.java b/backend/src/test/java/com/festago/bookmark/application/command/SchoolBookmarkCommandServiceTest.java index 46ce00ca2..504112e5e 100644 --- a/backend/src/test/java/com/festago/bookmark/application/command/SchoolBookmarkCommandServiceTest.java +++ b/backend/src/test/java/com/festago/bookmark/application/command/SchoolBookmarkCommandServiceTest.java @@ -3,7 +3,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import com.festago.bookmark.domain.Bookmark; import com.festago.bookmark.domain.BookmarkType; import com.festago.bookmark.repository.BookmarkRepository; import com.festago.bookmark.repository.MemoryBookmarkRepository; @@ -13,6 +12,7 @@ import com.festago.school.domain.School; import com.festago.school.repository.MemorySchoolRepository; import com.festago.school.repository.SchoolRepository; +import com.festago.support.fixture.BookmarkFixture; import com.festago.support.fixture.SchoolFixture; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; @@ -53,7 +53,13 @@ class 학교_북마크_추가시 { // given for (long i = 0; i < 12; i++) { School school = schoolRepository.save(SchoolFixture.builder().build()); - bookmarkRepository.save(new Bookmark(BookmarkType.SCHOOL, school.getId(), 회원_식별자)); + bookmarkRepository.save( + BookmarkFixture.builder() + .bookmarkType(BookmarkType.SCHOOL) + .resourceId(school.getId()) + .memberId(회원_식별자) + .build() + ); } Long schoolId = schoolRepository.save(SchoolFixture.builder().build()).getId(); @@ -68,7 +74,13 @@ class 학교_북마크_추가시 { void 이미_해당하는_북마크가_저장됐다면_예외() { // given Long schoolId = schoolRepository.save(SchoolFixture.builder().build()).getId(); - bookmarkRepository.save(new Bookmark(BookmarkType.SCHOOL, schoolId, 회원_식별자)); + bookmarkRepository.save( + BookmarkFixture.builder() + .bookmarkType(BookmarkType.SCHOOL) + .resourceId(schoolId) + .memberId(회원_식별자) + .build() + ); // when schoolBookmarkCommandService.save(schoolId, 회원_식별자); @@ -96,7 +108,13 @@ class 학교_북마크_추가시 { void 북마크를_삭제한다() { // given Long schoolId = schoolRepository.save(SchoolFixture.builder().build()).getId(); - bookmarkRepository.save(new Bookmark(BookmarkType.SCHOOL, schoolId, 회원_식별자)); + bookmarkRepository.save( + BookmarkFixture.builder() + .bookmarkType(BookmarkType.SCHOOL) + .resourceId(schoolId) + .memberId(회원_식별자) + .build() + ); // when schoolBookmarkCommandService.delete(schoolId, 회원_식별자); diff --git a/backend/src/test/java/com/festago/fcm/repository/MemberFCMRepositoryTest.java b/backend/src/test/java/com/festago/fcm/repository/MemberFCMRepositoryTest.java index 05c4c92b7..5d6420a8a 100644 --- a/backend/src/test/java/com/festago/fcm/repository/MemberFCMRepositoryTest.java +++ b/backend/src/test/java/com/festago/fcm/repository/MemberFCMRepositoryTest.java @@ -2,11 +2,11 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.festago.auth.domain.SocialType; import com.festago.fcm.domain.MemberFCM; import com.festago.member.domain.Member; import com.festago.member.repository.MemberRepository; import com.festago.support.RepositoryTest; +import com.festago.support.fixture.MemberFixture; import java.util.List; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -23,7 +23,7 @@ class MemberFCMRepositoryTest { @Test void member의_모든_fcmToken_조회() { // given - Member member = memberRepository.save(new Member("socialId", SocialType.FESTAGO, "nickname", "image.jpg")); + Member member = memberRepository.save(MemberFixture.builder().build()); Long memberId = member.getId(); MemberFCM expect1 = memberFCMRepository.save(new MemberFCM(memberId, "fcmToken")); MemberFCM expect2 = memberFCMRepository.save(new MemberFCM(memberId, "fcmToken2")); diff --git a/backend/src/test/java/com/festago/festival/application/FestivalQueryInfoArtistRenewServiceTest.java b/backend/src/test/java/com/festago/festival/application/FestivalQueryInfoArtistRenewServiceTest.java index 71408d5fe..7e0a83327 100644 --- a/backend/src/test/java/com/festago/festival/application/FestivalQueryInfoArtistRenewServiceTest.java +++ b/backend/src/test/java/com/festago/festival/application/FestivalQueryInfoArtistRenewServiceTest.java @@ -13,6 +13,8 @@ import com.festago.festival.domain.FestivalQueryInfo; import com.festago.festival.repository.FestivalInfoRepository; import com.festago.festival.repository.MemoryFestivalQueryInfoRepository; +import com.festago.support.fixture.ArtistFixture; +import com.festago.support.fixture.FestivalQueryInfoFixture; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; @@ -24,9 +26,6 @@ @SuppressWarnings("NonAsciiCharacters") class FestivalQueryInfoArtistRenewServiceTest { - private static final String PROFILE_IMAGE_URL = "https://image.com/profileImage.png"; - private static final String BACKGROUND_IMAGE_URL = "https://image.com/backgroundImage.png"; - FestivalInfoRepository festivalInfoRepository; FestivalIdStageArtistsResolver festivalIdStageArtistsResolver = mock(); ArtistsSerializer artistsSerializer = artists -> artists.stream() @@ -49,13 +48,14 @@ void setUp() { class renewArtistInfo { private final Long festivalId = 1L; - private final Artist 뉴진스 = new Artist(1L, "뉴진스", PROFILE_IMAGE_URL, BACKGROUND_IMAGE_URL); - private final Artist 소녀시대 = new Artist(2L, "소녀시대", PROFILE_IMAGE_URL, BACKGROUND_IMAGE_URL); + + private final Artist 뉴진스 = ArtistFixture.builder().id(1L).name("뉴진스").build(); + private final Artist 소녀시대 = ArtistFixture.builder().id(2L).name("소녀시대").build(); FestivalQueryInfo festivalQueryInfo; @BeforeEach void setUp() { - festivalQueryInfo = festivalInfoRepository.save(FestivalQueryInfo.create(festivalId)); + festivalQueryInfo = festivalInfoRepository.save(FestivalQueryInfoFixture.builder().festivalId(festivalId).build()); } @Test diff --git a/backend/src/test/java/com/festago/festival/application/integration/command/FestivalDeleteServiceTest.java b/backend/src/test/java/com/festago/festival/application/integration/command/FestivalDeleteServiceTest.java index 178e602e8..6fe503ba2 100644 --- a/backend/src/test/java/com/festago/festival/application/integration/command/FestivalDeleteServiceTest.java +++ b/backend/src/test/java/com/festago/festival/application/integration/command/FestivalDeleteServiceTest.java @@ -8,7 +8,6 @@ import com.festago.common.exception.ErrorCode; import com.festago.festival.application.command.FestivalDeleteService; import com.festago.festival.domain.Festival; -import com.festago.festival.domain.FestivalQueryInfo; import com.festago.festival.repository.FestivalInfoRepository; import com.festago.festival.repository.FestivalRepository; import com.festago.school.domain.School; @@ -17,6 +16,7 @@ import com.festago.support.ApplicationIntegrationTest; import com.festago.support.TimeInstantProvider; import com.festago.support.fixture.FestivalFixture; +import com.festago.support.fixture.FestivalQueryInfoFixture; import com.festago.support.fixture.SchoolFixture; import com.festago.support.fixture.StageFixture; import java.time.Clock; @@ -92,7 +92,7 @@ void setUp() { @Test void 축제를_삭제하면_FestivalQueryInfo도_삭제된다() { // given - festivalInfoRepository.save(FestivalQueryInfo.create(festivalId)); + festivalInfoRepository.save(FestivalQueryInfoFixture.builder().festivalId(festivalId).build()); // when festivalDeleteService.deleteFestival(festivalId); diff --git a/backend/src/test/java/com/festago/festival/application/integration/query/FestivalSearchV1QueryServiceTest.java b/backend/src/test/java/com/festago/festival/application/integration/query/FestivalSearchV1QueryServiceTest.java index 1eb72b920..266afc47e 100644 --- a/backend/src/test/java/com/festago/festival/application/integration/query/FestivalSearchV1QueryServiceTest.java +++ b/backend/src/test/java/com/festago/festival/application/integration/query/FestivalSearchV1QueryServiceTest.java @@ -7,7 +7,6 @@ import com.festago.artist.repository.ArtistRepository; import com.festago.festival.application.FestivalSearchV1QueryService; import com.festago.festival.domain.Festival; -import com.festago.festival.domain.FestivalQueryInfo; import com.festago.festival.dto.FestivalSearchV1Response; import com.festago.festival.repository.FestivalInfoRepository; import com.festago.festival.repository.FestivalRepository; @@ -20,6 +19,7 @@ import com.festago.support.ApplicationIntegrationTest; import com.festago.support.fixture.ArtistFixture; import com.festago.support.fixture.FestivalFixture; +import com.festago.support.fixture.FestivalQueryInfoFixture; import com.festago.support.fixture.SchoolFixture; import com.festago.support.fixture.StageArtistFixture; import com.festago.support.fixture.StageFixture; @@ -102,9 +102,9 @@ void setting() { .school(대구_학교) .build()); - festivalInfoRepository.save(FestivalQueryInfo.create(부산_축제.getId())); - festivalInfoRepository.save(FestivalQueryInfo.create(서울_축제.getId())); - festivalInfoRepository.save(FestivalQueryInfo.create(대구_축제.getId())); + festivalInfoRepository.save(FestivalQueryInfoFixture.builder().festivalId(부산_축제.getId()).build()); + festivalInfoRepository.save(FestivalQueryInfoFixture.builder().festivalId(서울_축제.getId()).build()); + festivalInfoRepository.save(FestivalQueryInfoFixture.builder().festivalId(대구_축제.getId()).build()); 부산_공연 = stageRepository.save(StageFixture.builder() .startTime(nowDateTime.minusDays(5L)) diff --git a/backend/src/test/java/com/festago/student/application/StudentServiceTest.java b/backend/src/test/java/com/festago/student/application/StudentServiceTest.java index c4cbb10f1..5b90f36e8 100644 --- a/backend/src/test/java/com/festago/student/application/StudentServiceTest.java +++ b/backend/src/test/java/com/festago/student/application/StudentServiceTest.java @@ -204,7 +204,7 @@ class 학생_인증 { given(studentCodeRepository.findByCodeAndMember(any(), any())) .willReturn(Optional.of(new StudentCode( new VerificationCode("123456"), - new School("snu.ac.kr", "서울대학교", SchoolRegion.서울), + SchoolFixture.builder().domain("snu.ac.kr").name("서울대학교").region(SchoolRegion.서울).build(), member, "ohs", LocalDateTime.now() diff --git a/backend/src/test/java/com/festago/ticketing/domain/MemberTicketTest.java b/backend/src/test/java/com/festago/ticketing/domain/MemberTicketTest.java index 549437573..dffeb9e8c 100644 --- a/backend/src/test/java/com/festago/ticketing/domain/MemberTicketTest.java +++ b/backend/src/test/java/com/festago/ticketing/domain/MemberTicketTest.java @@ -255,7 +255,7 @@ class 티켓_주인_검사 { void 티켓_주인이다() { // given Long memberId = 1L; - Member member = new Member(memberId); + Member member = MemberFixture.builder().id(memberId).build(); MemberTicket memberTicket = MemberTicketFixture.builder() .owner(member) .build(); @@ -269,7 +269,7 @@ class 티켓_주인_검사 { // given Long memberId = 1L; Long ownerId = 2L; - Member owner = new Member(ownerId); + Member owner = MemberFixture.builder().id(ownerId).build(); MemberTicket memberTicket = MemberTicketFixture.builder() .owner(owner) .build();