EntityManager entityManager = entityManagerFactory.createEntityManager();
Reader reader = entityManager.find(Reader.class, 1l);
entityManager.close();
em.getTransaction().begin();
borrowDAO.createBorrow(new Borrow(reader, prepareBorrowList(),
new Date(currentTime), new Date(currentTime + 2592000000l)));
em.getTransaction().commit();
entityManager = entityManagerFactory.createEntityManager();
Borrow borrow = entityManager.find(Borrow.class, 1l);
Book firstBook = entityManager.find(Book.class, 1l);
Book secondBook = entityManager.find(Book.class, 2l);
entityManager.close();
assertEquals(Available.BORROWED, firstBook.getAvailability());