try {
/* Add */
final FolderReference folderRef = new FolderReference(DynamicDAO.save(fFactory.createFolder(null, null, "Folder")).getId());
ISearchMark searchMark = fFactory.createSearchMark(null, folderRef.resolve(), "SearchMark");
final boolean searchMarkEvents[] = new boolean[3];
final SearchMarkReference searchMarkReference[] = new SearchMarkReference[1];
searchMarkListener = new SearchMarkListener() {
public void entitiesAdded(Set<SearchMarkEvent> events) {
for (SearchMarkEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
assertEquals(folderRef.getId(), event.getEntity().getParent().getId());
searchMarkEvents[0] = true;
}
}
public void entitiesDeleted(Set<SearchMarkEvent> events) {
for (SearchMarkEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
assertEquals(folderRef.getId(), event.getEntity().getParent().getId());
if (searchMarkReference[0].references(event.getEntity()))
searchMarkEvents[1] = true;
}
}
public void entitiesUpdated(Set<SearchMarkEvent> events) {
for (SearchMarkEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
assertEquals(folderRef.getId(), event.getEntity().getParent().getId());
if (searchMarkReference[0].references(event.getEntity()))
searchMarkEvents[2] = true;
}
}
public void resultsChanged(Set<SearchMarkEvent> events) {
fail("Unexpected event");
}
};
DynamicDAO.addEntityListener(ISearchMark.class, searchMarkListener);
searchMarkReference[0] = new SearchMarkReference(DynamicDAO.save(searchMark).getId());
/* Update */
searchMark = searchMarkReference[0].resolve();
searchMark.setName("SearchMark Updated");
DynamicDAO.save(searchMark);