fail("Method should fail on null parameter.");
} catch (IllegalArgumentException e) {
// OK
}
Book book = createCustomBook1();
persist(book);
book.setId(book.getId() + 1);
try {
bookDAOImpl.updateBook(book);
fail("Method should fail on updating book with incorrect id"
+ "as it should not be in the database.");
} catch (IllegalArgumentException e) {
// OK
}
book = createCustomBook1();
persist(book);
book.setISBN(null);
try {
bookDAOImpl.updateBook(book);
fail("Method should fail on updating book with incorrect parameters.");
} catch (IllegalArgumentException e) {
//OK
}
book = createCustomBook1();
Book book2 = createCustomBook2();
persist(book);
book2.setId(book.getId());
em.getTransaction().begin();
bookDAOImpl.updateBook(book2);
em.getTransaction().commit();
//if method findBookById() does not work properly, result of this test is irrelevant
assertEquals(book2.getTitle(), bookDAOImpl.findBookById(book2.getId()).getTitle());
assertEquals(1, bookDAOImpl.findBookByAuthor("Autor2").size());
}