use of com.celements.search.lucene.query.IQueryRestriction in project celements-blog by celements.
the class ArticleLuceneQueryBuilderTest method testGetBlogRestriction_noEdit.
@Test
public void testGetBlogRestriction_noEdit() throws Exception {
ArticleLoadParameter param = new ArticleLoadParameter();
param.setBlogDocRef(docRef);
param.setDateModes(Arrays.asList(DateMode.ARCHIVED.name()));
SpaceReference spaceRef = new SpaceReference("artSpace", wikiRef);
expect(builder.blogService.getBlogSpaceRef(eq(docRef))).andReturn(spaceRef).once();
expectSpaceRightsCheck(spaceRef, true, false);
replayDefault();
IQueryRestriction ret = builder.getBlogRestriction(param);
verifyDefault();
assertEquals("(space:(+\"" + spaceRef.getName() + "\") AND " + getArchivedQuery(param.getExecutionDate()) + ")", ret.getQueryString());
}
use of com.celements.search.lucene.query.IQueryRestriction in project celements-blog by celements.
the class BlogWebSearchPackageTest method test_getQueryRestriction_date.
@Test
public void test_getQueryRestriction_date() {
String searchTerm = "201708010830";
IQueryRestriction restriction = webSearchPackage.getQueryRestriction(null, searchTerm);
assertNotNull(restriction);
assertEquals(String.format("(XWiki.ArticleClass.lang:(+%s*) AND " + "XWiki.ArticleClass.publishdate:(%s))", getContext().getLanguage(), searchTerm), restriction.getQueryString());
}
use of com.celements.search.lucene.query.IQueryRestriction in project celements-blog by celements.
the class ArticleLuceneQueryBuilderTest method testGetBlogRestriction.
@Test
public void testGetBlogRestriction() throws Exception {
ArticleLoadParameter param = new ArticleLoadParameter();
param.setBlogDocRef(docRef);
param.setDateModes(Arrays.asList(DateMode.FUTURE.name()));
SpaceReference spaceRef = new SpaceReference("artSpace", wikiRef);
expect(builder.blogService.getBlogSpaceRef(eq(docRef))).andReturn(spaceRef).once();
expectSpaceRightsCheck(spaceRef, true, true);
replayDefault();
IQueryRestriction ret = builder.getBlogRestriction(param);
verifyDefault();
assertEquals("(space:(+\"" + spaceRef.getName() + "\") AND " + getFutureQuery(param.getExecutionDate()) + ")", ret.getQueryString());
}
use of com.celements.search.lucene.query.IQueryRestriction in project celements-blog by celements.
the class BlogWebSearchPackageTest method test_getQueryRestriction_empty.
@Test
public void test_getQueryRestriction_empty() {
String searchTerm = "";
IQueryRestriction restriction = webSearchPackage.getQueryRestriction(null, searchTerm);
assertNotNull(restriction);
assertEquals(String.format("XWiki.ArticleClass.lang:(+%s*)", getContext().getLanguage()), restriction.getQueryString());
}
use of com.celements.search.lucene.query.IQueryRestriction in project celements-blog by celements.
the class BlogWebSearchPackageTest method test_getQueryRestriction_text_exact.
@Test
public void test_getQueryRestriction_text_exact() {
String searchTerm = LuceneUtils.exactify("find me");
IQueryRestriction restriction = webSearchPackage.getQueryRestriction(null, searchTerm);
assertNotNull(restriction);
assertEquals(String.format("(XWiki.ArticleClass.lang:(+%s*) AND " + "(XWiki.ArticleClass.title:(+%s) OR XWiki.ArticleClass.extract:(+%s) OR " + "XWiki.ArticleClass.content:(+%s)))", getContext().getLanguage(), searchTerm, searchTerm, searchTerm), restriction.getQueryString());
}
Aggregations