FeedListener feedListener = null;
try {
feedListener = new FeedAdapter() {
@Override
public void entitiesAdded(Set<FeedEvent> events) {
FeedEvent event = events.iterator().next();
try {
feedAddedCalled[0] = true;
initialAuthor[0] = (Person) initialFeed.getAuthor();
initialImage[0] = (Image) initialFeed.getImage();
Feed dbFeed = (Feed) event.getEntity();
initialAuthor[0].setId(dbFeed.getAuthor().getId());
initialAuthor[0].isIdentical(dbFeed.getAuthor());
initialImage[0].equals(dbFeed.getImage());
initialFeed.setId(dbFeed.getId());
assertTrue(NOT_IDENTICAL_MESSAGE, initialFeed.isIdentical(dbFeed));
dbFeed.setCopyright("GPL");
dbFeed.setFormat("someDifferentformat");
dbFeed.getImage().setHeight(150);
dbFeed.getImage().setDescription("Some new description");
dbFeed.getImage().setTitle("yet another title");
updatedFeed[0] = dbFeed;
DynamicDAO.save(dbFeed);
} catch (PersistenceException e) {
fail(e.getMessage());
}
}
@Override
public void entitiesUpdated(Set<FeedEvent> events) {
FeedEvent event = events.iterator().next();
feedUpdatedCalled[0] = true;
Feed dbFeed = (Feed) event.getEntity();
assertTrue(updatedFeed[0].isIdentical(dbFeed));
}
};
DynamicDAO.addEntityListener(IFeed.class, feedListener);
DynamicDAO.save(initialFeed);