final IFeed feed = fFactory.createFeed(null, new URI("http://www.feed.com"));
final FeedReference feedRef = new FeedReference(DynamicDAO.save(feed).getId());
IBookMark bookMark1 = fFactory.createBookMark(null, rootRef.resolve(), new FeedLinkReference(feed.getLink()), "Root BookMark");
root = DynamicDAO.save(bookMark1.getParent());
final BookMarkReference bookMarkRef1 = new BookMarkReference(root.getMarks().get(0).getId());
IBookMark bookMark2 = fFactory.createBookMark(null, rootChildRef.resolve(), new FeedLinkReference(feed.getLink()), "Root Child BookMark");
rootChild = DynamicDAO.save(bookMark2.getParent());
final BookMarkReference bookMarkRef2 = new BookMarkReference(rootChild.getMarks().get(0).getId());
IBookMark bookMark3 = fFactory.createBookMark(null, rootChildChild1Ref.resolve(), new FeedLinkReference(feed.getLink()), "Root Child Child #1 BookMark");
rootChildChild1 = DynamicDAO.save(bookMark3.getParent());
final BookMarkReference bookMarkRef3 = new BookMarkReference(rootChildChild1.getMarks().get(0).getId());
final boolean bookMarkEventsIssued[] = new boolean[3];
final boolean feedEventsIssued[] = new boolean[1];
bookMarkListener = new BookMarkAdapter() {
@Override
public void entitiesDeleted(Set<BookMarkEvent> events) {
for (BookMarkEvent event : events) {
IBookMark bookMark = event.getEntity();
if (bookMarkRef1.references(bookMark))
bookMarkEventsIssued[0] = true;
else if (bookMarkRef2.references(bookMark))
bookMarkEventsIssued[1] = true;
else if (bookMarkRef3.references(bookMark))
bookMarkEventsIssued[2] = true;
}
}
};
DynamicDAO.addEntityListener(IBookMark.class, bookMarkListener);