Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(folder));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.SCOPE, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
}
/* 1 Filter Matches Folder (Location) */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(folder));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
search.setMatchAllConditions(true);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
}
/* 1 Filter Matches BM 1 (Scope) */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(bm1));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.SCOPE, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(filterSet.isEmpty());
}
/* 1 Filter Matches BM 1 (Location) */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(bm1));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(filterSet.isEmpty());
}
/* 2 Filter Matches All and BM 1 (Scope) */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
ISearchFilter filter = fFactory.createSearchFilter(null, null, "Foo");
filter.setMatchAllNews(true);
DynamicDAO.save(filter);
filterSet.add(filter);
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(bm1));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.SCOPE, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
}
/* 2 Filter Matches All and BM 1 (Location) */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
ISearchFilter filter = fFactory.createSearchFilter(null, null, "Foo");
filter.setMatchAllNews(true);
DynamicDAO.save(filter);
filterSet.add(filter);
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(bm1));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
}
/* 2 Filter Matches BM 1 and All (Scope) */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(bm1));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.SCOPE, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
ISearchFilter filter2 = fFactory.createSearchFilter(null, null, "Foo");
filter2.setMatchAllNews(true);
DynamicDAO.save(filter2);
filterSet.add(filter2);
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
assertEquals(2, filterSet.size());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
assertEquals(1, filterSet.size());
assertTrue(filterSet.contains(filter2));
}
/* 2 Filter Matches BM 1 and All (Location) */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(bm1));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
ISearchFilter filter2 = fFactory.createSearchFilter(null, null, "Foo");
filter2.setMatchAllNews(true);
DynamicDAO.save(filter2);
filterSet.add(filter2);
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
assertEquals(2, filterSet.size());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
assertEquals(1, filterSet.size());
assertTrue(filterSet.contains(filter2));
}
/* 1 Filter Matches BM 1 and Folder (Scope) */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { bm1, folder }));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.SCOPE, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
}
/* 1 Filter Matches BM 1 and Folder (Location) */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { bm1, folder }));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
}
/* 1 Filter Matches BM 1 and BM 2 (Scope) */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { bm1, bm2 }));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.SCOPE, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
}
/* 1 Filter Matches BM 1 and BM 2 (Location) */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { bm1, bm2 }));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
}
/* 1 Filter Matches Empty Folder Child (Scope) */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(bm1));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.SCOPE, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
DynamicDAO.delete(bm1);
assertTrue(CoreUtils.toEntities(scope).isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(filterSet.isEmpty());
}
/* 1 Filter Matches Empty Folder Child (Location) */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(bm1));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
DynamicDAO.delete(bm1);
assertTrue(CoreUtils.toEntities(scope).isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(filterSet.isEmpty());
}
/* 1 Filter Matches BM1 OR another condition */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(bm1));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearchCondition condition2 = fFactory.createSearchCondition(fFactory.createSearchField(INews.TITLE, INews.class.getName()), SearchSpecifier.CONTAINS, "Foo");
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
search.addSearchCondition(condition2);
search.setMatchAllConditions(false);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
DynamicDAO.delete(bm1);
assertTrue(CoreUtils.toEntities(scope).isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
}
/* 1 Filter Matches BM1 AND another condition */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(bm1));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearchCondition condition2 = fFactory.createSearchCondition(fFactory.createSearchField(INews.TITLE, INews.class.getName()), SearchSpecifier.CONTAINS, "Foo");
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
search.addSearchCondition(condition2);
search.setMatchAllConditions(true);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
DynamicDAO.delete(bm1);
assertTrue(CoreUtils.toEntities(scope).isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(filterSet.isEmpty());
}
/* 1 Filter Matches BM1 AND another Location */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(bm1));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.SCOPE, scope);
ISearchCondition condition2 = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
search.addSearchCondition(condition2);
search.setMatchAllConditions(true);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
DynamicDAO.delete(bm1);
assertTrue(CoreUtils.toEntities(scope).isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(filterSet.isEmpty());
}
/* 1 Filter Matches BM1 AND another Location */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(bm1));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearchCondition condition2 = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
search.addSearchCondition(condition2);
search.setMatchAllConditions(true);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);
DynamicDAO.delete(bm1);
assertTrue(CoreUtils.toEntities(scope).isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm1).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
CoreUtils.removeFiltersByScope(filterSet, ((IBookMark) bm2).getFeedLinkReference().getLinkAsText());
assertTrue(!filterSet.isEmpty());
}
/* 1 Filter Matches BM1 OR another Location */
{
Set<ISearchFilter> filterSet = new HashSet<ISearchFilter>();
Long[][] scope = ModelUtils.toPrimitive(Collections.singletonList(bm1));
ISearchCondition condition = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearchCondition condition2 = fFactory.createSearchCondition(fFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, scope);
ISearch search = fFactory.createSearch(null);
search.addSearchCondition(condition);
search.addSearchCondition(condition2);
search.setMatchAllConditions(false);
ISearchFilter filter = fFactory.createSearchFilter(null, search, "Foo");
DynamicDAO.save(filter);
filterSet.add(filter);