2v0-7222 Exam QuestionsBrowse all questions from this exam

2v0-7222 Exam - Question 42


Which two statements are true regarding @DataJpaTest? (Choose two.)

Show Answer
Correct Answer: BD

TestEntityManager provides a subset of functionality focused on testing, not all methods of EntityManager, so A is incorrect. @DataJpaTest is specifically designed for JPA components and not NoSQL, making C incorrect. It also cannot be used for JdbcTemplate testing, making E incorrect. If an embedded database is on the classpath, it is used to configure a DataSource by default, and @DataJpaTest auto-configures a TestEntityManager bean, making B and D the correct choices.

Discussion

3 comments
Sign in to comment
Tolo01Options: BD
Jul 31, 2023

A is incorrect because TestEntityManager does not provide all methods that are provided by EntityManager. It only provides a subset of the methods that are relevant for testing. C is incorrect because @DataJpaTest is specifically designed for testing JPA components. It cannot be used for testing NoSQL components. E is incorrect because @DataJpaTest cannot be used for testing JdbcTemplate. JdbcTemplate is a different type of data access abstraction that is not related to JPA.

rhuancaOptions: AD
Mar 26, 2023

why not A instead of B , because @DataJpaTest does not configure any DataSource by default. A and D

2211094Options: AD
Jun 15, 2024

A is correct as well as D, why A? here is the reason, TestEntityManager extends EntityManager which means it inherits all methods of EntityManager and adds more specialized methods specifically for testing purposes.