Skip to content

Commit

Permalink
refactor: 테스트에서 도메인 레포지토리 사용하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
swonny committed Oct 15, 2023
1 parent a46452d commit 98abe21
Showing 1 changed file with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,47 @@
import com.ddang.ddang.image.infrastructure.persistence.JpaAuctionImageRepository;
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 jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.time.LocalDateTime;
import java.util.List;
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 QuerydslAuctionAndImageRepositoryFixture {

@PersistenceContext
private EntityManager em;

@Autowired
private JPAQueryFactory jpaQueryFactory;

@Autowired
private JpaAuctionRepository jpaAuctionRepository;

@Autowired
private JpaAuctionImageRepository auctionImageRepository;

private UserRepository userRepository;

@Autowired
private JpaUserRepository userRepository;
private AuctionRepository auctionRepository;

private User 사용자;
protected Auction 경매;
protected AuctionImage 경매_이미지;

@BeforeEach
void setUp() {
void fixtureSetUp(
@Autowired JPAQueryFactory jpaQueryFactory,
@Autowired JpaAuctionRepository jpaAuctionRepository,
@Autowired JpaUserRepository jpaUserRepository
) {
auctionRepository = new AuctionRepositoryImpl(
jpaAuctionRepository,
new QuerydslAuctionRepository(jpaQueryFactory)
);
userRepository = new UserRepositoryImpl(jpaUserRepository);

경매 = Auction.builder()
.title("경매 상품 1")
.description("이것은 경매 상품 1 입니다.")
Expand All @@ -63,10 +71,6 @@ void setUp() {
.oauthId("12345")
.build();

final AuctionRepository auctionRepository = new AuctionRepositoryImpl(
jpaAuctionRepository,
new QuerydslAuctionRepository(jpaQueryFactory)
);
auctionRepository.save(경매);
userRepository.save(사용자);

Expand Down

0 comments on commit 98abe21

Please sign in to comment.