differentAuthor.getBooks().get(0) != book);
}
public void testSaves() throws Exception
{
Criteria criteria = new Criteria();
criteria.add(BookPeer.BOOK_ID, (Long) null, Criteria.NOT_EQUAL);
BookPeer.doDelete(criteria);
criteria = new Criteria();
criteria.add(AuthorPeer.AUTHOR_ID, (Long) null, Criteria.NOT_EQUAL);
AuthorPeer.doDelete(criteria);
Author author = new Author();
author.setName(AUTHOR_1_NAME);
author.save();
assertFalse("isModified() should return false after save",
author.isModified());
assertFalse("isNew() should return false after save",
author.isNew());
AuthorBean authorBean = author.getBean();
assertFalse("bean.isModified() should return false after save "
+ "and bean creation",
authorBean.isModified());
assertFalse("bean.isNew() should return false after save "
+ "and bean creation",
authorBean.isNew());
author = Author.createAuthor(authorBean);
assertFalse("isModified() should return false after save "
+ "and bean roundtrip",
author.isModified());
assertFalse("isNew() should return false after save "
+ "and bean rounddtrip",
author.isNew());
authorBean.setName(AUTHOR_2_NAME);
assertTrue("bean.isModified() should return true after it was modified",
authorBean.isModified());
assertFalse("bean.isNew() should still return false "
+ "after bean creation and modification",
authorBean.isNew());
author = Author.createAuthor(authorBean);
assertTrue("isModified() should return true after creation of object "
+ "from modified bean",
author.isModified());
author.save();
List authorList = AuthorPeer.doSelect(new Criteria());
Author readAuthor = (Author) authorList.get(0);
assertEquals("name from read Author is " + readAuthor.getName()
+" but should be " + authorBean.getName(),
readAuthor.getName(),
authorBean.getName());
BookBean bookBean = new BookBean();
bookBean.setTitle(BOOK_1_TITLE);
bookBean.setIsbn(BOOK_1_ISBN);
Book book = Book.createBook(bookBean);
assertTrue("isModified() should return true after creation of object "
+ " from new bean",
book.isModified());
assertTrue("isNew() should return true after creation of object "
+ " from new bean",
book.isNew());
book.setAuthor(author);
book.save();
List bookList = BookPeer.doSelect(new Criteria());
assertTrue("Ther should be one book in DB but there are "
+ bookList.size(),
bookList.size() == 1);
}