From 133b107e16d1aa2249d6607d75e5db9760291af7 Mon Sep 17 00:00:00 2001 From: Seokjin Jeon Date: Wed, 15 May 2024 22:36:30 +0900 Subject: [PATCH] =?UTF-8?q?[BE]=20refactor:=20CreateCommand,=20UpdateComma?= =?UTF-8?q?nd=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EB=B9=8C=EB=8D=94=20?= =?UTF-8?q?=ED=8C=A8=ED=84=B4=20=EC=A0=81=EC=9A=A9=20=EB=B0=8F=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=A0=81=EC=9A=A9=20?= =?UTF-8?q?(#940)=20(#943)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: Command 빌더 패턴 적용 (cherry picked from commit 9f34f2b82a8e1541306b33849a3aba14f5f88d41) * test: 테스트 코드에서 Command 생성 빌더 사용하도록 변경 (cherry picked from commit 7279977cd77c663a47361e387da821edc8d6603d) * refactor: SchoolCreateCommand, SchoolUpdateCommand 패키지 이동 및 검증 로직 제거 - 도메인 응집도 향상을 위해 DTO 검증 로직 제거 (cherry picked from commit ab06daaff355c56ac7e68d034f33333603eb814c) * test: 누락된 빌터 패턴 적용 추가 * fix: evnet -> event 패키지명 수정 --- .../dto/artist/ArtistV1CreateRequest.java | 10 +- .../dto/artist/ArtistV1UpdateRequest.java | 10 +- .../dto/festival/FestivalV1CreateRequest.java | 14 +- .../dto/festival/FestivalV1UpdateRequest.java | 12 +- .../dto/school/SchoolV1CreateRequest.java | 2 +- .../dto/school/SchoolV1UpdateRequest.java | 2 +- .../admin/dto/stage/StageV1CreateRequest.java | 12 +- .../admin/dto/stage/StageV1UpdateRequest.java | 10 +- .../dto/command/ArtistCreateCommand.java | 3 + .../dto/command/ArtistUpdateCommand.java | 3 + .../festago/auth/dto/AdminLoginV1Request.java | 5 +- .../auth/dto/AdminSignupV1Request.java | 5 +- .../auth/dto/command/AdminLoginCommand.java | 3 + .../auth/dto/command/AdminSignupCommand.java | 3 + .../dto/command/FestivalCreateCommand.java | 2 + .../dto/command/FestivalUpdateCommand.java | 2 + .../application/SchoolCommandService.java | 10 +- .../application/SchoolDeleteService.java | 2 +- .../school/dto/SchoolCreateCommand.java | 37 ----- .../school/dto/SchoolUpdateCommand.java | 21 --- .../dto/command/SchoolCreateCommand.java | 26 +++ .../dto/command/SchoolUpdateCommand.java | 14 ++ .../{evnet => event}/SchoolCreatedEvent.java | 2 +- .../{evnet => event}/SchoolDeletedEvent.java | 2 +- .../{evnet => event}/SchoolUpdatedEvent.java | 2 +- .../stage/dto/command/StageCreateCommand.java | 2 + .../stage/dto/command/StageUpdateCommand.java | 2 + ...UploadImagesStatusChangeEventListener.java | 6 +- .../steps/AdminStepDefinitions.java | 6 +- .../steps/FestivalStepDefinitions.java | 8 +- .../v1/AdminSchoolV1ControllerTest.java | 2 +- .../application/ArtistCommandServiceTest.java | 14 +- .../command/AdminAuthCommandServiceTest.java | 30 +++- ...FestivalV1QueryServiceIntegrationTest.java | 84 +++++----- .../command/FestivalCreateServiceTest.java | 28 ++-- .../command/FestivalUpdateServiceTest.java | 24 +-- ...alDetailV1QueryServiceIntegrationTest.java | 155 +++++++++++------- ...FestivalV1QueryServiceIntegrationTest.java | 106 ++++++------ ...FestivalV1QueryServiceIntegrationTest.java | 85 +++++----- .../application/SchoolCommandServiceTest.java | 4 +- .../SocialMediaCommandServiceTest.java | 68 ++++---- .../StageCommandServiceIntegrationTest.java | 116 ++++++------- .../command/StageCreateServiceTest.java | 79 +++++---- .../command/StageUpdateServiceTest.java | 70 ++++---- 44 files changed, 594 insertions(+), 509 deletions(-) delete mode 100644 backend/src/main/java/com/festago/school/dto/SchoolCreateCommand.java delete mode 100644 backend/src/main/java/com/festago/school/dto/SchoolUpdateCommand.java create mode 100644 backend/src/main/java/com/festago/school/dto/command/SchoolCreateCommand.java create mode 100644 backend/src/main/java/com/festago/school/dto/command/SchoolUpdateCommand.java rename backend/src/main/java/com/festago/school/dto/{evnet => event}/SchoolCreatedEvent.java (72%) rename backend/src/main/java/com/festago/school/dto/{evnet => event}/SchoolDeletedEvent.java (61%) rename backend/src/main/java/com/festago/school/dto/{evnet => event}/SchoolUpdatedEvent.java (72%) diff --git a/backend/src/main/java/com/festago/admin/dto/artist/ArtistV1CreateRequest.java b/backend/src/main/java/com/festago/admin/dto/artist/ArtistV1CreateRequest.java index b5dd0bea3..f59c5d30b 100644 --- a/backend/src/main/java/com/festago/admin/dto/artist/ArtistV1CreateRequest.java +++ b/backend/src/main/java/com/festago/admin/dto/artist/ArtistV1CreateRequest.java @@ -14,10 +14,10 @@ public record ArtistV1CreateRequest( ) { public ArtistCreateCommand toCommand() { - return new ArtistCreateCommand( - name, - profileImageUrl, - backgroundImageUrl - ); + return ArtistCreateCommand.builder() + .name(name) + .profileImageUrl(profileImageUrl) + .backgroundImageUrl(backgroundImageUrl) + .build(); } } diff --git a/backend/src/main/java/com/festago/admin/dto/artist/ArtistV1UpdateRequest.java b/backend/src/main/java/com/festago/admin/dto/artist/ArtistV1UpdateRequest.java index 42ea06955..46a51b4bc 100644 --- a/backend/src/main/java/com/festago/admin/dto/artist/ArtistV1UpdateRequest.java +++ b/backend/src/main/java/com/festago/admin/dto/artist/ArtistV1UpdateRequest.java @@ -14,10 +14,10 @@ public record ArtistV1UpdateRequest( ) { public ArtistUpdateCommand toCommand() { - return new ArtistUpdateCommand( - name, - profileImageUrl, - backgroundImageUrl - ); + return ArtistUpdateCommand.builder() + .name(name) + .profileImageUrl(profileImageUrl) + .backgroundImageUrl(backgroundImageUrl) + .build(); } } diff --git a/backend/src/main/java/com/festago/admin/dto/festival/FestivalV1CreateRequest.java b/backend/src/main/java/com/festago/admin/dto/festival/FestivalV1CreateRequest.java index 95b1d0c98..90d1022d5 100644 --- a/backend/src/main/java/com/festago/admin/dto/festival/FestivalV1CreateRequest.java +++ b/backend/src/main/java/com/festago/admin/dto/festival/FestivalV1CreateRequest.java @@ -27,12 +27,12 @@ public record FestivalV1CreateRequest( ) { public FestivalCreateCommand toCommand() { - return new FestivalCreateCommand( - name, - startDate, - endDate, - posterImageUrl, - schoolId - ); + return FestivalCreateCommand.builder() + .name(name) + .startDate(startDate) + .endDate(endDate) + .posterImageUrl(posterImageUrl) + .schoolId(schoolId) + .build(); } } diff --git a/backend/src/main/java/com/festago/admin/dto/festival/FestivalV1UpdateRequest.java b/backend/src/main/java/com/festago/admin/dto/festival/FestivalV1UpdateRequest.java index dc1a92f05..26c37b68e 100644 --- a/backend/src/main/java/com/festago/admin/dto/festival/FestivalV1UpdateRequest.java +++ b/backend/src/main/java/com/festago/admin/dto/festival/FestivalV1UpdateRequest.java @@ -24,11 +24,11 @@ public record FestivalV1UpdateRequest( ) { public FestivalUpdateCommand toCommand() { - return new FestivalUpdateCommand( - name, - startDate, - endDate, - posterImageUrl - ); + return FestivalUpdateCommand.builder() + .name(name) + .startDate(startDate) + .endDate(endDate) + .posterImageUrl(posterImageUrl) + .build(); } } diff --git a/backend/src/main/java/com/festago/admin/dto/school/SchoolV1CreateRequest.java b/backend/src/main/java/com/festago/admin/dto/school/SchoolV1CreateRequest.java index 43b0795d2..b2e2d9318 100644 --- a/backend/src/main/java/com/festago/admin/dto/school/SchoolV1CreateRequest.java +++ b/backend/src/main/java/com/festago/admin/dto/school/SchoolV1CreateRequest.java @@ -1,7 +1,7 @@ package com.festago.admin.dto.school; import com.festago.school.domain.SchoolRegion; -import com.festago.school.dto.SchoolCreateCommand; +import com.festago.school.dto.command.SchoolCreateCommand; import jakarta.annotation.Nullable; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; diff --git a/backend/src/main/java/com/festago/admin/dto/school/SchoolV1UpdateRequest.java b/backend/src/main/java/com/festago/admin/dto/school/SchoolV1UpdateRequest.java index 870cca5e5..14c1737c0 100644 --- a/backend/src/main/java/com/festago/admin/dto/school/SchoolV1UpdateRequest.java +++ b/backend/src/main/java/com/festago/admin/dto/school/SchoolV1UpdateRequest.java @@ -1,7 +1,7 @@ package com.festago.admin.dto.school; import com.festago.school.domain.SchoolRegion; -import com.festago.school.dto.SchoolUpdateCommand; +import com.festago.school.dto.command.SchoolUpdateCommand; import jakarta.annotation.Nullable; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; diff --git a/backend/src/main/java/com/festago/admin/dto/stage/StageV1CreateRequest.java b/backend/src/main/java/com/festago/admin/dto/stage/StageV1CreateRequest.java index b34bd5785..d862d498a 100644 --- a/backend/src/main/java/com/festago/admin/dto/stage/StageV1CreateRequest.java +++ b/backend/src/main/java/com/festago/admin/dto/stage/StageV1CreateRequest.java @@ -20,11 +20,11 @@ public record StageV1CreateRequest( ) { public StageCreateCommand toCommand() { - return new StageCreateCommand( - festivalId, - startTime, - ticketOpenTime, - artistIds - ); + return StageCreateCommand.builder() + .festivalId(festivalId) + .startTime(startTime) + .ticketOpenTime(ticketOpenTime) + .artistIds(artistIds) + .build(); } } diff --git a/backend/src/main/java/com/festago/admin/dto/stage/StageV1UpdateRequest.java b/backend/src/main/java/com/festago/admin/dto/stage/StageV1UpdateRequest.java index cecf04b76..ce0b0f361 100644 --- a/backend/src/main/java/com/festago/admin/dto/stage/StageV1UpdateRequest.java +++ b/backend/src/main/java/com/festago/admin/dto/stage/StageV1UpdateRequest.java @@ -18,10 +18,10 @@ public record StageV1UpdateRequest( ) { public StageUpdateCommand toCommand() { - return new StageUpdateCommand( - startTime, - ticketOpenTime, - artistIds - ); + return StageUpdateCommand.builder() + .startTime(startTime) + .ticketOpenTime(ticketOpenTime) + .artistIds(artistIds) + .build(); } } diff --git a/backend/src/main/java/com/festago/artist/dto/command/ArtistCreateCommand.java b/backend/src/main/java/com/festago/artist/dto/command/ArtistCreateCommand.java index 949d586c2..16119e6de 100644 --- a/backend/src/main/java/com/festago/artist/dto/command/ArtistCreateCommand.java +++ b/backend/src/main/java/com/festago/artist/dto/command/ArtistCreateCommand.java @@ -1,5 +1,8 @@ package com.festago.artist.dto.command; +import lombok.Builder; + +@Builder public record ArtistCreateCommand( String name, String profileImageUrl, diff --git a/backend/src/main/java/com/festago/artist/dto/command/ArtistUpdateCommand.java b/backend/src/main/java/com/festago/artist/dto/command/ArtistUpdateCommand.java index 9ece595c0..c14d165d4 100644 --- a/backend/src/main/java/com/festago/artist/dto/command/ArtistUpdateCommand.java +++ b/backend/src/main/java/com/festago/artist/dto/command/ArtistUpdateCommand.java @@ -1,5 +1,8 @@ package com.festago.artist.dto.command; +import lombok.Builder; + +@Builder public record ArtistUpdateCommand( String name, String profileImageUrl, diff --git a/backend/src/main/java/com/festago/auth/dto/AdminLoginV1Request.java b/backend/src/main/java/com/festago/auth/dto/AdminLoginV1Request.java index 47fa8d59d..e5051f97e 100644 --- a/backend/src/main/java/com/festago/auth/dto/AdminLoginV1Request.java +++ b/backend/src/main/java/com/festago/auth/dto/AdminLoginV1Request.java @@ -11,6 +11,9 @@ public record AdminLoginV1Request( ) { public AdminLoginCommand toCommand() { - return new AdminLoginCommand(username, password); + return AdminLoginCommand.builder() + .username(username) + .password(password) + .build(); } } diff --git a/backend/src/main/java/com/festago/auth/dto/AdminSignupV1Request.java b/backend/src/main/java/com/festago/auth/dto/AdminSignupV1Request.java index 9e58dde72..bd630c314 100644 --- a/backend/src/main/java/com/festago/auth/dto/AdminSignupV1Request.java +++ b/backend/src/main/java/com/festago/auth/dto/AdminSignupV1Request.java @@ -11,6 +11,9 @@ public record AdminSignupV1Request( ) { public AdminSignupCommand toCommand() { - return new AdminSignupCommand(username, password); + return AdminSignupCommand.builder() + .username(username) + .password(password) + .build(); } } diff --git a/backend/src/main/java/com/festago/auth/dto/command/AdminLoginCommand.java b/backend/src/main/java/com/festago/auth/dto/command/AdminLoginCommand.java index 083d7047e..6b628d8ef 100644 --- a/backend/src/main/java/com/festago/auth/dto/command/AdminLoginCommand.java +++ b/backend/src/main/java/com/festago/auth/dto/command/AdminLoginCommand.java @@ -1,5 +1,8 @@ package com.festago.auth.dto.command; +import lombok.Builder; + +@Builder public record AdminLoginCommand( String username, String password diff --git a/backend/src/main/java/com/festago/auth/dto/command/AdminSignupCommand.java b/backend/src/main/java/com/festago/auth/dto/command/AdminSignupCommand.java index 215d2b948..8d2295a3f 100644 --- a/backend/src/main/java/com/festago/auth/dto/command/AdminSignupCommand.java +++ b/backend/src/main/java/com/festago/auth/dto/command/AdminSignupCommand.java @@ -1,5 +1,8 @@ package com.festago.auth.dto.command; +import lombok.Builder; + +@Builder public record AdminSignupCommand( String username, String password diff --git a/backend/src/main/java/com/festago/festival/dto/command/FestivalCreateCommand.java b/backend/src/main/java/com/festago/festival/dto/command/FestivalCreateCommand.java index 7db308a8a..f5f1b551f 100644 --- a/backend/src/main/java/com/festago/festival/dto/command/FestivalCreateCommand.java +++ b/backend/src/main/java/com/festago/festival/dto/command/FestivalCreateCommand.java @@ -4,7 +4,9 @@ import com.festago.festival.domain.FestivalDuration; import com.festago.school.domain.School; import java.time.LocalDate; +import lombok.Builder; +@Builder public record FestivalCreateCommand( String name, LocalDate startDate, diff --git a/backend/src/main/java/com/festago/festival/dto/command/FestivalUpdateCommand.java b/backend/src/main/java/com/festago/festival/dto/command/FestivalUpdateCommand.java index 57aa9f1de..6fadfcf8d 100644 --- a/backend/src/main/java/com/festago/festival/dto/command/FestivalUpdateCommand.java +++ b/backend/src/main/java/com/festago/festival/dto/command/FestivalUpdateCommand.java @@ -1,7 +1,9 @@ package com.festago.festival.dto.command; import java.time.LocalDate; +import lombok.Builder; +@Builder public record FestivalUpdateCommand( String name, LocalDate startDate, diff --git a/backend/src/main/java/com/festago/school/application/SchoolCommandService.java b/backend/src/main/java/com/festago/school/application/SchoolCommandService.java index 5f1cda3e8..afe34c449 100644 --- a/backend/src/main/java/com/festago/school/application/SchoolCommandService.java +++ b/backend/src/main/java/com/festago/school/application/SchoolCommandService.java @@ -3,10 +3,10 @@ import com.festago.common.exception.BadRequestException; import com.festago.common.exception.ErrorCode; import com.festago.school.domain.School; -import com.festago.school.dto.SchoolCreateCommand; -import com.festago.school.dto.SchoolUpdateCommand; -import com.festago.school.dto.evnet.SchoolCreatedEvent; -import com.festago.school.dto.evnet.SchoolUpdatedEvent; +import com.festago.school.dto.command.SchoolCreateCommand; +import com.festago.school.dto.command.SchoolUpdateCommand; +import com.festago.school.dto.event.SchoolCreatedEvent; +import com.festago.school.dto.event.SchoolUpdatedEvent; import com.festago.school.repository.SchoolRepository; import java.util.Objects; import lombok.RequiredArgsConstructor; @@ -24,7 +24,7 @@ public class SchoolCommandService { public Long createSchool(SchoolCreateCommand command) { validateCreate(command); - School school = schoolRepository.save(command.toDomain()); + School school = schoolRepository.save(command.toEntity()); eventPublisher.publishEvent(new SchoolCreatedEvent(school)); return school.getId(); } diff --git a/backend/src/main/java/com/festago/school/application/SchoolDeleteService.java b/backend/src/main/java/com/festago/school/application/SchoolDeleteService.java index 1d45a4719..db06eea83 100644 --- a/backend/src/main/java/com/festago/school/application/SchoolDeleteService.java +++ b/backend/src/main/java/com/festago/school/application/SchoolDeleteService.java @@ -1,7 +1,7 @@ package com.festago.school.application; import com.festago.school.domain.validator.SchoolDeleteValidator; -import com.festago.school.dto.evnet.SchoolDeletedEvent; +import com.festago.school.dto.event.SchoolDeletedEvent; import com.festago.school.repository.SchoolRepository; import java.util.List; import lombok.RequiredArgsConstructor; diff --git a/backend/src/main/java/com/festago/school/dto/SchoolCreateCommand.java b/backend/src/main/java/com/festago/school/dto/SchoolCreateCommand.java deleted file mode 100644 index 6b266319a..000000000 --- a/backend/src/main/java/com/festago/school/dto/SchoolCreateCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.festago.school.dto; - -import com.festago.common.util.Validator; -import com.festago.school.domain.School; -import com.festago.school.domain.SchoolRegion; -import lombok.Builder; - -@Builder -public record SchoolCreateCommand( - String name, - String domain, - SchoolRegion region, - String logoUrl, - String backgroundImageUrl -) { - - public SchoolCreateCommand { - Validator.notNull(name, "name"); - Validator.notNull(domain, "domain"); - Validator.notNull(region, "region"); - } - - /** - * TODO 도메인에도 빌더 패턴을 적용해야할까? - * 생성자에 같은 타입이 중복적으로 발생하여 버그 발생 가능성이 매우 높다. - */ - public School toDomain() { - return new School( - null, - domain, - name, - logoUrl, - backgroundImageUrl, - region - ); - } -} diff --git a/backend/src/main/java/com/festago/school/dto/SchoolUpdateCommand.java b/backend/src/main/java/com/festago/school/dto/SchoolUpdateCommand.java deleted file mode 100644 index 0dcbf4a62..000000000 --- a/backend/src/main/java/com/festago/school/dto/SchoolUpdateCommand.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.festago.school.dto; - -import com.festago.common.util.Validator; -import com.festago.school.domain.SchoolRegion; -import lombok.Builder; - -@Builder -public record SchoolUpdateCommand( - String name, - String domain, - SchoolRegion region, - String logoUrl, - String backgroundImageUrl -) { - - public SchoolUpdateCommand { - Validator.notNull(name, "name"); - Validator.notNull(domain, "domain"); - Validator.notNull(region, "region"); - } -} diff --git a/backend/src/main/java/com/festago/school/dto/command/SchoolCreateCommand.java b/backend/src/main/java/com/festago/school/dto/command/SchoolCreateCommand.java new file mode 100644 index 000000000..989ae928e --- /dev/null +++ b/backend/src/main/java/com/festago/school/dto/command/SchoolCreateCommand.java @@ -0,0 +1,26 @@ +package com.festago.school.dto.command; + +import com.festago.school.domain.School; +import com.festago.school.domain.SchoolRegion; +import lombok.Builder; + +@Builder +public record SchoolCreateCommand( + String name, + String domain, + SchoolRegion region, + String logoUrl, + String backgroundImageUrl +) { + + public School toEntity() { + return new School( + null, + domain, + name, + logoUrl, + backgroundImageUrl, + region + ); + } +} diff --git a/backend/src/main/java/com/festago/school/dto/command/SchoolUpdateCommand.java b/backend/src/main/java/com/festago/school/dto/command/SchoolUpdateCommand.java new file mode 100644 index 000000000..58f6235d1 --- /dev/null +++ b/backend/src/main/java/com/festago/school/dto/command/SchoolUpdateCommand.java @@ -0,0 +1,14 @@ +package com.festago.school.dto.command; + +import com.festago.school.domain.SchoolRegion; +import lombok.Builder; + +@Builder +public record SchoolUpdateCommand( + String name, + String domain, + SchoolRegion region, + String logoUrl, + String backgroundImageUrl +) { +} diff --git a/backend/src/main/java/com/festago/school/dto/evnet/SchoolCreatedEvent.java b/backend/src/main/java/com/festago/school/dto/event/SchoolCreatedEvent.java similarity index 72% rename from backend/src/main/java/com/festago/school/dto/evnet/SchoolCreatedEvent.java rename to backend/src/main/java/com/festago/school/dto/event/SchoolCreatedEvent.java index 48fbc5c2f..20836f105 100644 --- a/backend/src/main/java/com/festago/school/dto/evnet/SchoolCreatedEvent.java +++ b/backend/src/main/java/com/festago/school/dto/event/SchoolCreatedEvent.java @@ -1,4 +1,4 @@ -package com.festago.school.dto.evnet; +package com.festago.school.dto.event; import com.festago.school.domain.School; diff --git a/backend/src/main/java/com/festago/school/dto/evnet/SchoolDeletedEvent.java b/backend/src/main/java/com/festago/school/dto/event/SchoolDeletedEvent.java similarity index 61% rename from backend/src/main/java/com/festago/school/dto/evnet/SchoolDeletedEvent.java rename to backend/src/main/java/com/festago/school/dto/event/SchoolDeletedEvent.java index 1377a215a..444713afc 100644 --- a/backend/src/main/java/com/festago/school/dto/evnet/SchoolDeletedEvent.java +++ b/backend/src/main/java/com/festago/school/dto/event/SchoolDeletedEvent.java @@ -1,4 +1,4 @@ -package com.festago.school.dto.evnet; +package com.festago.school.dto.event; public record SchoolDeletedEvent( Long schoolId diff --git a/backend/src/main/java/com/festago/school/dto/evnet/SchoolUpdatedEvent.java b/backend/src/main/java/com/festago/school/dto/event/SchoolUpdatedEvent.java similarity index 72% rename from backend/src/main/java/com/festago/school/dto/evnet/SchoolUpdatedEvent.java rename to backend/src/main/java/com/festago/school/dto/event/SchoolUpdatedEvent.java index cfa48f01c..923a87c81 100644 --- a/backend/src/main/java/com/festago/school/dto/evnet/SchoolUpdatedEvent.java +++ b/backend/src/main/java/com/festago/school/dto/event/SchoolUpdatedEvent.java @@ -1,4 +1,4 @@ -package com.festago.school.dto.evnet; +package com.festago.school.dto.event; import com.festago.school.domain.School; diff --git a/backend/src/main/java/com/festago/stage/dto/command/StageCreateCommand.java b/backend/src/main/java/com/festago/stage/dto/command/StageCreateCommand.java index c7d5bcaee..f696c102c 100644 --- a/backend/src/main/java/com/festago/stage/dto/command/StageCreateCommand.java +++ b/backend/src/main/java/com/festago/stage/dto/command/StageCreateCommand.java @@ -2,7 +2,9 @@ import java.time.LocalDateTime; import java.util.List; +import lombok.Builder; +@Builder public record StageCreateCommand( Long festivalId, LocalDateTime startTime, diff --git a/backend/src/main/java/com/festago/stage/dto/command/StageUpdateCommand.java b/backend/src/main/java/com/festago/stage/dto/command/StageUpdateCommand.java index 46b452b8c..86b064d0b 100644 --- a/backend/src/main/java/com/festago/stage/dto/command/StageUpdateCommand.java +++ b/backend/src/main/java/com/festago/stage/dto/command/StageUpdateCommand.java @@ -2,7 +2,9 @@ import java.time.LocalDateTime; import java.util.List; +import lombok.Builder; +@Builder public record StageUpdateCommand( LocalDateTime startTime, LocalDateTime ticketOpenTime, 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 663ee1ac1..184f72251 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 @@ -3,9 +3,9 @@ import static com.festago.upload.domain.FileOwnerType.SCHOOL; import com.festago.school.domain.School; -import com.festago.school.dto.evnet.SchoolCreatedEvent; -import com.festago.school.dto.evnet.SchoolDeletedEvent; -import com.festago.school.dto.evnet.SchoolUpdatedEvent; +import com.festago.school.dto.event.SchoolCreatedEvent; +import com.festago.school.dto.event.SchoolDeletedEvent; +import com.festago.school.dto.event.SchoolUpdatedEvent; import com.festago.upload.application.UploadFileStatusChangeService; import java.util.List; import lombok.RequiredArgsConstructor; diff --git a/backend/src/test/java/com/festago/acceptance/steps/AdminStepDefinitions.java b/backend/src/test/java/com/festago/acceptance/steps/AdminStepDefinitions.java index 582a738f7..c45f169eb 100644 --- a/backend/src/test/java/com/festago/acceptance/steps/AdminStepDefinitions.java +++ b/backend/src/test/java/com/festago/acceptance/steps/AdminStepDefinitions.java @@ -16,7 +16,11 @@ public class AdminStepDefinitions { @Given("어드민 계정으로 로그인한다.") public void loginAdmin() { - var adminLoginResult = adminAuthCommandService.login(new AdminLoginCommand("admin", "1234")); + AdminLoginCommand command = AdminLoginCommand.builder() + .username("admin") + .password("1234") + .build(); + var adminLoginResult = adminAuthCommandService.login(command); cucumberClient.setToken(adminLoginResult.accessToken()); } diff --git a/backend/src/test/java/com/festago/acceptance/steps/FestivalStepDefinitions.java b/backend/src/test/java/com/festago/acceptance/steps/FestivalStepDefinitions.java index b8c2c9dab..c620e726a 100644 --- a/backend/src/test/java/com/festago/acceptance/steps/FestivalStepDefinitions.java +++ b/backend/src/test/java/com/festago/acceptance/steps/FestivalStepDefinitions.java @@ -36,7 +36,13 @@ public class FestivalStepDefinitions { LocalDate startDate = LocalDate.parse(시작일, DATE_TIME_FORMATTER); LocalDate endDate = LocalDate.parse(종료일, DATE_TIME_FORMATTER); Long schoolId = schoolRepository.findByName(학교이름).get().getId(); - var command = new FestivalCreateCommand(축제이름, startDate, endDate, "https://image.com/image.png", schoolId); + var command = FestivalCreateCommand.builder() + .name(축제이름) + .startDate(startDate) + .endDate(endDate) + .posterImageUrl("https://image.com/image.png") + .schoolId(schoolId) + .build(); festivalCreateService.createFestival(command); } diff --git a/backend/src/test/java/com/festago/admin/presentation/v1/AdminSchoolV1ControllerTest.java b/backend/src/test/java/com/festago/admin/presentation/v1/AdminSchoolV1ControllerTest.java index 8020bac7d..3b29b51a0 100644 --- a/backend/src/test/java/com/festago/admin/presentation/v1/AdminSchoolV1ControllerTest.java +++ b/backend/src/test/java/com/festago/admin/presentation/v1/AdminSchoolV1ControllerTest.java @@ -21,7 +21,7 @@ import com.festago.school.application.SchoolCommandService; import com.festago.school.application.SchoolDeleteService; import com.festago.school.domain.SchoolRegion; -import com.festago.school.dto.SchoolCreateCommand; +import com.festago.school.dto.command.SchoolCreateCommand; import com.festago.support.CustomWebMvcTest; import com.festago.support.WithMockAuth; import jakarta.servlet.http.Cookie; diff --git a/backend/src/test/java/com/festago/artist/application/ArtistCommandServiceTest.java b/backend/src/test/java/com/festago/artist/application/ArtistCommandServiceTest.java index f8ce4ef82..7f177fbe0 100644 --- a/backend/src/test/java/com/festago/artist/application/ArtistCommandServiceTest.java +++ b/backend/src/test/java/com/festago/artist/application/ArtistCommandServiceTest.java @@ -33,8 +33,11 @@ void setUp() { @Test void 아티스트를_저장한다() { // given - ArtistCreateCommand command = new ArtistCreateCommand("윤서연", "https://image.com/image.png", - "https://image.com/image.png"); + var command = ArtistCreateCommand.builder() + .name("윤서연") + .profileImageUrl("https://image.com/image.png") + .backgroundImageUrl("https://image.com/image.png") + .build(); // when Long artistId = artistCommandService.save(command); @@ -47,8 +50,11 @@ void setUp() { void 아티스트_정보를_변경한다() { // given Long artistId = artistRepository.save(ArtistFixture.builder().name("고윤하").build()).getId(); - ArtistUpdateCommand command = new ArtistUpdateCommand("윤하", "https://image.com/image2.png", - "https://image.com/image2.png"); + var command = ArtistUpdateCommand.builder() + .name("윤하") + .profileImageUrl("https://image.com/image2.png") + .backgroundImageUrl("https://image.com/image2.png") + .build(); // when artistCommandService.update(command, artistId); diff --git a/backend/src/test/java/com/festago/auth/application/command/AdminAuthCommandServiceTest.java b/backend/src/test/java/com/festago/auth/application/command/AdminAuthCommandServiceTest.java index c1838a14c..0fc53dfd4 100644 --- a/backend/src/test/java/com/festago/auth/application/command/AdminAuthCommandServiceTest.java +++ b/backend/src/test/java/com/festago/auth/application/command/AdminAuthCommandServiceTest.java @@ -56,7 +56,10 @@ class 로그인 { @Test void 계정이_없으면_예외() { // given - var command = new AdminLoginCommand("admin", "password"); + var command = AdminLoginCommand.builder() + .username("admin") + .password("password") + .build(); // when & then assertThatThrownBy(() -> adminAuthCommandService.login(command)) @@ -71,7 +74,10 @@ class 로그인 { .username("admin") .password("{noop}password") .build()); - var command = new AdminLoginCommand("admin", "admin"); + var command = AdminLoginCommand.builder() + .username("admin") + .password("admin") + .build(); // when & then assertThatThrownBy(() -> adminAuthCommandService.login(command)) @@ -86,7 +92,10 @@ class 로그인 { .username("admin") .password("{noop}password") .build()); - var command = new AdminLoginCommand("admin", "password"); + var command = AdminLoginCommand.builder() + .username("admin") + .password("password") + .build(); given(authTokenProvider.provide(any())) .willReturn(new TokenResponse("token", LocalDateTime.now().plusWeeks(1))); @@ -105,7 +114,10 @@ class 가입 { void 닉네임이_중복이면_예외() { // given Admin rootAdmin = adminRepository.save(Admin.createRootAdmin("{noop}password")); - var command = new AdminSignupCommand("admin", "password"); + var command = AdminSignupCommand.builder() + .username("admin") + .password("password") + .build(); // when & then Long rootAdminId = rootAdmin.getId(); @@ -121,7 +133,10 @@ class 가입 { .username("glen") .password("{noop}password") .build()); - var command = new AdminSignupCommand("newAdmin", "password"); + var command = AdminSignupCommand.builder() + .username("newAdmin") + .password("password") + .build(); // when & then Long adminId = admin.getId(); @@ -134,7 +149,10 @@ class 가입 { void 성공() { // given Admin rootAdmin = adminRepository.save(Admin.createRootAdmin("{noop}password")); - var command = new AdminSignupCommand("newAdmin", "password"); + var command = AdminSignupCommand.builder() + .username("newAdmin") + .password("password") + .build(); // when adminAuthCommandService.signup(rootAdmin.getId(), command); diff --git a/backend/src/test/java/com/festago/festival/application/QueryDslSchoolSearchRecentFestivalV1QueryServiceIntegrationTest.java b/backend/src/test/java/com/festago/festival/application/QueryDslSchoolSearchRecentFestivalV1QueryServiceIntegrationTest.java index 44b0ffb8d..909dba7f6 100644 --- a/backend/src/test/java/com/festago/festival/application/QueryDslSchoolSearchRecentFestivalV1QueryServiceIntegrationTest.java +++ b/backend/src/test/java/com/festago/festival/application/QueryDslSchoolSearchRecentFestivalV1QueryServiceIntegrationTest.java @@ -3,13 +3,13 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; -import com.festago.festival.application.command.FestivalCreateService; -import com.festago.festival.dto.command.FestivalCreateCommand; -import com.festago.school.application.SchoolCommandService; -import com.festago.school.domain.SchoolRegion; -import com.festago.school.dto.SchoolCreateCommand; +import com.festago.festival.repository.FestivalRepository; +import com.festago.school.domain.School; +import com.festago.school.repository.SchoolRepository; import com.festago.support.ApplicationIntegrationTest; import com.festago.support.TimeInstantProvider; +import com.festago.support.fixture.FestivalFixture; +import com.festago.support.fixture.SchoolFixture; import java.time.Clock; import java.time.LocalDate; import java.util.List; @@ -23,25 +23,21 @@ @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) class QueryDslSchoolSearchRecentFestivalV1QueryServiceIntegrationTest extends ApplicationIntegrationTest { - private static final String LOGO_URL = "https://image.com/logo.png"; - private static final String BACKGROUND_IMAGE_URL = "https://image.com/backgroundimage.png"; - private static final String POSTER_IMAGE_URL = "https://image.com/posterimage.png"; - @Autowired QueryDslSchoolUpcomingFestivalStartDateV1QueryService schoolUpcomingFestivalStartDateV1QueryService; @Autowired - SchoolCommandService schoolCommandService; + SchoolRepository schoolRepository; @Autowired - FestivalCreateService festivalCreateService; + FestivalRepository festivalRepository; @Autowired Clock clock; - Long 테코대학교_식별자; + School 테코대학교; - Long 우테대학교_식별자; + School 우테대학교; LocalDate _6월_14일 = LocalDate.parse("2077-06-14"); LocalDate _6월_15일 = LocalDate.parse("2077-06-15"); @@ -54,20 +50,28 @@ class QueryDslSchoolSearchRecentFestivalV1QueryServiceIntegrationTest extends Ap */ @BeforeEach void setUp() { - 테코대학교_식별자 = schoolCommandService.createSchool( - new SchoolCreateCommand("테코대학교", "teco.ac.kr", SchoolRegion.서울, LOGO_URL, BACKGROUND_IMAGE_URL) - ); - 우테대학교_식별자 = schoolCommandService.createSchool( - new SchoolCreateCommand("우테대학교", "wote.ac.kr", SchoolRegion.서울, LOGO_URL, BACKGROUND_IMAGE_URL) - ); - festivalCreateService.createFestival( - new FestivalCreateCommand("테코대학교 6월 15일 당일 축제", _6월_15일, _6월_15일, POSTER_IMAGE_URL, 테코대학교_식별자) + 테코대학교 = schoolRepository.save(SchoolFixture.builder().name("테코대학교").build()); + 우테대학교 = schoolRepository.save(SchoolFixture.builder().name("우테대학교").build()); + festivalRepository.save(FestivalFixture.builder() + .name("테코대학교 6월 15일 당일 축제") + .startDate(_6월_15일) + .endDate(_6월_15일) + .school(테코대학교) + .build() ); - festivalCreateService.createFestival( - new FestivalCreateCommand("테코대학교 6월 16일 당일 축제", _6월_16일, _6월_16일, POSTER_IMAGE_URL, 테코대학교_식별자) + festivalRepository.save(FestivalFixture.builder() + .name("테코대학교 6월 16일 당일 축제") + .startDate(_6월_16일) + .endDate(_6월_16일) + .school(테코대학교) + .build() ); - festivalCreateService.createFestival( - new FestivalCreateCommand("우테대학교 6월 16~17일 축제", _6월_16일, _6월_17일, POSTER_IMAGE_URL, 우테대학교_식별자) + festivalRepository.save(FestivalFixture.builder() + .name("우테대학교 6월 16~17일 축제") + .startDate(_6월_16일) + .endDate(_6월_17일) + .school(우테대학교) + .build() ); } @@ -79,12 +83,12 @@ void setUp() { // when var actual = schoolUpcomingFestivalStartDateV1QueryService.getSchoolIdToUpcomingFestivalStartDate( - List.of(테코대학교_식별자, 우테대학교_식별자) + List.of(테코대학교.getId(), 우테대학교.getId()) ); // then - assertThat(actual.get(테코대학교_식별자)).isEqualTo(_6월_15일); - assertThat(actual.get(우테대학교_식별자)).isEqualTo(_6월_16일); + assertThat(actual.get(테코대학교.getId())).isEqualTo(_6월_15일); + assertThat(actual.get(우테대학교.getId())).isEqualTo(_6월_16일); } @Test @@ -95,12 +99,12 @@ void setUp() { // when var actual = schoolUpcomingFestivalStartDateV1QueryService.getSchoolIdToUpcomingFestivalStartDate( - List.of(테코대학교_식별자, 우테대학교_식별자) + List.of(테코대학교.getId(), 우테대학교.getId()) ); // then - assertThat(actual.get(테코대학교_식별자)).isEqualTo(_6월_15일); - assertThat(actual.get(우테대학교_식별자)).isEqualTo(_6월_16일); + assertThat(actual.get(테코대학교.getId())).isEqualTo(_6월_15일); + assertThat(actual.get(우테대학교.getId())).isEqualTo(_6월_16일); } @Test @@ -111,12 +115,12 @@ void setUp() { // when var actual = schoolUpcomingFestivalStartDateV1QueryService.getSchoolIdToUpcomingFestivalStartDate( - List.of(테코대학교_식별자, 우테대학교_식별자) + List.of(테코대학교.getId(), 우테대학교.getId()) ); // then - assertThat(actual.get(테코대학교_식별자)).isEqualTo(_6월_16일); - assertThat(actual.get(우테대학교_식별자)).isEqualTo(_6월_16일); + assertThat(actual.get(테코대학교.getId())).isEqualTo(_6월_16일); + assertThat(actual.get(우테대학교.getId())).isEqualTo(_6월_16일); } @Test @@ -127,12 +131,12 @@ void setUp() { // when var actual = schoolUpcomingFestivalStartDateV1QueryService.getSchoolIdToUpcomingFestivalStartDate( - List.of(테코대학교_식별자, 우테대학교_식별자) + List.of(테코대학교.getId(), 우테대학교.getId()) ); // then - assertThat(actual.get(테코대학교_식별자)).isNull(); - assertThat(actual.get(우테대학교_식별자)).isEqualTo(_6월_16일); + assertThat(actual.get(테코대학교.getId())).isNull(); + assertThat(actual.get(우테대학교.getId())).isEqualTo(_6월_16일); } @Test @@ -143,11 +147,11 @@ void setUp() { // when var actual = schoolUpcomingFestivalStartDateV1QueryService.getSchoolIdToUpcomingFestivalStartDate( - List.of(테코대학교_식별자, 우테대학교_식별자) + List.of(테코대학교.getId(), 우테대학교.getId()) ); // then - assertThat(actual.get(테코대학교_식별자)).isNull(); - assertThat(actual.get(우테대학교_식별자)).isNull(); + assertThat(actual.get(테코대학교.getId())).isNull(); + assertThat(actual.get(우테대학교.getId())).isNull(); } } diff --git a/backend/src/test/java/com/festago/festival/application/integration/command/FestivalCreateServiceTest.java b/backend/src/test/java/com/festago/festival/application/integration/command/FestivalCreateServiceTest.java index 3074c91ba..feb784cdd 100644 --- a/backend/src/test/java/com/festago/festival/application/integration/command/FestivalCreateServiceTest.java +++ b/backend/src/test/java/com/festago/festival/application/integration/command/FestivalCreateServiceTest.java @@ -64,13 +64,13 @@ void setUp() { LocalDate startDate = now.minusDays(1); LocalDate endDate = now.plusDays(3); String posterImageUrl = "https://image.com/image.png"; - var command = new FestivalCreateCommand( - festivalName, - startDate, - endDate, - posterImageUrl, - schoolId - ); + var command = FestivalCreateCommand.builder() + .name(festivalName) + .startDate(startDate) + .endDate(endDate) + .posterImageUrl(posterImageUrl) + .schoolId(schoolId) + .build(); // when & then assertThatThrownBy(() -> festivalCreateService.createFestival(command)) @@ -85,13 +85,13 @@ void setUp() { LocalDate startDate = now.plusDays(1); LocalDate endDate = now.plusDays(3); String posterImageUrl = "https://image.com/image.png"; - var command = new FestivalCreateCommand( - festivalName, - startDate, - endDate, - posterImageUrl, - schoolId - ); + var command = FestivalCreateCommand.builder() + .name(festivalName) + .startDate(startDate) + .endDate(endDate) + .posterImageUrl(posterImageUrl) + .schoolId(schoolId) + .build(); // when Long festivalId = festivalCreateService.createFestival(command); diff --git a/backend/src/test/java/com/festago/festival/application/integration/command/FestivalUpdateServiceTest.java b/backend/src/test/java/com/festago/festival/application/integration/command/FestivalUpdateServiceTest.java index 5ad33ee4f..b5357fb6d 100644 --- a/backend/src/test/java/com/festago/festival/application/integration/command/FestivalUpdateServiceTest.java +++ b/backend/src/test/java/com/festago/festival/application/integration/command/FestivalUpdateServiceTest.java @@ -60,12 +60,12 @@ void setUp() { LocalDate newStartDate = now.minusDays(1); LocalDate newEndDate = now.plusDays(1); String newPosterImageUrl = "https://image.com/new-image.png"; - var command = new FestivalUpdateCommand( - newFestivalName, - newStartDate, - newEndDate, - newPosterImageUrl - ); + var command = FestivalUpdateCommand.builder() + .name(newFestivalName) + .startDate(newStartDate) + .endDate(newEndDate) + .posterImageUrl(newPosterImageUrl) + .build(); // when festivalUpdateService.updateFestival(festivalId, command); @@ -87,12 +87,12 @@ void setUp() { LocalDate newStartDate = now.plusDays(1); LocalDate newEndDate = now.plusDays(1); String newPosterImageUrl = "https://image.com/new-image.png"; - var command = new FestivalUpdateCommand( - newFestivalName, - newStartDate, - newEndDate, - newPosterImageUrl - ); + var command = FestivalUpdateCommand.builder() + .name(newFestivalName) + .startDate(newStartDate) + .endDate(newEndDate) + .posterImageUrl(newPosterImageUrl) + .build(); // when festivalUpdateService.updateFestival(festivalId, command); diff --git a/backend/src/test/java/com/festago/festival/application/integration/query/FestivalDetailV1QueryServiceIntegrationTest.java b/backend/src/test/java/com/festago/festival/application/integration/query/FestivalDetailV1QueryServiceIntegrationTest.java index bdd1e587e..af1631c77 100644 --- a/backend/src/test/java/com/festago/festival/application/integration/query/FestivalDetailV1QueryServiceIntegrationTest.java +++ b/backend/src/test/java/com/festago/festival/application/integration/query/FestivalDetailV1QueryServiceIntegrationTest.java @@ -3,37 +3,39 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.SoftAssertions.assertSoftly; -import com.festago.artist.application.ArtistCommandService; -import com.festago.artist.dto.command.ArtistCreateCommand; +import com.festago.artist.domain.Artist; +import com.festago.artist.repository.ArtistRepository; import com.festago.common.exception.ErrorCode; import com.festago.common.exception.NotFoundException; import com.festago.festival.application.FestivalDetailV1QueryService; -import com.festago.festival.application.command.FestivalCreateService; +import com.festago.festival.domain.Festival; import com.festago.festival.dto.SocialMediaV1Response; -import com.festago.festival.dto.command.FestivalCreateCommand; -import com.festago.school.application.SchoolCommandService; -import com.festago.school.domain.SchoolRegion; -import com.festago.school.dto.SchoolCreateCommand; +import com.festago.festival.repository.FestivalRepository; +import com.festago.school.domain.School; +import com.festago.school.repository.SchoolRepository; import com.festago.socialmedia.domain.OwnerType; import com.festago.socialmedia.domain.SocialMediaType; import com.festago.socialmedia.repository.SocialMediaRepository; import com.festago.stage.application.command.StageCreateService; -import com.festago.stage.dto.command.StageCreateCommand; +import com.festago.stage.domain.Stage; +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.SocialMediaFixture; +import com.festago.support.fixture.StageArtistFixture; +import com.festago.support.fixture.StageFixture; import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) @SuppressWarnings("NonAsciiCharacters") -@Transactional class FestivalDetailV1QueryServiceIntegrationTest extends ApplicationIntegrationTest { @Autowired @@ -43,22 +45,28 @@ class FestivalDetailV1QueryServiceIntegrationTest extends ApplicationIntegration SocialMediaRepository socialMediaRepository; @Autowired - SchoolCommandService schoolCommandService; + SchoolRepository schoolRepository; @Autowired - FestivalCreateService festivalCreateService; + FestivalRepository festivalRepository; @Autowired StageCreateService stageCreateService; @Autowired - ArtistCommandService artistCommandService; + StageRepository stageRepository; + + @Autowired + StageArtistRepository stageArtistRepository; + + @Autowired + ArtistRepository artistRepository; LocalDate now = LocalDate.parse("2077-06-30"); - Long 테코대학교_축제_식별자; - Long 테코대학교_공연_없는_축제_식별자; - Long 우테대학교_축제_식별자; + Festival 테코대학교_축제; + Festival 테코대학교_공연_없는_축제; + Festival 우테대학교_축제; /** * 테코대학교 축제는 공연이 있는 3일 기간의 축제와 공연이 없는 당일 축제가 있다.
테코대학교는 소셜미디어에 인스타그램과 페이스북이 등록되어 있다.

우테대학교 축제는 공연이 @@ -66,37 +74,56 @@ class FestivalDetailV1QueryServiceIntegrationTest extends ApplicationIntegration */ @BeforeEach void setUp() { - Long 테코대학교_식별자 = createSchool("테코대학교", "teco.ac.kr"); - Long 우테대학교_식별자 = createSchool("우테대학교", "wote.ac.kr"); - - 테코대학교_축제_식별자 = festivalCreateService.createFestival(new FestivalCreateCommand( - "테코대학교 축제", now, now.plusDays(2), "https://school.com/image.com", 테코대학교_식별자 - )); - 테코대학교_공연_없는_축제_식별자 = festivalCreateService.createFestival(new FestivalCreateCommand( - "테코대학교 공연 없는 축제", now, now, "https://school.com/image.com", 테코대학교_식별자 - )); - 우테대학교_축제_식별자 = festivalCreateService.createFestival(new FestivalCreateCommand( - "우테대학교 축제", now, now, "https://school.com/image.com", 우테대학교_식별자 - )); - - Long 아티스트_식별자 = createArtist("아티스트A"); - - LocalDateTime ticketOpenTime = now.minusWeeks(1).atStartOfDay(); - stageCreateService.createStage(new StageCreateCommand( - 테코대학교_축제_식별자, now.atTime(18, 0), ticketOpenTime, List.of(아티스트_식별자) - )); - stageCreateService.createStage(new StageCreateCommand( - 테코대학교_축제_식별자, now.plusDays(1).atTime(18, 0), ticketOpenTime, List.of(아티스트_식별자) - )); - stageCreateService.createStage(new StageCreateCommand( - 테코대학교_축제_식별자, now.plusDays(2).atTime(18, 0), ticketOpenTime, List.of(아티스트_식별자) - )); - stageCreateService.createStage(new StageCreateCommand( - 우테대학교_축제_식별자, now.atTime(18, 0), ticketOpenTime, List.of(아티스트_식별자) - )); + School 테코대학교 = createSchool("테코대학교", "teco.ac.kr"); + School 우테대학교 = createSchool("우테대학교", "wote.ac.kr"); + + 테코대학교_축제 = festivalRepository.save(FestivalFixture.builder() + .startDate(now) + .endDate(now.plusDays(2)) + .school(테코대학교) + .build() + ); + 테코대학교_공연_없는_축제 = festivalRepository.save(FestivalFixture.builder() + .startDate(now) + .endDate(now) + .school(테코대학교) + .build() + ); + 우테대학교_축제 = festivalRepository.save(FestivalFixture.builder() + .startDate(now) + .endDate(now) + .school(우테대학교) + .build() + ); + Artist 아티스트A = createArtist("아티스트A"); + + Stage 테코대학교_축제_1일차_공연 = stageRepository.save(StageFixture.builder() + .festival(테코대학교_축제) + .startTime(now.atTime(18, 0)) + .build() + ); + Stage 테코대학교_축제_2일차_공연 = stageRepository.save(StageFixture.builder() + .festival(테코대학교_축제) + .startTime(now.plusDays(1).atTime(18, 0)) + .build() + ); + Stage 테코대학교_축제_3일차_공연 = stageRepository.save(StageFixture.builder() + .festival(테코대학교_축제) + .startTime(now.plusDays(2).atTime(18, 0)) + .build() + ); + Stage 우테대학교_축제_당일_공연 = stageRepository.save(StageFixture.builder() + .festival(우테대학교_축제) + .startTime(now.atTime(18, 0)) + .build() + ); + stageArtistRepository.save(StageArtistFixture.builder(테코대학교_축제_1일차_공연.getId(), 아티스트A.getId()).build()); + stageArtistRepository.save(StageArtistFixture.builder(테코대학교_축제_2일차_공연.getId(), 아티스트A.getId()).build()); + stageArtistRepository.save(StageArtistFixture.builder(테코대학교_축제_3일차_공연.getId(), 아티스트A.getId()).build()); + stageArtistRepository.save(StageArtistFixture.builder(우테대학교_축제_당일_공연.getId(), 아티스트A.getId()).build()); socialMediaRepository.save(SocialMediaFixture.builder() - .ownerId(테코대학교_식별자) + .ownerId(테코대학교.getId()) .ownerType(OwnerType.SCHOOL) .mediaType(SocialMediaType.INSTAGRAM) .name("총학생회 인스타그램") @@ -104,7 +131,7 @@ void setUp() { .url("https://instagram.com/테코대학교_총학생회") .build()); socialMediaRepository.save(SocialMediaFixture.builder() - .ownerId(테코대학교_식별자) + .ownerId(테코대학교.getId()) .ownerType(OwnerType.SCHOOL) .mediaType(SocialMediaType.FACEBOOK) .name("총학생회 페이스북") @@ -114,29 +141,31 @@ void setUp() { ); } - private Long createArtist(String artistName) { - return artistCommandService.save(new ArtistCreateCommand( - artistName, "https://image.com/profileImage.png", "https://image.com/background.png" - )); + private Artist createArtist(String artistName) { + Artist artist = ArtistFixture.builder() + .name(artistName) + .build(); + return artistRepository.save(artist); } - private Long createSchool(String schoolName, String domain) { - return schoolCommandService.createSchool(new SchoolCreateCommand( - schoolName, domain, SchoolRegion.서울, "https://image.com/logo.png", "https://image.com/background.png" - )); + private School createSchool(String schoolName, String domain) { + School school = SchoolFixture.builder() + .name(schoolName) + .domain(domain) + .build(); + return schoolRepository.save(school); } @Test void 축제의_식별자로_축제의_상세_조회를_할_수_있다() { // when - var response = festivalDetailV1QueryService.findFestivalDetail(테코대학교_축제_식별자); + var response = festivalDetailV1QueryService.findFestivalDetail(테코대학교_축제.getId()); // then assertSoftly(softly -> { - softly.assertThat(response.id()).isEqualTo(테코대학교_축제_식별자); + softly.assertThat(response.id()).isEqualTo(테코대학교_축제.getId()); softly.assertThat(response.startDate()).isEqualTo("2077-06-30"); softly.assertThat(response.endDate()).isEqualTo("2077-07-02"); - softly.assertThat(response.posterImageUrl()).isEqualTo("https://school.com/image.com"); softly.assertThat(response.school().name()).isEqualTo("테코대학교"); softly.assertThat(response.socialMedias()) .map(SocialMediaV1Response::name) @@ -148,11 +177,11 @@ private Long createSchool(String schoolName, String domain) { @Test void 축제에_공연이_없으면_응답의_공연에는_비어있는_컬렉션이_반환된다() { // when - var response = festivalDetailV1QueryService.findFestivalDetail(테코대학교_공연_없는_축제_식별자); + var response = festivalDetailV1QueryService.findFestivalDetail(테코대학교_공연_없는_축제.getId()); // then assertSoftly(softly -> { - softly.assertThat(response.id()).isEqualTo(테코대학교_공연_없는_축제_식별자); + softly.assertThat(response.id()).isEqualTo(테코대학교_공연_없는_축제.getId()); softly.assertThat(response.stages()).isEmpty(); softly.assertThat(response.socialMedias()) .map(SocialMediaV1Response::name) @@ -163,11 +192,11 @@ private Long createSchool(String schoolName, String domain) { @Test void 축제에_속한_학교에_소셜미디어가_없으면_소셜미디어에는_비어있는_컬렉션이_반환된다() { // when - var response = festivalDetailV1QueryService.findFestivalDetail(우테대학교_축제_식별자); + var response = festivalDetailV1QueryService.findFestivalDetail(우테대학교_축제.getId()); // then assertSoftly(softly -> { - softly.assertThat(response.id()).isEqualTo(우테대학교_축제_식별자); + softly.assertThat(response.id()).isEqualTo(우테대학교_축제.getId()); softly.assertThat(response.socialMedias()).isEmpty(); softly.assertThat(response.stages()).hasSize(1); }); diff --git a/backend/src/test/java/com/festago/festival/application/integration/query/FestivalV1QueryServiceIntegrationTest.java b/backend/src/test/java/com/festago/festival/application/integration/query/FestivalV1QueryServiceIntegrationTest.java index c0394e17f..46b73d75b 100644 --- a/backend/src/test/java/com/festago/festival/application/integration/query/FestivalV1QueryServiceIntegrationTest.java +++ b/backend/src/test/java/com/festago/festival/application/integration/query/FestivalV1QueryServiceIntegrationTest.java @@ -5,16 +5,20 @@ import static org.mockito.BDDMockito.given; import com.festago.festival.application.FestivalV1QueryService; -import com.festago.festival.application.command.FestivalCreateService; +import com.festago.festival.domain.Festival; import com.festago.festival.dto.FestivalV1QueryRequest; import com.festago.festival.dto.FestivalV1Response; -import com.festago.festival.dto.command.FestivalCreateCommand; import com.festago.festival.repository.FestivalFilter; -import com.festago.school.application.SchoolCommandService; +import com.festago.festival.repository.FestivalInfoRepository; +import com.festago.festival.repository.FestivalRepository; +import com.festago.school.domain.School; import com.festago.school.domain.SchoolRegion; -import com.festago.school.dto.SchoolCreateCommand; +import com.festago.school.repository.SchoolRepository; 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 java.time.Clock; import java.time.LocalDate; import java.util.List; @@ -29,22 +33,22 @@ import org.junit.jupiter.params.provider.MethodSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; -import org.springframework.transaction.annotation.Transactional; -// TODO Repository 사용하지 않고 Service로 데이터 세팅하도록 변경 @DisplayNameGeneration(ReplaceUnderscores.class) @SuppressWarnings("NonAsciiCharacters") -@Transactional class FestivalV1QueryServiceIntegrationTest extends ApplicationIntegrationTest { @Autowired FestivalV1QueryService festivalV1QueryService; @Autowired - FestivalCreateService festivalCreateService; + FestivalRepository festivalRepository; @Autowired - SchoolCommandService schoolCommandService; + SchoolRepository schoolRepository; + + @Autowired + FestivalInfoRepository festivalInfoRepository; @Autowired Clock clock; @@ -52,16 +56,16 @@ class FestivalV1QueryServiceIntegrationTest extends ApplicationIntegrationTest { LocalDate now = LocalDate.parse("2077-07-10"); // 진행중 - Long 서울대학교_8일_12일_축제_식별자; - Long 서울대학교_6일_12일_축제_식별자; - Long 대구대학교_9일_12일_축제_식별자; - Long 부산대학교_6일_13일_축제_식별자; - Long 부산대학교_6일_12일_축제_식별자; + Festival 서울대학교_8일_12일_축제; + Festival 서울대학교_6일_12일_축제; + Festival 대구대학교_9일_12일_축제; + Festival 부산대학교_6일_13일_축제; + Festival 부산대학교_6일_12일_축제; // 진행 예정 - Long 대구대학교_13일_14일_축제_식별자; - Long 대구대학교_12일_14일_축제_식별자; - Long 부산대학교_12일_14일_축제_식별자; + Festival 대구대학교_13일_14일_축제; + Festival 대구대학교_12일_14일_축제; + Festival 부산대학교_12일_14일_축제; /** * 현재 시간

2023년 7월 10일

@@ -74,40 +78,40 @@ class FestivalV1QueryServiceIntegrationTest extends ApplicationIntegrationTest { */ @BeforeEach void setting() { - Long 서울대학교_식별자 = createSchool("서울대학교", "seoul.ac.kr", SchoolRegion.서울); - Long 부산대학교_식별자 = createSchool("부산대학교", "busan.ac.kr", SchoolRegion.부산); - Long 대구대학교_식별자 = createSchool("대구대학교", "daegu.ac.kr", SchoolRegion.대구); + School 서울대학교 = createSchool("서울대학교", SchoolRegion.서울); + School 부산대학교 = createSchool("부산대학교", SchoolRegion.부산); + School 대구대학교 = createSchool("대구대학교", SchoolRegion.대구); // 진행 중 - 서울대학교_8일_12일_축제_식별자 = createFestival("서울대학교_8일_12일_축제", now.minusDays(2), now.plusDays(2), 서울대학교_식별자); - 서울대학교_6일_12일_축제_식별자 = createFestival("서울대학교_6일_12일_축제", now.minusDays(4), now.plusDays(2), 서울대학교_식별자); - 대구대학교_9일_12일_축제_식별자 = createFestival("대구대학교_9일_12일_축제", now.minusDays(1), now.plusDays(2), 대구대학교_식별자); - 부산대학교_6일_13일_축제_식별자 = createFestival("부산대학교_6일_13일_축제", now.minusDays(4), now.plusDays(3), 부산대학교_식별자); - 부산대학교_6일_12일_축제_식별자 = createFestival("부산대학교_6일_12일_축제", now.minusDays(4), now.plusDays(2), 부산대학교_식별자); + 서울대학교_8일_12일_축제 = createFestival("서울대학교_8일_12일_축제", now.minusDays(2), now.plusDays(2), 서울대학교); + 서울대학교_6일_12일_축제 = createFestival("서울대학교_6일_12일_축제", now.minusDays(4), now.plusDays(2), 서울대학교); + 대구대학교_9일_12일_축제 = createFestival("대구대학교_9일_12일_축제", now.minusDays(1), now.plusDays(2), 대구대학교); + 부산대학교_6일_13일_축제 = createFestival("부산대학교_6일_13일_축제", now.minusDays(4), now.plusDays(3), 부산대학교); + 부산대학교_6일_12일_축제 = createFestival("부산대학교_6일_12일_축제", now.minusDays(4), now.plusDays(2), 부산대학교); // 진행 예정 - 대구대학교_13일_14일_축제_식별자 = createFestival("대구대학교_13일_14일_축제", now.plusDays(3), now.plusDays(4), 대구대학교_식별자); - 부산대학교_12일_14일_축제_식별자 = createFestival("부산대학교_12일_14일_축제", now.plusDays(2), now.plusDays(4), 부산대학교_식별자); - 대구대학교_12일_14일_축제_식별자 = createFestival("대구대학교_12일_14일_축제", now.plusDays(2), now.plusDays(4), 대구대학교_식별자); + 대구대학교_13일_14일_축제 = createFestival("대구대학교_13일_14일_축제", now.plusDays(3), now.plusDays(4), 대구대학교); + 부산대학교_12일_14일_축제 = createFestival("부산대학교_12일_14일_축제", now.plusDays(2), now.plusDays(4), 부산대학교); + 대구대학교_12일_14일_축제 = createFestival("대구대학교_12일_14일_축제", now.plusDays(2), now.plusDays(4), 대구대학교); given(clock.instant()) .willReturn(TimeInstantProvider.from(now)); } - private Long createSchool(String schoolName, String domain, SchoolRegion region) { - return schoolCommandService.createSchool(new SchoolCreateCommand( - schoolName, - domain, - region, - "https://image.com/logo.png", - "https://image.com/background.png" - )); + private School createSchool(String schoolName, SchoolRegion region) { + return schoolRepository.save(SchoolFixture.builder().name(schoolName).region(region).build()); } - private Long createFestival(String festivalName, LocalDate startDate, LocalDate endDate, Long schoolId) { - return festivalCreateService.createFestival(new FestivalCreateCommand( - festivalName, startDate, endDate, "https://image.com/posterImage.png", schoolId - )); + private Festival createFestival(String festivalName, LocalDate startDate, LocalDate endDate, School school) { + Festival festival = festivalRepository.save(FestivalFixture.builder() + .name(festivalName) + .startDate(startDate) + .endDate(endDate) + .school(school) + .build() + ); + festivalInfoRepository.save(FestivalQueryInfoFixture.builder().festivalId(festival.getId()).build()); + return festival; } @Nested @@ -170,9 +174,9 @@ class 지역_필터_미적용 { assertThat(response.getContent()) .map(FestivalV1Response::id) .containsExactly( - 부산대학교_12일_14일_축제_식별자, - 대구대학교_12일_14일_축제_식별자, - 대구대학교_13일_14일_축제_식별자 + 부산대학교_12일_14일_축제.getId(), + 대구대학교_12일_14일_축제.getId(), + 대구대학교_13일_14일_축제.getId() ); } @@ -188,11 +192,11 @@ class 지역_필터_미적용 { assertThat(response.getContent()) .map(FestivalV1Response::id) .containsExactly( - 대구대학교_9일_12일_축제_식별자, - 서울대학교_8일_12일_축제_식별자, - 서울대학교_6일_12일_축제_식별자, - 부산대학교_6일_13일_축제_식별자, - 부산대학교_6일_12일_축제_식별자 + 대구대학교_9일_12일_축제.getId(), + 서울대학교_8일_12일_축제.getId(), + 서울대학교_6일_12일_축제.getId(), + 부산대학교_6일_13일_축제.getId(), + 부산대학교_6일_12일_축제.getId() ); } @@ -216,9 +220,9 @@ class 지역_필터_미적용 { softly.assertThat(secondResponse.getContent()) .map(FestivalV1Response::id) .containsExactly( - 서울대학교_6일_12일_축제_식별자, - 부산대학교_6일_13일_축제_식별자, - 부산대학교_6일_12일_축제_식별자 + 서울대학교_6일_12일_축제.getId(), + 부산대학교_6일_13일_축제.getId(), + 부산대학교_6일_12일_축제.getId() ); }); } diff --git a/backend/src/test/java/com/festago/festival/application/integration/query/PopularFestivalV1QueryServiceIntegrationTest.java b/backend/src/test/java/com/festago/festival/application/integration/query/PopularFestivalV1QueryServiceIntegrationTest.java index d85f1ccaf..e19c11fe6 100644 --- a/backend/src/test/java/com/festago/festival/application/integration/query/PopularFestivalV1QueryServiceIntegrationTest.java +++ b/backend/src/test/java/com/festago/festival/application/integration/query/PopularFestivalV1QueryServiceIntegrationTest.java @@ -3,14 +3,16 @@ import static org.assertj.core.api.Assertions.assertThat; import com.festago.festival.application.PopularFestivalV1QueryService; -import com.festago.festival.application.command.FestivalCreateService; +import com.festago.festival.domain.Festival; import com.festago.festival.dto.FestivalV1Response; -import com.festago.festival.dto.command.FestivalCreateCommand; -import com.festago.school.application.SchoolCommandService; -import com.festago.school.domain.SchoolRegion; -import com.festago.school.dto.SchoolCreateCommand; +import com.festago.festival.repository.FestivalInfoRepository; +import com.festago.festival.repository.FestivalRepository; +import com.festago.school.domain.School; +import com.festago.school.repository.SchoolRepository; import com.festago.support.ApplicationIntegrationTest; -import java.time.LocalDate; +import com.festago.support.fixture.FestivalFixture; +import com.festago.support.fixture.FestivalQueryInfoFixture; +import com.festago.support.fixture.SchoolFixture; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; @@ -25,64 +27,61 @@ class PopularFestivalV1QueryServiceIntegrationTest extends ApplicationIntegratio PopularFestivalV1QueryService popularQueryService; @Autowired - FestivalCreateService festivalCreateService; + FestivalRepository festivalRepository; @Autowired - SchoolCommandService schoolCommandService; + FestivalInfoRepository festivalInfoRepository; - LocalDate now = LocalDate.parse("2077-06-30"); + @Autowired + SchoolRepository schoolRepository; - Long 대학교_식별자; + School 대학교; - Long 첫번째로_저장된_축제_식별자; - Long 두번째로_저장된_축제_식별자; - Long 세번째로_저장된_축제_식별자; - Long 네번째로_저장된_축제_식별자; - Long 다섯번째로_저장된_축제_식별자; - Long 여섯번째로_저장된_축제_식별자; - Long 일곱번째로_저장된_축제_식별자; - Long 여덟번째로_저장된_축제_식별자; + Festival 첫번째로_저장된_축제; + Festival 두번째로_저장된_축제; + Festival 세번째로_저장된_축제; + Festival 네번째로_저장된_축제; + Festival 다섯번째로_저장된_축제; + Festival 여섯번째로_저장된_축제; + Festival 일곱번째로_저장된_축제; + Festival 여덟번째로_저장된_축제; @BeforeEach void setUp() { - 대학교_식별자 = schoolCommandService.createSchool(new SchoolCreateCommand( - "테코대학교", - "teco.ac.kr", - SchoolRegion.서울, - "https://image.com/logo.png", - "https://image.com/background.png" - )); + 대학교 = schoolRepository.save(SchoolFixture.builder().build()); - 첫번째로_저장된_축제_식별자 = festivalCreateService.createFestival(getFestivalCreateCommand("첫번째로 저장된 축제")); - 두번째로_저장된_축제_식별자 = festivalCreateService.createFestival(getFestivalCreateCommand("두번째로 저장된 축제")); - 세번째로_저장된_축제_식별자 = festivalCreateService.createFestival(getFestivalCreateCommand("세번째로 저장된 축제")); - 네번째로_저장된_축제_식별자 = festivalCreateService.createFestival(getFestivalCreateCommand("네번째로 저장된 축제")); - 다섯번째로_저장된_축제_식별자 = festivalCreateService.createFestival(getFestivalCreateCommand("다섯번째로 저장된 축제")); - 여섯번째로_저장된_축제_식별자 = festivalCreateService.createFestival(getFestivalCreateCommand("여섯번째로 저장된 축제")); - 일곱번째로_저장된_축제_식별자 = festivalCreateService.createFestival(getFestivalCreateCommand("일곱번째로 저장된 축제")); - 여덟번째로_저장된_축제_식별자 = festivalCreateService.createFestival(getFestivalCreateCommand("여덟번째로 저장된 축제")); + 첫번째로_저장된_축제 = createFestival(); + 두번째로_저장된_축제 = createFestival(); + 세번째로_저장된_축제 = createFestival(); + 네번째로_저장된_축제 = createFestival(); + 다섯번째로_저장된_축제 = createFestival(); + 여섯번째로_저장된_축제 = createFestival(); + 일곱번째로_저장된_축제 = createFestival(); + 여덟번째로_저장된_축제 = createFestival(); } - private FestivalCreateCommand getFestivalCreateCommand(String schoolName) { - return new FestivalCreateCommand(schoolName, now, now, "https://image.com/posterImage.png", 대학교_식별자); + private Festival createFestival() { + Festival festival = festivalRepository.save(FestivalFixture.builder().school(대학교).build()); + festivalInfoRepository.save(FestivalQueryInfoFixture.builder().festivalId(festival.getId()).build()); + return festival; } @Test void 인기_축제는_7개까지_반환되고_식별자의_내림차순으로_정렬되어_조회된다() { - // given && when + // when var expect = popularQueryService.findPopularFestivals().content(); // then assertThat(expect) .map(FestivalV1Response::id) .containsExactly( - 여덟번째로_저장된_축제_식별자, - 일곱번째로_저장된_축제_식별자, - 여섯번째로_저장된_축제_식별자, - 다섯번째로_저장된_축제_식별자, - 네번째로_저장된_축제_식별자, - 세번째로_저장된_축제_식별자, - 두번째로_저장된_축제_식별자 + 여덟번째로_저장된_축제.getId(), + 일곱번째로_저장된_축제.getId(), + 여섯번째로_저장된_축제.getId(), + 다섯번째로_저장된_축제.getId(), + 네번째로_저장된_축제.getId(), + 세번째로_저장된_축제.getId(), + 두번째로_저장된_축제.getId() ); } } diff --git a/backend/src/test/java/com/festago/school/application/SchoolCommandServiceTest.java b/backend/src/test/java/com/festago/school/application/SchoolCommandServiceTest.java index b67b5390b..3b8919481 100644 --- a/backend/src/test/java/com/festago/school/application/SchoolCommandServiceTest.java +++ b/backend/src/test/java/com/festago/school/application/SchoolCommandServiceTest.java @@ -10,8 +10,8 @@ import com.festago.common.exception.NotFoundException; import com.festago.school.domain.School; import com.festago.school.domain.SchoolRegion; -import com.festago.school.dto.SchoolCreateCommand; -import com.festago.school.dto.SchoolUpdateCommand; +import com.festago.school.dto.command.SchoolCreateCommand; +import com.festago.school.dto.command.SchoolUpdateCommand; import com.festago.school.repository.MemorySchoolRepository; import com.festago.school.repository.SchoolRepository; import com.festago.support.fixture.SchoolFixture; diff --git a/backend/src/test/java/com/festago/socialmedia/application/SocialMediaCommandServiceTest.java b/backend/src/test/java/com/festago/socialmedia/application/SocialMediaCommandServiceTest.java index cbdc39304..8b6c32e5e 100644 --- a/backend/src/test/java/com/festago/socialmedia/application/SocialMediaCommandServiceTest.java +++ b/backend/src/test/java/com/festago/socialmedia/application/SocialMediaCommandServiceTest.java @@ -67,14 +67,14 @@ class createSocialMedia { .build()); // when & then - var command = new SocialMediaCreateCommand( - socialMedia.getOwnerId(), - socialMedia.getOwnerType(), - socialMedia.getMediaType(), - socialMedia.getName(), - socialMedia.getLogoUrl(), - socialMedia.getUrl() - ); + var command = SocialMediaCreateCommand.builder() + .ownerId(socialMedia.getId()) + .ownerType(socialMedia.getOwnerType()) + .socialMediaType(socialMedia.getMediaType()) + .name(socialMedia.getName()) + .logoUrl(socialMedia.getLogoUrl()) + .url(socialMedia.getUrl()) + .build(); assertThatThrownBy(() -> socialMediaCommandService.createSocialMedia(command)) .isInstanceOf(BadRequestException.class) .hasMessage(ErrorCode.DUPLICATE_SOCIAL_MEDIA.getMessage()); @@ -84,14 +84,14 @@ class createSocialMedia { @Test void 추가하려는_소셜미디어의_owner가_존재하지_않으면_예외() { // when & then - var command = new SocialMediaCreateCommand( - 4885L, - OwnerType.SCHOOL, - SocialMediaType.INSTAGRAM, - "테코대학교 인스타그램", - "https://image.com/logo.png", - "https://instagram.com/tecodaehak" - ); + var command = SocialMediaCreateCommand.builder() + .ownerId(4885L) + .ownerType(OwnerType.SCHOOL) + .socialMediaType(SocialMediaType.INSTAGRAM) + .name("테코대학교 인스타그램") + .logoUrl("https://image.com/logo.png") + .url("https://instagram.com/tecodaehak") + .build(); assertThatThrownBy(() -> socialMediaCommandService.createSocialMedia(command)) .isInstanceOf(NotFoundException.class) .hasMessage(ErrorCode.SCHOOL_NOT_FOUND.getMessage()); @@ -103,14 +103,14 @@ class createSocialMedia { School 테코대학교 = schoolRepository.save(SchoolFixture.builder().name("테코대학교").build()); // when - var command = new SocialMediaCreateCommand( - 테코대학교.getId(), - OwnerType.SCHOOL, - SocialMediaType.INSTAGRAM, - "테코대학교 인스타그램", - "https://image.com/logo.png", - "https://instagram.com/tecodaehak" - ); + var command = SocialMediaCreateCommand.builder() + .ownerId(테코대학교.getId()) + .ownerType(OwnerType.SCHOOL) + .socialMediaType(SocialMediaType.INSTAGRAM) + .name("테코대학교 인스타그램") + .logoUrl("https://image.com/logo.png") + .url("https://instagram.com/tecodaehak") + .build(); Long socialMediaId = socialMediaCommandService.createSocialMedia(command); // then @@ -124,11 +124,11 @@ class updateSocialMedia { @Test void 소셜미디어의_식별자에_대한_소셜미디어가_존재하지_않으면_예외() { // when & then - var command = new SocialMediaUpdateCommand( - "테코대학교 인스타그램", - "https://instagram.com/tecodaehak", - "https://image.com/logo.png" - ); + var command = SocialMediaUpdateCommand.builder() + .name("테코대학교 인스타그램") + .url("https://instagram.com/tecodaehak") + .logoUrl("https://image.com/logo.png") + .build(); assertThatThrownBy(() -> socialMediaCommandService.updateSocialMedia(4885L, command)) .isInstanceOf(NotFoundException.class) .hasMessage(ErrorCode.SOCIAL_MEDIA_NOT_FOUND.getMessage()); @@ -146,11 +146,11 @@ class updateSocialMedia { .build()); // when - var command = new SocialMediaUpdateCommand( - "테코대학교 인스타그램", - "https://instagram.com/tecodaehak", - "https://image.com/logo.png" - ); + var command = SocialMediaUpdateCommand.builder() + .name("테코대학교 인스타그램") + .url("https://instagram.com/tecodaehak") + .logoUrl("https://image.com/logo.png") + .build(); socialMediaCommandService.updateSocialMedia(socialMedia.getId(), command); // then diff --git a/backend/src/test/java/com/festago/stage/application/command/StageCommandServiceIntegrationTest.java b/backend/src/test/java/com/festago/stage/application/command/StageCommandServiceIntegrationTest.java index 3dbdf46b7..1973b438e 100644 --- a/backend/src/test/java/com/festago/stage/application/command/StageCommandServiceIntegrationTest.java +++ b/backend/src/test/java/com/festago/stage/application/command/StageCommandServiceIntegrationTest.java @@ -105,12 +105,12 @@ class createStage { @Test void 공연을_생성하면_StageQueryInfo가_저장된다() { // given - var command = new StageCreateCommand( - 테코대학교_축제_식별자, - festivalStartDate.atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - List.of(에픽하이_식별자, 소녀시대_식별자, 뉴진스_식별자) - ); + var command = StageCreateCommand.builder() + .festivalId(테코대학교_축제_식별자) + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(에픽하이_식별자, 소녀시대_식별자, 뉴진스_식별자)) + .build(); // when Long stageId = stageCreateService.createStage(command); @@ -122,12 +122,12 @@ class createStage { @Test void 공연을_생성하면_FestivalQueryInfo가_갱신된다() { // given - var command = new StageCreateCommand( - 테코대학교_축제_식별자, - festivalStartDate.atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - List.of(에픽하이_식별자, 소녀시대_식별자, 뉴진스_식별자) - ); + var command = StageCreateCommand.builder() + .festivalId(테코대학교_축제_식별자) + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(에픽하이_식별자, 소녀시대_식별자, 뉴진스_식별자)) + .build(); // when FestivalQueryInfo previosFestivalQueryInfo = festivalInfoRepository.findByFestivalId(테코대학교_축제_식별자).get(); @@ -144,18 +144,18 @@ class createStage { @Test void 공연이_여러_개_추가되면_FestivalQueryInfo에_추가된_공연의_ArtistInfo가_갱신된다() throws Exception { // given - var firstCommand = new StageCreateCommand( - 테코대학교_축제_식별자, - festivalStartDate.atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - List.of(에픽하이_식별자) - ); - var secondCommand = new StageCreateCommand( - 테코대학교_축제_식별자, - festivalStartDate.plusDays(1).atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - List.of(소녀시대_식별자) - ); + var firstCommand = StageCreateCommand.builder() + .festivalId(테코대학교_축제_식별자) + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(에픽하이_식별자)) + .build(); + var secondCommand = StageCreateCommand.builder() + .festivalId(테코대학교_축제_식별자) + .startTime(festivalStartDate.plusDays(1).atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(소녀시대_식별자)) + .build(); // when stageCreateService.createStage(firstCommand); @@ -174,18 +174,18 @@ class createStage { @Test void 공연이_여러_개_추가될때_공연에_중복된_아티스트가_있어도_FestivalQueryInfo에는_중복이_없다() throws Exception { // given - var firstCommand = new StageCreateCommand( - 테코대학교_축제_식별자, - festivalStartDate.atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - List.of(에픽하이_식별자, 소녀시대_식별자, 뉴진스_식별자) - ); - var secondCommand = new StageCreateCommand( - 테코대학교_축제_식별자, - festivalStartDate.plusDays(1).atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - List.of(에픽하이_식별자, 소녀시대_식별자, 뉴진스_식별자) - ); + var firstCommand = StageCreateCommand.builder() + .festivalId(테코대학교_축제_식별자) + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(에픽하이_식별자, 소녀시대_식별자, 뉴진스_식별자)) + .build(); + var secondCommand = StageCreateCommand.builder() + .festivalId(테코대학교_축제_식별자) + .startTime(festivalStartDate.plusDays(1).atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(에픽하이_식별자, 소녀시대_식별자, 뉴진스_식별자)) + .build(); // when stageCreateService.createStage(firstCommand); @@ -209,22 +209,22 @@ class updateStage { @BeforeEach void setUp() { - 테코대학교_축제_공연_식별자 = stageCreateService.createStage(new StageCreateCommand( - 테코대학교_축제_식별자, - festivalStartDate.atTime(18, 0), - now.minusWeeks(1), - List.of(에픽하이_식별자, 소녀시대_식별자, 뉴진스_식별자) - )); + 테코대학교_축제_공연_식별자 = stageCreateService.createStage(StageCreateCommand.builder() + .festivalId(테코대학교_축제_식별자) + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(에픽하이_식별자, 소녀시대_식별자, 뉴진스_식별자)) + .build()); } @Test void 공연을_수정하면_StageQueryInfo가_갱신된다() throws Exception { // given - var command = new StageUpdateCommand( - festivalStartDate.atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - List.of(에픽하이_식별자, 소녀시대_식별자) - ); + var command = StageUpdateCommand.builder() + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(에픽하이_식별자, 소녀시대_식별자)) + .build(); // when stageUpdateService.updateStage(테코대학교_축제_공연_식별자, command); @@ -242,11 +242,11 @@ void setUp() { @Test void 공연을_수정하면_FestivalQueryInfo가_갱신된다() throws Exception { // given - var command = new StageUpdateCommand( - festivalStartDate.atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - List.of(에픽하이_식별자, 소녀시대_식별자) - ); + var command = StageUpdateCommand.builder() + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(에픽하이_식별자, 소녀시대_식별자)) + .build(); // when stageUpdateService.updateStage(테코대학교_축제_공연_식별자, command); @@ -268,12 +268,12 @@ class deleteStage { @BeforeEach void setUp() { - 테코대학교_축제_공연_식별자 = stageCreateService.createStage(new StageCreateCommand( - 테코대학교_축제_식별자, - festivalStartDate.atTime(18, 0), - now.minusWeeks(1), - List.of(에픽하이_식별자, 소녀시대_식별자, 뉴진스_식별자) - )); + 테코대학교_축제_공연_식별자 = stageCreateService.createStage(StageCreateCommand.builder() + .festivalId(테코대학교_축제_식별자) + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(에픽하이_식별자, 소녀시대_식별자, 뉴진스_식별자)) + .build()); } @Test diff --git a/backend/src/test/java/com/festago/stage/application/command/StageCreateServiceTest.java b/backend/src/test/java/com/festago/stage/application/command/StageCreateServiceTest.java index 91f2618f5..e49fa58ff 100644 --- a/backend/src/test/java/com/festago/stage/application/command/StageCreateServiceTest.java +++ b/backend/src/test/java/com/festago/stage/application/command/StageCreateServiceTest.java @@ -36,13 +36,20 @@ class StageCreateServiceTest { StageRepository stageRepository; + FestivalRepository festivalRepository; + ArtistRepository artistRepository; + StageArtistRepository stageArtistRepository; + StageCreateService stageCreateService; + LocalDate festivalStartDate = LocalDate.parse("2077-06-30"); LocalDate festivalEndDate = LocalDate.parse("2077-07-02"); + Festival 테코대학교_축제; + Artist 에픽하이; Artist 소녀시대; Artist 뉴진스; @@ -80,12 +87,12 @@ class createStage { @Test void ArtistIds에_중복이_있으면_예외() { // given - var command = new StageCreateCommand( - 테코대학교_축제.getId(), - festivalStartDate.atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - List.of(에픽하이.getId(), 에픽하이.getId()) - ); + var command = StageCreateCommand.builder() + .festivalId(테코대학교_축제.getId()) + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(에픽하이.getId(), 에픽하이.getId())) + .build(); // then // when & then @@ -100,12 +107,12 @@ class createStage { List artistIds = LongStream.rangeClosed(1, 11) .boxed() .toList(); - var command = new StageCreateCommand( - 테코대학교_축제.getId(), - festivalStartDate.atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - artistIds - ); + var command = StageCreateCommand.builder() + .festivalId(테코대학교_축제.getId()) + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(artistIds) + .build(); // when & then assertThatThrownBy(() -> stageCreateService.createStage(command)) @@ -120,12 +127,12 @@ class createStage { .mapToObj(it -> artistRepository.save(ArtistFixture.builder().build())) .map(Artist::getId) .toList(); - var command = new StageCreateCommand( - 테코대학교_축제.getId(), - festivalStartDate.atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - artistIds - ); + var command = StageCreateCommand.builder() + .festivalId(테코대학교_축제.getId()) + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(artistIds) + .build(); // when assertThatNoException().isThrownBy(() -> stageCreateService.createStage(command)); @@ -134,12 +141,12 @@ class createStage { @Test void Festival_식별자에_대한_Festival이_없으면_예외() { // given - var command = new StageCreateCommand( - 4885L, - festivalStartDate.atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - List.of(에픽하이.getId(), 소녀시대.getId(), 뉴진스.getId()) - ); + var command = StageCreateCommand.builder() + .festivalId(4885L) + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(에픽하이.getId(), 소녀시대.getId(), 뉴진스.getId())) + .build(); // when & then assertThatThrownBy(() -> stageCreateService.createStage(command)) @@ -150,12 +157,12 @@ class createStage { @Test void 아티스트_식별자_목록에_존재하지_않은_아티스트가_있으면_예외() { // given - var command = new StageCreateCommand( - 테코대학교_축제.getId(), - festivalStartDate.atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - List.of(에픽하이.getId(), 소녀시대.getId(), 뉴진스.getId(), 4885L) - ); + var command = StageCreateCommand.builder() + .festivalId(테코대학교_축제.getId()) + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(에픽하이.getId(), 소녀시대.getId(), 뉴진스.getId(), 4885L)) + .build(); // when & then assertThatThrownBy(() -> stageCreateService.createStage(command)) @@ -166,12 +173,12 @@ class createStage { @Test void 성공하면_생성한_Stage에_대한_StageArtist가_저장된다() { // given - var command = new StageCreateCommand( - 테코대학교_축제.getId(), - festivalStartDate.atTime(18, 0), - festivalStartDate.minusWeeks(1).atStartOfDay(), - List.of(에픽하이.getId(), 소녀시대.getId(), 뉴진스.getId()) - ); + var command = StageCreateCommand.builder() + .festivalId(테코대학교_축제.getId()) + .startTime(festivalStartDate.atTime(18, 0)) + .ticketOpenTime(festivalStartDate.minusWeeks(1).atStartOfDay()) + .artistIds(List.of(에픽하이.getId(), 소녀시대.getId(), 뉴진스.getId())) + .build(); // when Long stageId = stageCreateService.createStage(command); diff --git a/backend/src/test/java/com/festago/stage/application/command/StageUpdateServiceTest.java b/backend/src/test/java/com/festago/stage/application/command/StageUpdateServiceTest.java index ddc8c8600..cf5e173ec 100644 --- a/backend/src/test/java/com/festago/stage/application/command/StageUpdateServiceTest.java +++ b/backend/src/test/java/com/festago/stage/application/command/StageUpdateServiceTest.java @@ -82,11 +82,11 @@ class updateStage { @Test void ArtistIds에_중복이_있으면_예외() { // given - var command = new StageUpdateCommand( - stageStartTime.minusHours(1), - ticketOpenTime.minusDays(1), - List.of(에픽하이.getId(), 에픽하이.getId()) - ); + var command = StageUpdateCommand.builder() + .startTime(stageStartTime.minusHours(1)) + .ticketOpenTime(ticketOpenTime.minusDays(1)) + .artistIds(List.of(에픽하이.getId(), 에픽하이.getId())) + .build(); // then // when & then @@ -101,11 +101,11 @@ class updateStage { List artistIds = LongStream.rangeClosed(1, 11) .boxed() .toList(); - var command = new StageUpdateCommand( - stageStartTime.minusHours(1), - ticketOpenTime.minusDays(1), - artistIds - ); + var command = StageUpdateCommand.builder() + .startTime(stageStartTime.minusHours(1)) + .ticketOpenTime(ticketOpenTime.minusDays(1)) + .artistIds(artistIds) + .build(); // when & then assertThatThrownBy(() -> stageUpdateService.updateStage(테코대학교_축제_공연.getId(), command)) @@ -120,11 +120,11 @@ class updateStage { .mapToObj(it -> artistRepository.save(ArtistFixture.builder().build())) .map(Artist::getId) .toList(); - var command = new StageUpdateCommand( - stageStartTime.minusHours(1), - ticketOpenTime.minusDays(1), - artistIds - ); + var command = StageUpdateCommand.builder() + .startTime(stageStartTime.minusHours(1)) + .ticketOpenTime(ticketOpenTime.minusDays(1)) + .artistIds(artistIds) + .build(); // when assertThatNoException() @@ -135,11 +135,11 @@ class updateStage { void Stage에_대한_식별자가_없으면_예외() { // given Long stageId = 4885L; - var command = new StageUpdateCommand( - stageStartTime.minusHours(1), - ticketOpenTime.minusDays(1), - List.of(에픽하이.getId(), 소녀시대.getId(), 뉴진스.getId()) - ); + var command = StageUpdateCommand.builder() + .startTime(stageStartTime.minusHours(1)) + .ticketOpenTime(ticketOpenTime.minusDays(1)) + .artistIds(List.of(에픽하이.getId(), 소녀시대.getId(), 뉴진스.getId())) + .build(); // when & then assertThatThrownBy(() -> stageUpdateService.updateStage(stageId, command)) @@ -150,11 +150,11 @@ class updateStage { @Test void 아티스트_식별자_목록에_존재하지_않은_아티스트가_있으면_예외() { // given - var command = new StageUpdateCommand( - stageStartTime.minusHours(1), - ticketOpenTime.minusDays(1), - List.of(에픽하이.getId(), 소녀시대.getId(), 뉴진스.getId(), 4885L) - ); + var command = StageUpdateCommand.builder() + .startTime(stageStartTime.minusHours(1)) + .ticketOpenTime(ticketOpenTime.minusDays(1)) + .artistIds(List.of(에픽하이.getId(), 소녀시대.getId(), 뉴진스.getId(), 4885L)) + .build(); // when & then assertThatThrownBy(() -> stageUpdateService.updateStage(테코대학교_축제_공연.getId(), command)) @@ -165,11 +165,11 @@ class updateStage { @Test void 성공하면_수정된_Stage에_반영된다() { // given - var command = new StageUpdateCommand( - stageStartTime.minusHours(1), - ticketOpenTime.minusDays(1), - List.of(에픽하이.getId(), 소녀시대.getId(), 뉴진스.getId()) - ); + var command = StageUpdateCommand.builder() + .startTime(stageStartTime.minusHours(1)) + .ticketOpenTime(ticketOpenTime.minusDays(1)) + .artistIds(List.of(에픽하이.getId(), 소녀시대.getId(), 뉴진스.getId())) + .build(); // when stageUpdateService.updateStage(테코대학교_축제_공연.getId(), command); @@ -183,11 +183,11 @@ class updateStage { @Test void 성공하면_수정된_Stage에_대한_StageArtist가_갱신된다() { // given - var command = new StageUpdateCommand( - stageStartTime.minusHours(1), - ticketOpenTime.minusDays(1), - List.of(에픽하이.getId()) - ); + var command = StageUpdateCommand.builder() + .startTime(stageStartTime.minusHours(1)) + .ticketOpenTime(ticketOpenTime.minusDays(1)) + .artistIds(List.of(에픽하이.getId())) + .build(); // when stageUpdateService.updateStage(테코대학교_축제_공연.getId(), command);