From 9f1d791e892b2a97d4700f88f55f23354ebfd3fa Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Sat, 14 Oct 2023 23:49:26 +0900 Subject: [PATCH] =?UTF-8?q?ci:=20=EB=B8=8C=EB=9E=9C=EC=B9=98=20=EC=B5=9C?= =?UTF-8?q?=EC=8B=A0=ED=99=94=20=EA=B3=BC=EC=A0=95=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=88=84=EB=9D=BD=EB=90=9C=20=EC=82=AC=ED=95=AD=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EC=B6=A9=EB=8F=8C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ChatRoomAndImageRepositoryImplFixture.java | 29 +++++++++--------- ...dMessageAndImageRepositoryImplFixture.java | 30 ++++++++++--------- .../ChatRoomRepositoryImplFixture.java | 10 +++++-- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/backend/ddang/src/test/java/com/ddang/ddang/chat/infrastructure/persistence/fixture/ChatRoomAndImageRepositoryImplFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/chat/infrastructure/persistence/fixture/ChatRoomAndImageRepositoryImplFixture.java index 8de2d6483..238f76175 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/chat/infrastructure/persistence/fixture/ChatRoomAndImageRepositoryImplFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/chat/infrastructure/persistence/fixture/ChatRoomAndImageRepositoryImplFixture.java @@ -20,7 +20,9 @@ import com.ddang.ddang.image.domain.ProfileImage; import com.ddang.ddang.user.domain.Reliability; import com.ddang.ddang.user.domain.User; +import com.ddang.ddang.user.domain.repository.UserRepository; import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository; +import com.ddang.ddang.user.infrastructure.persistence.UserRepositoryImpl; import com.querydsl.jpa.impl.JPAQueryFactory; import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; @@ -31,17 +33,12 @@ @SuppressWarnings("NonAsciiCharacters") public class ChatRoomAndImageRepositoryImplFixture { - @Autowired - private JPAQueryFactory queryFactory; - - @Autowired - private JpaAuctionRepository jpaAuctionRepository; + private AuctionRepository auctionRepository; @Autowired private JpaCategoryRepository categoryRepository; - @Autowired - private JpaUserRepository userRepository; + private UserRepository userRepository; @Autowired private JpaBidRepository bidRepository; @@ -52,7 +49,13 @@ public class ChatRoomAndImageRepositoryImplFixture { protected ChatRoom 채팅방; @BeforeEach - void fixtureSetUp(@Autowired final JpaChatRoomRepository jpaChatRoomRepository) { + void fixtureSetUp( + @Autowired final JPAQueryFactory jpaQueryFactory, + @Autowired final JpaAuctionRepository jpaAuctionRepository, + @Autowired final JpaUserRepository jpaUserRepository, + @Autowired final JpaChatRoomRepository jpaChatRoomRepository) { + auctionRepository = new AuctionRepositoryImpl(jpaAuctionRepository, new QuerydslAuctionRepository(jpaQueryFactory)); + userRepository = new UserRepositoryImpl(jpaUserRepository); chatRoomRepository = new ChatRoomRepositoryImpl(jpaChatRoomRepository); final Category 전자기기_카테고리 = new Category("전자기기"); @@ -85,16 +88,14 @@ void fixtureSetUp(@Autowired final JpaChatRoomRepository jpaChatRoomRepository) 경매_대표_이미지 = new AuctionImage("경매_대표_이미지.png", "경매_대표_이미지.png"); 채팅방 = new ChatRoom(경매, 구매자); - - final AuctionRepository auctionRepository = new AuctionRepositoryImpl( - jpaAuctionRepository, - new QuerydslAuctionRepository(queryFactory) - ); auctionRepository.save(경매); 전자기기_카테고리.addSubCategory(전자기기_서브_노트북_카테고리); categoryRepository.save(전자기기_카테고리); - userRepository.saveAll(List.of(판매자, 구매자)); + + userRepository.save(판매자); + userRepository.save(구매자); + 경매.addAuctionImages(List.of(경매_대표_이미지, 대표_이미지가_아닌_경매_이미지)); bidRepository.save(입찰); 경매.updateLastBid(입찰); diff --git a/backend/ddang/src/test/java/com/ddang/ddang/chat/infrastructure/persistence/fixture/ChatRoomAndMessageAndImageRepositoryImplFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/chat/infrastructure/persistence/fixture/ChatRoomAndMessageAndImageRepositoryImplFixture.java index 30b20b456..910a036b0 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/chat/infrastructure/persistence/fixture/ChatRoomAndMessageAndImageRepositoryImplFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/chat/infrastructure/persistence/fixture/ChatRoomAndMessageAndImageRepositoryImplFixture.java @@ -22,7 +22,9 @@ import com.ddang.ddang.image.domain.ProfileImage; import com.ddang.ddang.user.domain.Reliability; import com.ddang.ddang.user.domain.User; +import com.ddang.ddang.user.domain.repository.UserRepository; import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository; +import com.ddang.ddang.user.infrastructure.persistence.UserRepositoryImpl; import com.querydsl.jpa.impl.JPAQueryFactory; import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; @@ -33,17 +35,12 @@ @SuppressWarnings("NonAsciiCharacters") public class ChatRoomAndMessageAndImageRepositoryImplFixture { - @Autowired - private JPAQueryFactory queryFactory; - - @Autowired - private JpaAuctionRepository jpaAuctionRepository; + private AuctionRepository auctionRepository; @Autowired private JpaCategoryRepository categoryRepository; - @Autowired - private JpaUserRepository userRepository; + private UserRepository userRepository; @Autowired private JpaBidRepository bidRepository; @@ -65,7 +62,14 @@ public class ChatRoomAndMessageAndImageRepositoryImplFixture { protected Message 엔초가_지토에게_5시에_보낸_쪽지; @BeforeEach - void fixtureSetUp(@Autowired final JpaChatRoomRepository jpaChatRoomRepository) { + void fixtureSetUp( + @Autowired final JPAQueryFactory jpaQueryFactory, + @Autowired final JpaAuctionRepository jpaAuctionRepository, + @Autowired final JpaUserRepository jpaUserRepository, + @Autowired final JpaChatRoomRepository jpaChatRoomRepository + ) { + auctionRepository = new AuctionRepositoryImpl(jpaAuctionRepository, new QuerydslAuctionRepository(jpaQueryFactory)); + userRepository = new UserRepositoryImpl(jpaUserRepository); chatRoomRepository = new ChatRoomRepositoryImpl(jpaChatRoomRepository); final Category 전자기기_카테고리 = new Category("전자기기"); @@ -178,17 +182,15 @@ void fixtureSetUp(@Autowired final JpaChatRoomRepository jpaChatRoomRepository) 전자기기_카테고리.addSubCategory(전자기기_서브_노트북_카테고리); categoryRepository.save(전자기기_카테고리); - userRepository.saveAll(List.of(메리, 엔초, 제이미, 지토)); + userRepository.save(메리); + userRepository.save(엔초); + userRepository.save(제이미); + userRepository.save(지토); 메리의_경매.addAuctionImages(List.of(메리의_경매_대표_이미지, 메리의_대표_이미지가_아닌_경매_이미지)); 엔초의_경매.addAuctionImages(List.of(엔초의_경매_대표_이미지, 엔초의_대표_이미지가_아닌_경매_이미지)); 제이미의_경매.addAuctionImages(List.of(제이미의_경매_대표_이미지, 제이미의_대표_이미지가_아닌_경매_이미지)); - final AuctionRepository auctionRepository = new AuctionRepositoryImpl( - jpaAuctionRepository, - new QuerydslAuctionRepository(queryFactory) - ); - auctionRepository.save(메리의_경매); auctionRepository.save(엔초의_경매); auctionRepository.save(제이미의_경매); diff --git a/backend/ddang/src/test/java/com/ddang/ddang/chat/infrastructure/persistence/fixture/ChatRoomRepositoryImplFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/chat/infrastructure/persistence/fixture/ChatRoomRepositoryImplFixture.java index aad3b0897..54d23f007 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/chat/infrastructure/persistence/fixture/ChatRoomRepositoryImplFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/chat/infrastructure/persistence/fixture/ChatRoomRepositoryImplFixture.java @@ -20,7 +20,9 @@ import com.ddang.ddang.image.domain.ProfileImage; import com.ddang.ddang.user.domain.Reliability; import com.ddang.ddang.user.domain.User; +import com.ddang.ddang.user.domain.repository.UserRepository; import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository; +import com.ddang.ddang.user.infrastructure.persistence.UserRepositoryImpl; import com.querydsl.jpa.impl.JPAQueryFactory; import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; @@ -34,8 +36,7 @@ public class ChatRoomRepositoryImplFixture { @Autowired private JpaCategoryRepository categoryRepository; - @Autowired - private JpaUserRepository userRepository; + private UserRepository userRepository; private AuctionRepository auctionRepository; @@ -55,9 +56,11 @@ public class ChatRoomRepositoryImplFixture { void fixtureSetUp( @Autowired final JPAQueryFactory queryFactory, @Autowired final JpaAuctionRepository jpaAuctionRepository, + @Autowired final JpaUserRepository jpaUserRepository, @Autowired final JpaChatRoomRepository jpaChatRoomRepository ) { auctionRepository = new AuctionRepositoryImpl(jpaAuctionRepository, new QuerydslAuctionRepository(queryFactory)); + userRepository = new UserRepositoryImpl(jpaUserRepository); chatRoomRepository = new ChatRoomRepositoryImpl(jpaChatRoomRepository); final Category 전자기기_카테고리 = new Category("전자기기"); @@ -95,7 +98,8 @@ void fixtureSetUp( 전자기기_카테고리.addSubCategory(전자기기_서브_노트북_카테고리); categoryRepository.save(전자기기_카테고리); - userRepository.saveAll(List.of(판매자, 구매자)); + userRepository.save(판매자); + userRepository.save(구매자); 경매.addAuctionImages(List.of(경매이미지1, 경매이미지2)); auctionRepository.save(경매);