List<Book> borrowList2 = new ArrayList<Book>();
borrowList2.add(entityManager.find(Book.class, 3l));
borrowList2.add(entityManager.find(Book.class, 4l));
// ID 1
Borrow borrow1 = new Borrow(entityManager.find(Reader.class, 1l), borrowList1, new Date(System.currentTimeMillis()),
new Date(System.currentTimeMillis()));
// ID 2
Borrow borrow2 = new Borrow(entityManager.find(Reader.class, 2l), borrowList2, new Date(System.currentTimeMillis()),
new Date(System.currentTimeMillis()));
entityManager.close();
entityManager = entityManagerFactory.createEntityManager();
entityManager.getTransaction().begin();
entityManager.persist(borrow1);
entityManager.getTransaction().commit();
entityManager.getTransaction().begin();
entityManager.persist(borrow2);
entityManager.getTransaction().commit();
entityManager.close();
borrow1.setBorrowID(1l);
borrow2.setBorrowID(2l);
assertEquals(borrow1, borrowDAO.findBorrowById(1l));
assertEquals(borrow2, borrowDAO.findBorrowById(2l));
}