Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] 이벤트 유저를 다양한 조건으로 검색할 수 있게 개선(#135) #139

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles;
import org.testcontainers.junit.jupiter.Testcontainers;

Expand All @@ -16,5 +17,6 @@
@Testcontainers
@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@Import(TestConfig.class)
public @interface TCDataJpaTest {
}
18 changes: 18 additions & 0 deletions src/test/java/hyundai/softeer/orange/support/TestConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package hyundai.softeer.orange.support;

import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;

@TestConfiguration
public class TestConfig {
@PersistenceContext
private EntityManager entityManager;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QueryDSL의 경우 JPA persistence layer에 속해있지 않아 DataJPATest을 이용할 때 자동으로 bean으로 등록되지 않는다고 합니다. 이로 인해 DataJPATest에서 필요로 하는 QueryDSL 관련 Bean이 없는 상태가 되어 NoSuchBeanDefinitionException이 발생한다고 하네요. 이를 방지하기 위해 test configuration으로 설정을 만들어줬습니다.

참고 경로입니다.

https://velog.io/@gloz0315/QueryDSL-Test-%EC%BD%94%EB%93%9C-%EB%AC%B8%EC%A0%9C-%EB%B0%8F-%ED%95%B4%EA%B2%B0


@Bean
public JPAQueryFactory jpaQueryFactory() {
return new JPAQueryFactory(entityManager);
}
}
Loading