diff --git a/backend/src/main/java/com/festago/artist/domain/Artist.java b/backend/src/main/java/com/festago/artist/domain/Artist.java index f1baf8ee9..34f0aa8d7 100644 --- a/backend/src/main/java/com/festago/artist/domain/Artist.java +++ b/backend/src/main/java/com/festago/artist/domain/Artist.java @@ -8,6 +8,7 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import java.util.List; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -49,6 +50,10 @@ public void update(String name, String profileImage, String backgroundImageUrl) this.backgroundImageUrl = ImageUrlHelper.getBlankStringIfBlank(backgroundImageUrl); } + public List getImageUrls() { + return List.of(profileImage, backgroundImageUrl); + } + public Long getId() { return id; } diff --git a/backend/src/main/java/com/festago/festival/domain/Festival.java b/backend/src/main/java/com/festago/festival/domain/Festival.java index e7995390e..268643d00 100644 --- a/backend/src/main/java/com/festago/festival/domain/Festival.java +++ b/backend/src/main/java/com/festago/festival/domain/Festival.java @@ -15,6 +15,7 @@ import jakarta.validation.constraints.Size; import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.List; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -101,6 +102,10 @@ public void changeFestivalDuration(FestivalDuration festivalDuration) { this.festivalDuration = festivalDuration; } + public List getImageUrls() { + return List.of(posterImageUrl); + } + public Long getId() { return id; } diff --git a/backend/src/main/java/com/festago/school/domain/School.java b/backend/src/main/java/com/festago/school/domain/School.java index 91a4f8040..a6ae16031 100644 --- a/backend/src/main/java/com/festago/school/domain/School.java +++ b/backend/src/main/java/com/festago/school/domain/School.java @@ -12,6 +12,7 @@ import jakarta.persistence.Id; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; +import java.util.List; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -112,6 +113,10 @@ public void changeBackgroundImageUrl(String backgroundImageUrl) { this.backgroundUrl = ImageUrlHelper.getBlankStringIfBlank(backgroundImageUrl); } + public List getImageUrls() { + return List.of(backgroundUrl, logoUrl); + } + public Long getId() { return id; } diff --git a/backend/src/main/java/com/festago/upload/application/artist/AsyncArtistUploadImagesStatusChangeEventListener.java b/backend/src/main/java/com/festago/upload/application/artist/AsyncArtistUploadImagesStatusChangeEventListener.java index 8a6c8f86c..9fdc0da53 100644 --- a/backend/src/main/java/com/festago/upload/application/artist/AsyncArtistUploadImagesStatusChangeEventListener.java +++ b/backend/src/main/java/com/festago/upload/application/artist/AsyncArtistUploadImagesStatusChangeEventListener.java @@ -27,7 +27,7 @@ public class AsyncArtistUploadImagesStatusChangeEventListener { public void changeAttachedStatusArtistImagesEventHandler(ArtistCreatedEvent event) { Artist artist = event.artist(); Long artistId = artist.getId(); - List imageUris = List.of(artist.getProfileImage(), artist.getBackgroundImageUrl()); + List imageUris = artist.getImageUrls(); uploadFileStatusChangeService.changeAttached(artistId, ARTIST, imageUris); } @@ -35,7 +35,7 @@ public void changeAttachedStatusArtistImagesEventHandler(ArtistCreatedEvent even public void changeRenewalStatusArtistImagesEventHandler(ArtistUpdatedEvent event) { Artist artist = event.artist(); Long artistId = artist.getId(); - List imageUris = List.of(artist.getProfileImage(), artist.getBackgroundImageUrl()); + List imageUris = artist.getImageUrls(); uploadFileStatusChangeService.changeRenewal(artistId, ARTIST, imageUris); } diff --git a/backend/src/main/java/com/festago/upload/application/festival/AsyncFestivalUploadImagesStatusChangeEventListener.java b/backend/src/main/java/com/festago/upload/application/festival/AsyncFestivalUploadImagesStatusChangeEventListener.java index 332a0ed33..e515b94b0 100644 --- a/backend/src/main/java/com/festago/upload/application/festival/AsyncFestivalUploadImagesStatusChangeEventListener.java +++ b/backend/src/main/java/com/festago/upload/application/festival/AsyncFestivalUploadImagesStatusChangeEventListener.java @@ -27,7 +27,7 @@ public class AsyncFestivalUploadImagesStatusChangeEventListener { public void changeAttachedStatusFestivalImagesEventHandler(FestivalCreatedEvent event) { Festival festival = event.festival(); Long festivalId = festival.getId(); - List imageUris = List.of(festival.getPosterImageUrl()); + List imageUris = festival.getImageUrls(); uploadFileStatusChangeService.changeAttached(festivalId, FESTIVAL, imageUris); } @@ -35,7 +35,7 @@ public void changeAttachedStatusFestivalImagesEventHandler(FestivalCreatedEvent public void changeRenewalStatusFestivalImagesEventHandler(FestivalUpdatedEvent event) { Festival festival = event.festival(); Long festivalId = festival.getId(); - List imageUris = List.of(festival.getPosterImageUrl()); + List imageUris = festival.getImageUrls(); uploadFileStatusChangeService.changeRenewal(festivalId, FESTIVAL, imageUris); } diff --git a/backend/src/main/java/com/festago/upload/application/school/AsyncSchoolUploadImagesStatusChangeEventListener.java b/backend/src/main/java/com/festago/upload/application/school/AsyncSchoolUploadImagesStatusChangeEventListener.java index 184f72251..2a0fe293d 100644 --- a/backend/src/main/java/com/festago/upload/application/school/AsyncSchoolUploadImagesStatusChangeEventListener.java +++ b/backend/src/main/java/com/festago/upload/application/school/AsyncSchoolUploadImagesStatusChangeEventListener.java @@ -27,7 +27,7 @@ public class AsyncSchoolUploadImagesStatusChangeEventListener { public void changeAttachedStatusSchoolImagesEventHandler(SchoolCreatedEvent event) { School school = event.school(); Long schoolId = school.getId(); - List imageUris = List.of(school.getBackgroundUrl(), school.getLogoUrl()); + List imageUris = school.getImageUrls(); uploadFileStatusChangeService.changeAttached(schoolId, SCHOOL, imageUris); } @@ -35,7 +35,7 @@ public void changeAttachedStatusSchoolImagesEventHandler(SchoolCreatedEvent even public void changeRenewalStatusSchoolImagesEventHandler(SchoolUpdatedEvent event) { School school = event.school(); Long schoolId = school.getId(); - List imageUris = List.of(school.getBackgroundUrl(), school.getLogoUrl()); + List imageUris = school.getImageUrls(); uploadFileStatusChangeService.changeRenewal(schoolId, SCHOOL, imageUris); } diff --git a/backend/src/test/java/com/festago/artist/domain/ArtistTest.java b/backend/src/test/java/com/festago/artist/domain/ArtistTest.java new file mode 100644 index 000000000..071c7c41c --- /dev/null +++ b/backend/src/test/java/com/festago/artist/domain/ArtistTest.java @@ -0,0 +1,32 @@ +package com.festago.artist.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.festago.support.fixture.ArtistFixture; +import java.util.List; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +@SuppressWarnings("NonAsciiCharacters") +class ArtistTest { + + @Nested + class getImageUrls { + + @Test + void 가지고_있는_모든_이미지_URL을_반환한다() { + // given + Artist artist = ArtistFixture.builder().build(); + + // when + List imageUrls = artist.getImageUrls(); + + // then + assertThat(imageUrls) + .containsExactlyInAnyOrder(artist.getProfileImage(), artist.getBackgroundImageUrl()); + } + } +} diff --git a/backend/src/test/java/com/festago/festival/domain/FestivalTest.java b/backend/src/test/java/com/festago/festival/domain/FestivalTest.java new file mode 100644 index 000000000..e428f6a08 --- /dev/null +++ b/backend/src/test/java/com/festago/festival/domain/FestivalTest.java @@ -0,0 +1,32 @@ +package com.festago.festival.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.festago.support.fixture.FestivalFixture; +import java.util.List; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +@SuppressWarnings("NonAsciiCharacters") +class FestivalTest { + + @Nested + class getImageUrls { + + @Test + void 가지고_있는_모든_이미지_URL을_반환한다() { + // given + Festival festival = FestivalFixture.builder().build(); + + // when + List imageUrls = festival.getImageUrls(); + + // then + assertThat(imageUrls) + .containsExactlyInAnyOrder(festival.getPosterImageUrl()); + } + } +} diff --git a/backend/src/test/java/com/festago/school/domain/SchoolTest.java b/backend/src/test/java/com/festago/school/domain/SchoolTest.java index 9ba4b7e1d..9e8b796bb 100644 --- a/backend/src/test/java/com/festago/school/domain/SchoolTest.java +++ b/backend/src/test/java/com/festago/school/domain/SchoolTest.java @@ -5,6 +5,8 @@ import static org.assertj.core.api.SoftAssertions.assertSoftly; import com.festago.common.exception.ValidException; +import com.festago.support.fixture.SchoolFixture; +import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; @@ -357,4 +359,21 @@ void setUp() { .isInstanceOf(ValidException.class); } } + + @Nested + class getImageUrls { + + @Test + void 가지고_있는_모든_이미지_URL을_반환한다() { + // given + School school = SchoolFixture.builder().build(); + + // when + List imageUrls = school.getImageUrls(); + + // then + assertThat(imageUrls) + .containsExactlyInAnyOrder(school.getLogoUrl(), school.getBackgroundUrl()); + } + } }