From 668ed15ccf6f90d5be3cfbc1d1f60d4d3a78e758 Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 5 Oct 2023 02:01:10 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=EC=8B=A0=EB=A2=B0=EB=8F=84=EC=97=90=20double=20=EB=8C=80?= =?UTF-8?q?=EC=8B=A0=20Double=EC=9D=84=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ddang/ddang/auction/application/dto/ReadAuctionDto.java | 2 +- .../auction/presentation/dto/response/SellerResponse.java | 2 +- .../authentication/application/AuthenticationService.java | 2 +- .../ddang/chat/application/dto/ReadUserInChatRoomDto.java | 2 +- .../ddang/ddang/report/application/dto/ReadReporterDto.java | 2 +- .../ddang/report/application/dto/ReadUserInReportDto.java | 2 +- .../com/ddang/ddang/user/application/dto/ReadUserDto.java | 2 +- .../ddang/src/main/java/com/ddang/ddang/user/domain/User.java | 4 ++-- .../ddang/ddang/user/presentation/dto/ReadUserResponse.java | 2 +- .../user/presentation/dto/response/ReadUserResponse.java | 2 +- .../ddang/user/presentation/dto/response/SellerResponse.java | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/application/dto/ReadAuctionDto.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/application/dto/ReadAuctionDto.java index d6ca7fd44..2925b2de6 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/application/dto/ReadAuctionDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/auction/application/dto/ReadAuctionDto.java @@ -27,7 +27,7 @@ public record ReadAuctionDto( Long sellerId, Long sellerProfileId, String sellerName, - double sellerReliability, + Double sellerReliability, boolean isSellerDeleted, AuctionStatus auctionStatus ) { diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/SellerResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/SellerResponse.java index 3483aab60..24e85ddeb 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/SellerResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/SellerResponse.java @@ -8,7 +8,7 @@ public record SellerResponse( Long id, String image, String nickname, - double reliability + Double reliability ) { public static SellerResponse from(final ReadAuctionDto auctionDto) { diff --git a/backend/ddang/src/main/java/com/ddang/ddang/authentication/application/AuthenticationService.java b/backend/ddang/src/main/java/com/ddang/ddang/authentication/application/AuthenticationService.java index 6380f877a..7705c65e2 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/authentication/application/AuthenticationService.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/authentication/application/AuthenticationService.java @@ -67,7 +67,7 @@ private User findOrPersistUser(final Oauth2Type oauth2Type, final UserInformatio final User user = User.builder() .name(oauth2Type.calculateNickname(calculateRandomNumber())) .profileImage(findDefaultProfileImage()) - .reliability(0.0d) + .reliability(null) .oauthId(userInformationDto.findUserId()) .build(); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/chat/application/dto/ReadUserInChatRoomDto.java b/backend/ddang/src/main/java/com/ddang/ddang/chat/application/dto/ReadUserInChatRoomDto.java index be7bbffc9..7155299d4 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/chat/application/dto/ReadUserInChatRoomDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/chat/application/dto/ReadUserInChatRoomDto.java @@ -3,7 +3,7 @@ import com.ddang.ddang.image.application.util.ImageIdProcessor; import com.ddang.ddang.user.domain.User; -public record ReadUserInChatRoomDto(Long id, String name, Long profileImageId, double reliability, boolean isDeleted) { +public record ReadUserInChatRoomDto(Long id, String name, Long profileImageId, Double reliability, boolean isDeleted) { public static ReadUserInChatRoomDto from(final User user) { return new ReadUserInChatRoomDto( diff --git a/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadReporterDto.java b/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadReporterDto.java index eecb87cab..c996197c0 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadReporterDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadReporterDto.java @@ -3,7 +3,7 @@ import com.ddang.ddang.image.application.util.ImageIdProcessor; import com.ddang.ddang.user.domain.User; -public record ReadReporterDto(Long id, String name, Long profileImageId, double reliability, boolean isDeleted) { +public record ReadReporterDto(Long id, String name, Long profileImageId, Double reliability, boolean isDeleted) { public static ReadReporterDto from(final User reporter) { return new ReadReporterDto( diff --git a/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadUserInReportDto.java b/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadUserInReportDto.java index 324e62ea8..0e63c1130 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadUserInReportDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadUserInReportDto.java @@ -7,7 +7,7 @@ public record ReadUserInReportDto( Long id, String name, Long profileImageId, - double reliability, + Double reliability, String oauthId, boolean isSellerDeleted ) { diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/application/dto/ReadUserDto.java b/backend/ddang/src/main/java/com/ddang/ddang/user/application/dto/ReadUserDto.java index b82952650..0ee30ce16 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/application/dto/ReadUserDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/application/dto/ReadUserDto.java @@ -7,7 +7,7 @@ public record ReadUserDto( Long id, String name, Long profileImageId, - double reliability, + Double reliability, String oauthId, boolean isDeleted ) { diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/domain/User.java b/backend/ddang/src/main/java/com/ddang/ddang/user/domain/User.java index b6cede7d3..74d2ce667 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/domain/User.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/domain/User.java @@ -42,7 +42,7 @@ public class User extends BaseTimeEntity { @JoinColumn(name = "profile_image_id", foreignKey = @ForeignKey(name = "fk_user_profile_image"), nullable = false) private ProfileImage profileImage; - private double reliability; + private Double reliability; private String oauthId; @@ -53,7 +53,7 @@ public class User extends BaseTimeEntity { private User( final String name, final ProfileImage profileImage, - final double reliability, + final Double reliability, final String oauthId ) { this.name = name; diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/ReadUserResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/ReadUserResponse.java index f8b2099b6..5e08b8b48 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/ReadUserResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/ReadUserResponse.java @@ -5,7 +5,7 @@ import com.ddang.ddang.user.application.dto.ReadUserDto; import com.ddang.ddang.user.presentation.util.NameProcessor; -public record ReadUserResponse(String name, String profileImage, double reliability) { +public record ReadUserResponse(String name, String profileImage, Double reliability) { public static ReadUserResponse from(final ReadUserDto readUserDto) { final String name = NameProcessor.process(readUserDto.isDeleted(), readUserDto.name()); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadUserResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadUserResponse.java index 67b127f06..6774f46f9 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadUserResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadUserResponse.java @@ -5,7 +5,7 @@ import com.ddang.ddang.user.application.dto.ReadUserDto; import com.ddang.ddang.user.presentation.util.NameProcessor; -public record ReadUserResponse(String name, String profileImage, double reliability) { +public record ReadUserResponse(String name, String profileImage, Double reliability) { public static ReadUserResponse from(final ReadUserDto readUserDto) { return new ReadUserResponse( diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/SellerResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/SellerResponse.java index 4f15aba33..f6da26e8f 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/SellerResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/SellerResponse.java @@ -4,6 +4,6 @@ public record SellerResponse( Long id, String image, String nickname, - double reliability + Double reliability ) { } From 88de52f16e4d2417f7a110432c5ae1ffee55f3fd Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 5 Oct 2023 02:21:03 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=ED=8C=90=EB=A7=A4=EC=9E=90=20?= =?UTF-8?q?=EC=8B=A0=EB=A2=B0=EB=8F=84=EA=B0=80=20null=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EC=A7=80=EC=A0=95=ED=95=9C=20=EA=B2=BD?= =?UTF-8?q?=EB=A7=A4=20=EC=95=84=EC=9D=B4=EB=94=94=EC=97=90=20=ED=95=B4?= =?UTF-8?q?=EB=8B=B9=ED=95=98=EB=8A=94=20=EA=B2=BD=EB=A7=A4=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=8B=9C=20=EC=A0=95=EC=83=81=EC=A0=81=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=8F=99=EC=9E=91=ED=95=98=EB=8A=94=EC=A7=80?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/AuctionServiceTest.java | 24 ++++++++--- .../fixture/AuctionServiceFixture.java | 43 +++++++++++++------ 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/application/AuctionServiceTest.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/AuctionServiceTest.java index 5184d113f..a95c7148b 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/application/AuctionServiceTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/AuctionServiceTest.java @@ -1,11 +1,5 @@ package com.ddang.ddang.auction.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatCode; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; - import com.ddang.ddang.auction.application.dto.CreateInfoAuctionDto; import com.ddang.ddang.auction.application.dto.ReadAuctionDto; import com.ddang.ddang.auction.application.dto.ReadAuctionsDto; @@ -18,7 +12,6 @@ import com.ddang.ddang.image.domain.StoreImageProcessor; import com.ddang.ddang.region.application.exception.RegionNotFoundException; import com.ddang.ddang.user.application.exception.UserNotFoundException; -import java.util.List; import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; @@ -29,6 +22,14 @@ import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Order; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; + @IsolateDatabase @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) @SuppressWarnings("NonAsciiCharacters") @@ -195,6 +196,15 @@ class AuctionServiceTest extends AuctionServiceFixture { .hasMessage("지정한 아이디에 대한 경매를 찾을 수 없습니다."); } + @Test + void 지정한_아이디에_해당하는_경매의_판매자_신뢰도가_null이라면_서비스에서_반환하는_dto에서_판매자_신뢰도를_나타내는_부분도_null이다() { + // when + final ReadAuctionDto actual = auctionService.readByAuctionId(신뢰도가_null인_판매자의_경매.getId()); + + // then + assertThat(actual.sellerReliability()).isNull(); + } + @Test void 첫번째_페이지의_경매_목록을_조회한다() { // when diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/application/fixture/AuctionServiceFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/fixture/AuctionServiceFixture.java index 8bbf48dc8..b29f571d6 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/application/fixture/AuctionServiceFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/fixture/AuctionServiceFixture.java @@ -1,8 +1,9 @@ package com.ddang.ddang.auction.application.fixture; -import com.ddang.ddang.auction.application.AuctionService; import com.ddang.ddang.auction.application.dto.CreateAuctionDto; import com.ddang.ddang.auction.domain.Auction; +import com.ddang.ddang.auction.domain.BidUnit; +import com.ddang.ddang.auction.domain.Price; import com.ddang.ddang.auction.infrastructure.persistence.JpaAuctionRepository; import com.ddang.ddang.bid.domain.Bid; import com.ddang.ddang.bid.domain.BidPrice; @@ -11,25 +12,24 @@ import com.ddang.ddang.category.infrastructure.persistence.JpaCategoryRepository; import com.ddang.ddang.chat.domain.ChatRoom; import com.ddang.ddang.chat.infrastructure.persistence.JpaChatRoomRepository; +import com.ddang.ddang.image.domain.AuctionImage; import com.ddang.ddang.image.domain.ProfileImage; import com.ddang.ddang.image.domain.dto.StoreImageDto; import com.ddang.ddang.region.domain.Region; import com.ddang.ddang.region.infrastructure.persistence.JpaRegionRepository; import com.ddang.ddang.user.domain.User; import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository; -import java.time.LocalDateTime; -import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.mock.web.MockMultipartFile; +import java.time.LocalDateTime; +import java.util.List; + @SuppressWarnings("NonAsciiCharacters") public class AuctionServiceFixture { - @Autowired - private AuctionService auctionService; - @Autowired private JpaAuctionRepository auctionRepository; @@ -58,11 +58,17 @@ public class AuctionServiceFixture { .oauthId("12345") .build(); protected User 구매자 = User.builder() - .name("구매자") - .profileImage(new ProfileImage("upload.png", "store.png")) - .reliability(4.7d) - .oauthId("54321") - .build(); + .name("구매자") + .profileImage(new ProfileImage("upload.png", "store.png")) + .reliability(4.7d) + .oauthId("54321") + .build(); + protected User 신뢰도가_null인_판매자 = User.builder() + .name("신뢰도가 null인 판매자") + .profileImage(new ProfileImage("upload.png", "store.png")) + .reliability(null) + .oauthId("99999") + .build(); private MockMultipartFile 경매_이미지_파일 = new MockMultipartFile( "image.png", @@ -90,6 +96,7 @@ public class AuctionServiceFixture { protected Auction 종료되는_날이_3일_뒤인_경매; protected Auction 입찰이_존재하는_경매; protected Auction 종료된_경매; + protected Auction 신뢰도가_null인_판매자의_경매; protected BidPrice 채팅방이_있는_경매_입찰_가격 = new BidPrice(10_000); protected Bid 채팅방이_있는_경매_입찰; protected Bid 입찰이_존재하는_경매_입찰; @@ -109,7 +116,7 @@ void setUp() { categoryRepository.save(가구_카테고리); - userRepository.saveAll(List.of(판매자, 구매자)); + userRepository.saveAll(List.of(판매자, 구매자, 신뢰도가_null인_판매자)); 유효한_경매_생성_dto = new CreateAuctionDto( "제목", @@ -224,7 +231,17 @@ void setUp() { 채팅방이_있는_경매.updateLastBid(채팅방이_있는_경매_입찰); 입찰이_존재하는_경매.updateLastBid(입찰이_존재하는_경매_입찰); - auctionRepository.saveAll(List.of(채팅방이_있는_경매, 종료되는_날이_3일_뒤인_경매, 입찰이_존재하는_경매, 종료된_경매)); + 신뢰도가_null인_판매자의_경매 = Auction.builder() + .title("신뢰도가 null인 판매자의 경매") + .description("신뢰도가 null인 판매자의 경매") + .subCategory(가구_서브_의자_카테고리) + .seller(신뢰도가_null인_판매자) + .bidUnit(new BidUnit(1_000)) + .startPrice(new Price(10_000)) + .closingTime(LocalDateTime.now().plusDays(3L)) + .build(); + 신뢰도가_null인_판매자의_경매.addAuctionImages(List.of(new AuctionImage("auction.png", "auction.png"))); + auctionRepository.saveAll(List.of(채팅방이_있는_경매, 종료되는_날이_3일_뒤인_경매, 입찰이_존재하는_경매, 종료된_경매, 신뢰도가_null인_판매자의_경매)); final ChatRoom 채팅방 = new ChatRoom(채팅방이_있는_경매, 구매자); From df6b52b378f007cc8cdee81ce970c5b3e155dc7f Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 5 Oct 2023 02:22:28 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0=EC=9D=98=20`@EqualsAndHashCode`=20?= =?UTF-8?q?=EC=98=B5=EC=85=98=EC=97=90=20`callSuper=20=3D=20false`=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ddang/src/main/java/com/ddang/ddang/user/domain/User.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/domain/User.java b/backend/ddang/src/main/java/com/ddang/ddang/user/domain/User.java index 74d2ce667..763cd9a88 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/domain/User.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/domain/User.java @@ -23,7 +23,7 @@ @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter -@EqualsAndHashCode(of = "id") +@EqualsAndHashCode(of = "id", callSuper = false) @ToString(of = {"id", "name", "reliability", "oauthId", "deleted"}) @Table(name = "users") public class User extends BaseTimeEntity { From 47620bd801bf72674ad7aef4b9a24065d036e4be Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 5 Oct 2023 02:24:35 +0900 Subject: [PATCH 4/6] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20dto=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/presentation/dto/ReadUserResponse.java | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/ReadUserResponse.java diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/ReadUserResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/ReadUserResponse.java deleted file mode 100644 index 5e08b8b48..000000000 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/ReadUserResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ddang.ddang.user.presentation.dto; - -import com.ddang.ddang.image.presentation.util.ImageRelativeUrl; -import com.ddang.ddang.image.presentation.util.ImageUrlCalculator; -import com.ddang.ddang.user.application.dto.ReadUserDto; -import com.ddang.ddang.user.presentation.util.NameProcessor; - -public record ReadUserResponse(String name, String profileImage, Double reliability) { - - public static ReadUserResponse from(final ReadUserDto readUserDto) { - final String name = NameProcessor.process(readUserDto.isDeleted(), readUserDto.name()); - final String profileImageUrl = ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, readUserDto.profileImageId()); - - return new ReadUserResponse(name, profileImageUrl, readUserDto.reliability()); - } -} From 1f66ba20c8742813a4c3db1a245810e5782ff97a Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 5 Oct 2023 03:33:12 +0900 Subject: [PATCH 5/6] =?UTF-8?q?test:=20=EC=8B=A4=ED=8C=A8=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auction/application/fixture/AuctionServiceFixture.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/application/fixture/AuctionServiceFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/fixture/AuctionServiceFixture.java index b29f571d6..26f1bdc57 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/application/fixture/AuctionServiceFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/fixture/AuctionServiceFixture.java @@ -241,7 +241,7 @@ void setUp() { .closingTime(LocalDateTime.now().plusDays(3L)) .build(); 신뢰도가_null인_판매자의_경매.addAuctionImages(List.of(new AuctionImage("auction.png", "auction.png"))); - auctionRepository.saveAll(List.of(채팅방이_있는_경매, 종료되는_날이_3일_뒤인_경매, 입찰이_존재하는_경매, 종료된_경매, 신뢰도가_null인_판매자의_경매)); + auctionRepository.saveAll(List.of(신뢰도가_null인_판매자의_경매, 채팅방이_있는_경매, 종료되는_날이_3일_뒤인_경매, 입찰이_존재하는_경매, 종료된_경매)); final ChatRoom 채팅방 = new ChatRoom(채팅방이_있는_경매, 구매자); From 8a846198c3c73cc2d7575ff347961695a88753a9 Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 5 Oct 2023 14:36:09 +0900 Subject: [PATCH 6/6] =?UTF-8?q?test:=20dto=EC=99=80=20=EA=B4=80=EB=A0=A8?= =?UTF-8?q?=EB=90=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EB=A5=BC=20dto=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=ED=81=B4=EB=9E=98=EC=8A=A4?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/AuctionServiceTest.java | 9 --- .../application/dto/ReadAuctionDtoTest.java | 26 ++++++++ .../dto/fixture/ReadAuctionDtoFixture.java | 64 +++++++++++++++++++ .../fixture/AuctionServiceFixture.java | 25 +------- 4 files changed, 92 insertions(+), 32 deletions(-) create mode 100644 backend/ddang/src/test/java/com/ddang/ddang/auction/application/dto/ReadAuctionDtoTest.java create mode 100644 backend/ddang/src/test/java/com/ddang/ddang/auction/application/dto/fixture/ReadAuctionDtoFixture.java diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/application/AuctionServiceTest.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/AuctionServiceTest.java index a95c7148b..cb6477efb 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/application/AuctionServiceTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/AuctionServiceTest.java @@ -196,15 +196,6 @@ class AuctionServiceTest extends AuctionServiceFixture { .hasMessage("지정한 아이디에 대한 경매를 찾을 수 없습니다."); } - @Test - void 지정한_아이디에_해당하는_경매의_판매자_신뢰도가_null이라면_서비스에서_반환하는_dto에서_판매자_신뢰도를_나타내는_부분도_null이다() { - // when - final ReadAuctionDto actual = auctionService.readByAuctionId(신뢰도가_null인_판매자의_경매.getId()); - - // then - assertThat(actual.sellerReliability()).isNull(); - } - @Test void 첫번째_페이지의_경매_목록을_조회한다() { // when diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/application/dto/ReadAuctionDtoTest.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/dto/ReadAuctionDtoTest.java new file mode 100644 index 000000000..a1d058ef3 --- /dev/null +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/dto/ReadAuctionDtoTest.java @@ -0,0 +1,26 @@ +package com.ddang.ddang.auction.application.dto; + +import com.ddang.ddang.auction.application.dto.fixture.ReadAuctionDtoFixture; +import com.ddang.ddang.configuration.IsolateDatabase; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; + +import java.time.LocalDateTime; + +import static org.assertj.core.api.Assertions.assertThat; + +@IsolateDatabase +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +@SuppressWarnings("NonAsciiCharacters") +class ReadAuctionDtoTest extends ReadAuctionDtoFixture { + + @Test + void 지정한_아이디에_해당하는_경매의_판매자_신뢰도가_null이라면_서비스에서_반환하는_dto에서_판매자_신뢰도를_나타내는_부분도_null이다() { + // when + final ReadAuctionDto actual = ReadAuctionDto.of(신뢰도가_null인_판매자의_경매, LocalDateTime.now()); + + // then + assertThat(actual.sellerReliability()).isNull(); + } +} diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/application/dto/fixture/ReadAuctionDtoFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/dto/fixture/ReadAuctionDtoFixture.java new file mode 100644 index 000000000..baeb519fc --- /dev/null +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/dto/fixture/ReadAuctionDtoFixture.java @@ -0,0 +1,64 @@ +package com.ddang.ddang.auction.application.dto.fixture; + +import com.ddang.ddang.auction.domain.Auction; +import com.ddang.ddang.auction.domain.BidUnit; +import com.ddang.ddang.auction.domain.Price; +import com.ddang.ddang.auction.infrastructure.persistence.JpaAuctionRepository; +import com.ddang.ddang.category.domain.Category; +import com.ddang.ddang.category.infrastructure.persistence.JpaCategoryRepository; +import com.ddang.ddang.image.domain.AuctionImage; +import com.ddang.ddang.image.domain.ProfileImage; +import com.ddang.ddang.region.infrastructure.persistence.JpaRegionRepository; +import com.ddang.ddang.user.domain.User; +import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository; +import org.junit.jupiter.api.BeforeEach; +import org.springframework.beans.factory.annotation.Autowired; + +import java.time.LocalDateTime; +import java.util.List; + +@SuppressWarnings("NonAsciiCharacters") +public class ReadAuctionDtoFixture { + + @Autowired + private JpaAuctionRepository auctionRepository; + + @Autowired + private JpaRegionRepository regionRepository; + + @Autowired + private JpaCategoryRepository categoryRepository; + + @Autowired + private JpaUserRepository userRepository; + + private Category 가구_카테고리 = new Category("가구"); + private Category 가구_서브_의자_카테고리 = new Category("의자"); + protected User 신뢰도가_null인_판매자 = User.builder() + .name("신뢰도가 null인 판매자") + .profileImage(new ProfileImage("upload.png", "store.png")) + .reliability(null) + .oauthId("99999") + .build(); + protected Auction 신뢰도가_null인_판매자의_경매; + + @BeforeEach + void setUp() { + userRepository.save(신뢰도가_null인_판매자); + + 가구_카테고리.addSubCategory(가구_서브_의자_카테고리); + categoryRepository.save(가구_카테고리); + + 신뢰도가_null인_판매자의_경매 = Auction.builder() + .title("신뢰도가 null인 판매자의 경매") + .description("신뢰도가 null인 판매자의 경매") + .subCategory(가구_서브_의자_카테고리) + .seller(신뢰도가_null인_판매자) + .bidUnit(new BidUnit(1_000)) + .startPrice(new Price(10_000)) + .closingTime(LocalDateTime.now().plusDays(3L)) + .build(); + 신뢰도가_null인_판매자의_경매.addAuctionImages(List.of(new AuctionImage("auction.png", "auction.png"))); + auctionRepository.save(신뢰도가_null인_판매자의_경매); + } +} diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/application/fixture/AuctionServiceFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/fixture/AuctionServiceFixture.java index 26f1bdc57..22a9620ee 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/application/fixture/AuctionServiceFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/application/fixture/AuctionServiceFixture.java @@ -2,8 +2,6 @@ import com.ddang.ddang.auction.application.dto.CreateAuctionDto; import com.ddang.ddang.auction.domain.Auction; -import com.ddang.ddang.auction.domain.BidUnit; -import com.ddang.ddang.auction.domain.Price; import com.ddang.ddang.auction.infrastructure.persistence.JpaAuctionRepository; import com.ddang.ddang.bid.domain.Bid; import com.ddang.ddang.bid.domain.BidPrice; @@ -12,7 +10,6 @@ import com.ddang.ddang.category.infrastructure.persistence.JpaCategoryRepository; import com.ddang.ddang.chat.domain.ChatRoom; import com.ddang.ddang.chat.infrastructure.persistence.JpaChatRoomRepository; -import com.ddang.ddang.image.domain.AuctionImage; import com.ddang.ddang.image.domain.ProfileImage; import com.ddang.ddang.image.domain.dto.StoreImageDto; import com.ddang.ddang.region.domain.Region; @@ -63,12 +60,6 @@ public class AuctionServiceFixture { .reliability(4.7d) .oauthId("54321") .build(); - protected User 신뢰도가_null인_판매자 = User.builder() - .name("신뢰도가 null인 판매자") - .profileImage(new ProfileImage("upload.png", "store.png")) - .reliability(null) - .oauthId("99999") - .build(); private MockMultipartFile 경매_이미지_파일 = new MockMultipartFile( "image.png", @@ -96,7 +87,6 @@ public class AuctionServiceFixture { protected Auction 종료되는_날이_3일_뒤인_경매; protected Auction 입찰이_존재하는_경매; protected Auction 종료된_경매; - protected Auction 신뢰도가_null인_판매자의_경매; protected BidPrice 채팅방이_있는_경매_입찰_가격 = new BidPrice(10_000); protected Bid 채팅방이_있는_경매_입찰; protected Bid 입찰이_존재하는_경매_입찰; @@ -116,7 +106,7 @@ void setUp() { categoryRepository.save(가구_카테고리); - userRepository.saveAll(List.of(판매자, 구매자, 신뢰도가_null인_판매자)); + userRepository.saveAll(List.of(판매자, 구매자)); 유효한_경매_생성_dto = new CreateAuctionDto( "제목", @@ -230,18 +220,7 @@ void setUp() { 채팅방이_있는_경매.updateLastBid(채팅방이_있는_경매_입찰); 입찰이_존재하는_경매.updateLastBid(입찰이_존재하는_경매_입찰); - - 신뢰도가_null인_판매자의_경매 = Auction.builder() - .title("신뢰도가 null인 판매자의 경매") - .description("신뢰도가 null인 판매자의 경매") - .subCategory(가구_서브_의자_카테고리) - .seller(신뢰도가_null인_판매자) - .bidUnit(new BidUnit(1_000)) - .startPrice(new Price(10_000)) - .closingTime(LocalDateTime.now().plusDays(3L)) - .build(); - 신뢰도가_null인_판매자의_경매.addAuctionImages(List.of(new AuctionImage("auction.png", "auction.png"))); - auctionRepository.saveAll(List.of(신뢰도가_null인_판매자의_경매, 채팅방이_있는_경매, 종료되는_날이_3일_뒤인_경매, 입찰이_존재하는_경매, 종료된_경매)); + auctionRepository.saveAll(List.of(채팅방이_있는_경매, 종료되는_날이_3일_뒤인_경매, 입찰이_존재하는_경매, 종료된_경매)); final ChatRoom 채팅방 = new ChatRoom(채팅방이_있는_경매, 구매자);