FolderReference folderRef = new FolderReference(DynamicDAO.save(fFactory.createFolder(null, null, "Folder")).getId());
ISearchMark searchMark = DynamicDAO.save(fFactory.createSearchMark(null, folderRef.resolve(), "SearchMark"));
ISearchField field = fFactory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
ISearchCondition searchCondition = fFactory.createSearchCondition(null, searchMark, field, SearchSpecifier.CONTAINS, "Foo");
final boolean searchConditionEvents[] = new boolean[3];
final SearchConditionReference searchConditionReference[] = new SearchConditionReference[1];
searchConditionListener = new SearchConditionListener() {
public void entitiesAdded(Set<SearchConditionEvent> events) {
for (SearchConditionEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
searchConditionEvents[0] = true;
}
}
public void entitiesDeleted(Set<SearchConditionEvent> events) {
for (SearchConditionEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
if (searchConditionReference[0].references(event.getEntity()))
searchConditionEvents[1] = true;
}
}
public void entitiesUpdated(Set<SearchConditionEvent> events) {
for (SearchConditionEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
if (searchConditionReference[0].references(event.getEntity()))
searchConditionEvents[2] = true;
}
}
};
DynamicDAO.addEntityListener(ISearchCondition.class, searchConditionListener);
searchConditionReference[0] = new SearchConditionReference(DynamicDAO.save(searchCondition).getId());
DynamicDAO.removeEntityListener(ISearchCondition.class, searchConditionListener);
DynamicDAO.save(searchMark);
searchMark = null;
System.gc();