VMware vRealize Automation 8.x (2022) — Question 28
Which two statements are true regarding @DataJpaTest? (Choose two.)
Answer options
- A. TestEntityManager provides all methods that are provided by EntityManager and more.
- B. If an embedded database is on the classpath, it will be used to configure a DataSource by default.
- C. It can be used for testing both JPA components and NoSQL components.
- D. It auto-configures a TestEntityManager bean.
- E. It can be used for testing JdbcTemplate.
Correct answer: B, D
Explanation
The correct answers are B and D because @DataJpaTest automatically configures a DataSource if an embedded database is present, and it also auto-configures a TestEntityManager bean for testing purposes. Options A and C are incorrect as TestEntityManager does not provide more methods than EntityManager, and @DataJpaTest is specifically designed for JPA components, not NoSQL. Option E is also incorrect as JdbcTemplate is not the focus of @DataJpaTest.