Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Repository
- @Transactional(readOnly = true)
- public class BookRepositoryJpa implements BookRepository {
- @PersistenceContext
- private EntityManager em;
- @Transactional // тест проходит, даже если я забуду @Transactional - как это проверить?
- public void delete(Book book) {
- em.remove(book);
- }
- }
- @DataJpaTest
- @ComponentScan("my.package.jpa")
- class BookRepositoryJpaTest {
- @Autowired
- BookDao bookDao;
- @Autowired
- TestEntityManager tem;
- @Test
- void testDelete() {
- Book bookToDelete = tem.find(Book.class, BOOK2.getBookId());
- bookDao.delete(bookToDelete);
- assertThat(bookDao.findAll()).containsExactly(BOOK5, BOOK4, BOOK3, BOOK1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement