Search in sources :

Example 6 with IQueryRestriction

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());
}
Also used : IQueryRestriction(com.celements.search.lucene.query.IQueryRestriction) SpaceReference(org.xwiki.model.reference.SpaceReference) Test(org.junit.Test)

Example 7 with IQueryRestriction

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());
}
Also used : IQueryRestriction(com.celements.search.lucene.query.IQueryRestriction) AbstractComponentTest(com.celements.common.test.AbstractComponentTest) Test(org.junit.Test)

Example 8 with IQueryRestriction

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());
}
Also used : IQueryRestriction(com.celements.search.lucene.query.IQueryRestriction) SpaceReference(org.xwiki.model.reference.SpaceReference) Test(org.junit.Test)

Example 9 with IQueryRestriction

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());
}
Also used : IQueryRestriction(com.celements.search.lucene.query.IQueryRestriction) AbstractComponentTest(com.celements.common.test.AbstractComponentTest) Test(org.junit.Test)

Example 10 with IQueryRestriction

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());
}
Also used : IQueryRestriction(com.celements.search.lucene.query.IQueryRestriction) AbstractComponentTest(com.celements.common.test.AbstractComponentTest) Test(org.junit.Test)

Aggregations

IQueryRestriction (com.celements.search.lucene.query.IQueryRestriction)13 Test (org.junit.Test)9 SpaceReference (org.xwiki.model.reference.SpaceReference)6 AbstractComponentTest (com.celements.common.test.AbstractComponentTest)4 QueryRestrictionGroup (com.celements.search.lucene.query.QueryRestrictionGroup)4 QueryRestriction (com.celements.search.lucene.query.QueryRestriction)1