Skip to content

Commit

Permalink
test: jpa 저장 테스트 시 불필요한 엔티티 매니저 호출 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonyj1022 committed Oct 14, 2023
1 parent eca3793 commit 0b43d52
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.ddang.ddang.configuration.JpaConfiguration;
import com.ddang.ddang.configuration.QuerydslConfiguration;
import com.ddang.ddang.user.domain.ReliabilityUpdateHistory;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.Test;
Expand All @@ -23,9 +21,6 @@
@SuppressWarnings("NonAsciiCharacters")
class JpaReliabilityUpdateHistoryRepositoryTest {

@PersistenceContext
EntityManager em;

@Autowired
JpaReliabilityUpdateHistoryRepository reliabilityUpdateHistoryRepository;

Expand All @@ -37,9 +32,6 @@ class JpaReliabilityUpdateHistoryRepositoryTest {
// when
final ReliabilityUpdateHistory actual = reliabilityUpdateHistoryRepository.save(reliabilityUpdateHistory);

em.flush();
em.clear();

// then
assertThat(actual.getId()).isPositive();
}
Expand All @@ -62,9 +54,6 @@ class JpaReliabilityUpdateHistoryRepositoryTest {

reliabilityUpdateHistoryRepository.saveAll(List.of(history1, history2, history3));

em.flush();
em.clear();

// when
final Optional<ReliabilityUpdateHistory> actual = reliabilityUpdateHistoryRepository.findFirstByOrderByIdDesc();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.ddang.ddang.configuration.QuerydslConfiguration;
import com.ddang.ddang.user.domain.UserReliability;
import com.ddang.ddang.user.infrastructure.persistence.fixture.JpaUserReliabilityRepositoryFixture;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.Test;
Expand All @@ -23,9 +21,6 @@
@SuppressWarnings("NonAsciiCharacters")
class JpaUserReliabilityRepositoryTest extends JpaUserReliabilityRepositoryFixture {

@PersistenceContext
EntityManager em;

@Autowired
JpaUserReliabilityRepository userReliabilityRepository;

Expand All @@ -34,9 +29,6 @@ class JpaUserReliabilityRepositoryTest extends JpaUserReliabilityRepositoryFixtu
// when
UserReliability actual = userReliabilityRepository.save(저장하기_전_사용자_신뢰도_엔티티);

em.flush();
em.clear();

// then
assertThat(actual.getId()).isPositive();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import com.ddang.ddang.user.domain.Reliability;
import com.ddang.ddang.user.domain.User;
import com.ddang.ddang.user.infrastructure.persistence.fixture.JpaUserRepositoryFixture;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.Test;
Expand All @@ -24,9 +22,6 @@
@SuppressWarnings("NonAsciiCharacters")
class JpaUserRepositoryTest extends JpaUserRepositoryFixture {

@PersistenceContext
EntityManager em;

@Autowired
JpaUserRepository userRepository;

Expand All @@ -44,9 +39,6 @@ class JpaUserRepositoryTest extends JpaUserRepositoryFixture {
final User actual = userRepository.save(user);

// then
em.flush();
em.clear();

assertThat(actual.getId()).isPositive();
}

Expand Down

0 comments on commit 0b43d52

Please sign in to comment.