try {
/* Add */
final FolderReference folderRef = new FolderReference(fDao.saveFolder(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 searchMarkAdded(Set<SearchMarkEvent> events) {
for (SearchMarkEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
assertEquals(folderRef.getId(), event.getEntity().getFolder().getId());
searchMarkEvents[0] = true;
}
}
public void searchMarkDeleted(Set<SearchMarkEvent> events) {
for (SearchMarkEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
assertEquals(folderRef.getId(), event.getEntity().getFolder().getId());
if (searchMarkReference[0].references(event.getEntity()))
searchMarkEvents[1] = true;
}
}
public void searchMarkUpdated(Set<SearchMarkEvent> events) {
for (SearchMarkEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
assertEquals(folderRef.getId(), event.getEntity().getFolder().getId());
if (searchMarkReference[0].references(event.getEntity()))
searchMarkEvents[2] = true;
}
}
};
fModel.addSearchMarkListener(searchMarkListener);
searchMarkReference[0] = new SearchMarkReference(fDao.saveSearchMark(searchMark).getId());
/* Update */
searchMark = searchMarkReference[0].resolve();
searchMark.setName("SearchMark Updated");
fDao.saveSearchMark(searchMark);