feed = DynamicDAO.save(createFeed());
} catch (PersistenceException e) {
fail(e.getMessage());
return;
}
final News initialNews = (News) createNews(feed);
final Feed[] initialFeed = new Feed[1];
final Person[] initialAuthor = new Person[1];
final Source[] initialSource = new Source[1];
final Guid[] initialGuid = new Guid[1];
final News[] updatedNews = new News[1];
final boolean[] NewsAddedCalled = new boolean[] { false };
final boolean[] NewsUpdatedCalled = new boolean[] { false };
NewsListener newsListener = null;
try {
newsListener = new NewsAdapter() {
@Override
public void entitiesAdded(Set<NewsEvent> events) {
NewsEvent event = events.iterator().next();
NewsAddedCalled[0] = true;
initialFeed[0] = (Feed) initialNews.getFeedReference().resolve();
initialAuthor[0] = (Person) initialNews.getAuthor();
initialSource[0] = (Source) initialNews.getSource();
initialGuid[0] = (Guid) initialNews.getGuid();
final News dbNews = (News) event.getEntity();
initialAuthor[0].setId(dbNews.getAuthor().getId());
initialAuthor[0].isIdentical(dbNews.getAuthor());
//FIXME Find a way to verify this without changing the id from the
//event handler
// initialNews.setId(dbNews.getId());
// assertTrue(initialNews.isIdentical(dbNews));
}
@Override
public void entitiesUpdated(Set<NewsEvent> events) {
NewsEvent event = events.iterator().next();
NewsUpdatedCalled[0] = true;
News dbNews = (News) event.getEntity();
assertTrue(updatedNews[0].isIdentical(dbNews));
}
};
DynamicDAO.addEntityListener(INews.class, newsListener);
INews news = DynamicDAO.save(initialNews);