if (mark instanceof ISearchMark)
searchmarks.add((ISearchMark) mark);
}
/* 1) State ISnew */
ISearchMark searchmark = searchmarks.get(0);
assertEquals("Search", searchmark.getName());
List<ISearchCondition> conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
assertEquals(INews.STATE, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.IS, conditions.get(0).getSpecifier());
assertEquals(EnumSet.of(INews.State.NEW), conditions.get(0).getValue());
if (isBackup)
assertProperties(Owl.getPreferenceService().getEntityScope(searchmark));
/* 2) State ISnewunreadupdated */
searchmark = searchmarks.get(1);
conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
assertEquals(INews.STATE, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.IS, conditions.get(0).getSpecifier());
assertEquals(EnumSet.of(INews.State.NEW, INews.State.UNREAD, INews.State.UPDATED), conditions.get(0).getValue());
/* 3) Entire News CONTAINS foo?bar */
searchmark = searchmarks.get(2);
conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
assertEquals(IEntity.ALL_FIELDS, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.CONTAINS, conditions.get(0).getSpecifier());
assertEquals("foo?bar", conditions.get(0).getValue());
/* 4) Age in Days is > 5 */
searchmark = searchmarks.get(3);
conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
assertEquals(INews.AGE_IN_DAYS, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.IS_GREATER_THAN, conditions.get(0).getSpecifier());
assertEquals(5, conditions.get(0).getValue());
/* 5) Publish Date is 26.12.1981 */
Calendar cal = DateUtils.getToday();
cal.set(Calendar.YEAR, 1981);
cal.set(Calendar.MONTH, Calendar.DECEMBER);
cal.set(Calendar.DATE, 26);
searchmark = searchmarks.get(4);
conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
assertEquals(INews.PUBLISH_DATE, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.IS, conditions.get(0).getSpecifier());
assertEquals(cal.getTime(), conditions.get(0).getValue());
/* 6) Feed Links is not http://www.rssowl.org/node/feed */
searchmark = searchmarks.get(5);
conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
assertEquals(INews.FEED, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.IS_NOT, conditions.get(0).getSpecifier());
assertEquals("http://www.rssowl.org/node/feed", conditions.get(0).getValue());
/* 7) Has Attachments is TRUE */
searchmark = searchmarks.get(6);
conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
assertEquals(INews.HAS_ATTACHMENTS, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.IS, conditions.get(0).getSpecifier());
assertEquals(true, conditions.get(0).getValue());
/*
* 8) Entire News CONTAINS foo?bar AND State ISnew AND Has Attachments is
* TRUE
*/
searchmark = searchmarks.get(7);
conditions = searchmark.getSearchConditions();
assertEquals(3, conditions.size());
assertEquals(true, searchmark.matchAllConditions());
for (ISearchCondition condition : conditions) {
switch (condition.getField().getId()) {
case IEntity.ALL_FIELDS:
assertEquals(SearchSpecifier.CONTAINS, condition.getSpecifier());
assertEquals("foo?bar", condition.getValue());
break;
case INews.STATE:
assertEquals(SearchSpecifier.IS, condition.getSpecifier());
assertEquals(EnumSet.of(INews.State.NEW), condition.getValue());
break;
case INews.HAS_ATTACHMENTS:
assertEquals(SearchSpecifier.IS, condition.getSpecifier());
assertEquals(true, condition.getValue());
break;
default:
fail();
}
}
/* 9) Location is Default Set */
searchmark = searchmarks.get(8);
conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
assertEquals(INews.LOCATION, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.IS, conditions.get(0).getSpecifier());
assertEquals(Arrays.asList(new IFolderChild[] { fDefaultSet }), CoreUtils.toEntities((Long[][]) conditions.get(0).getValue()));
/* 10) Location is Default Set OR Location is Custom Set */
searchmark = searchmarks.get(9);
conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
List<IFolderChild> locations = CoreUtils.toEntities((Long[][]) conditions.get(0).getValue());
assertEquals(INews.LOCATION, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.IS, conditions.get(0).getSpecifier());
assertEquals(2, locations.size());
assertContains("My Bookmarks", locations);
assertContains("Custom", locations);
/* 11) Location is Folder 1 */
searchmark = searchmarks.get(10);
conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
assertEquals(INews.LOCATION, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.IS, conditions.get(0).getSpecifier());
locations = CoreUtils.toEntities((Long[][]) conditions.get(0).getValue());
assertEquals(1, locations.size());
assertEquals(true, locations.get(0) instanceof IFolder);
assertEquals("Default Folder 1", locations.get(0).getName());
/* 12) Location is BookMark 1 */
searchmark = searchmarks.get(11);
conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
assertEquals(INews.LOCATION, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.IS, conditions.get(0).getSpecifier());
locations = CoreUtils.toEntities((Long[][]) conditions.get(0).getValue());
assertEquals(1, locations.size());
assertEquals(true, locations.get(0) instanceof IBookMark);
assertEquals("Bookmark 1", locations.get(0).getName());
/*
* 13) Location is Default Set OR Location is Custom Set OR Location is
* BookMark1
*/
searchmark = searchmarks.get(12);
conditions = searchmark.getSearchConditions();
assertEquals(3, conditions.size());
locations = new ArrayList<IFolderChild>();
for (ISearchCondition condition : conditions) {
assertEquals(INews.LOCATION, condition.getField().getId());
assertEquals(SearchSpecifier.IS, condition.getSpecifier());
locations.addAll(CoreUtils.toEntities((Long[][]) condition.getValue()));
}
assertEquals(3, locations.size());
assertContains("My Bookmarks", locations);
assertContains("Custom", locations);
assertContains("Bookmark 1", locations);
/* 14) Location is Bin 1 */
searchmark = searchmarks.get(13);
conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
assertEquals(INews.LOCATION, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.IS, conditions.get(0).getSpecifier());
locations = CoreUtils.toEntities((Long[][]) conditions.get(0).getValue());
assertEquals(1, locations.size());
assertEquals(true, locations.get(0) instanceof INewsBin);
assertEquals(fNewsBin.getName(), locations.get(0).getName());
/* 15) Entire News CONTAINS_ALL foo?bar */
searchmark = searchmarks.get(14);
conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
assertEquals(IEntity.ALL_FIELDS, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.CONTAINS_ALL, conditions.get(0).getSpecifier());
assertEquals("foo?bar", conditions.get(0).getValue());
/* 16) Entire News CONTAINS_NOT foo?bar */
searchmark = searchmarks.get(15);
conditions = searchmark.getSearchConditions();
assertEquals(1, conditions.size());
assertEquals(IEntity.ALL_FIELDS, conditions.get(0).getField().getId());
assertEquals(SearchSpecifier.CONTAINS_NOT, conditions.get(0).getSpecifier());
assertEquals("foo?bar", conditions.get(0).getValue());
}