DynamicDAO.addEntityListener(IFeed.class, feedListener);
/* Save Feed since a IBookMark now doesn't contain a feed */
DynamicDAO.save(feed);
final IBookMark bookMark1 = fFactory.createBookMark(null, root, new FeedLinkReference(feed.getLink()), "Root BookMark");
final IBookMark bookMark2 = fFactory.createBookMark(null, rootChild, new FeedLinkReference(feed.getLink()), "Root Child BookMark");
final IBookMark bookMark3 = fFactory.createBookMark(null, rootChildChild1Child, new FeedLinkReference(feed.getLink()), "Root Child Child #1 BookMark");
final boolean bookMarkEventsIssued[] = new boolean[3];
bookMarkListener = new BookMarkAdapter() {
@Override
public void entitiesAdded(Set<BookMarkEvent> events) {
for (BookMarkEvent event : events) {
assertFalse("Expected this Event to be no Root Event", event.isRoot());
IBookMark bookMark = event.getEntity();
if ("Root BookMark".equals(bookMark.getName()))
assertEquals("Root", bookMark.getParent().getName());
else if ("Root Child BookMark".equals(bookMark.getName()))
assertEquals("Root Child", bookMark.getParent().getName());
else if ("Root Child Child #1 BookMark".equals(bookMark.getName()))
assertEquals("Root Child Child #1 Child", bookMark.getParent().getName());
if (bookMark.getName().equals(bookMark1.getName()))
bookMarkEventsIssued[0] = true;
else if (bookMark.getName().equals(bookMark2.getName()))
bookMarkEventsIssued[1] = true;
else if (bookMark.getName().equals(bookMark3.getName()))
bookMarkEventsIssued[2] = true;
}
}
};
DynamicDAO.addEntityListener(IBookMark.class, bookMarkListener);