Search in sources :

Example 16 with QueryRestrictionGroup

use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetArticleSubsRestrictions_all.

@Test
public void testGetArticleSubsRestrictions_all() {
    DocumentReference blogConfDocRef = new DocumentReference("wiki", "space", "blog");
    Set<SubscriptionMode> modes = new HashSet<>(Arrays.asList(SubscriptionMode.SUBSCRIBED, SubscriptionMode.UNSUBSCRIBED, SubscriptionMode.UNDECIDED));
    boolean hasEditRights = true;
    QueryRestrictionGroup ret = builder.getArticleSubsRestrictions(modes, blogConfDocRef, hasEditRights);
    assertEquals("", ret.getQueryString());
}
Also used : SubscriptionMode(com.celements.blog.article.ArticleLoadParameter.SubscriptionMode) DocumentReference(org.xwiki.model.reference.DocumentReference) HashSet(java.util.HashSet) QueryRestrictionGroup(com.celements.search.lucene.query.QueryRestrictionGroup) Test(org.junit.Test)

Example 17 with QueryRestrictionGroup

use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetArticleSubsRestrictions_none.

@Test
public void testGetArticleSubsRestrictions_none() {
    Set<SubscriptionMode> modes = Collections.emptySet();
    boolean hasEditRights = true;
    QueryRestrictionGroup ret = builder.getArticleSubsRestrictions(modes, docRef, hasEditRights);
    assertNull(ret);
}
Also used : SubscriptionMode(com.celements.blog.article.ArticleLoadParameter.SubscriptionMode) QueryRestrictionGroup(com.celements.search.lucene.query.QueryRestrictionGroup) Test(org.junit.Test)

Example 18 with QueryRestrictionGroup

use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetArticleSubsRestrictions_subscribed_noEditRights.

@Test
public void testGetArticleSubsRestrictions_subscribed_noEditRights() {
    Set<SubscriptionMode> modes = new HashSet<>(Arrays.asList(SubscriptionMode.SUBSCRIBED));
    boolean hasEditRights = false;
    QueryRestrictionGroup ret = builder.getArticleSubsRestrictions(modes, docRef, hasEditRights);
    assertEquals(getSubsQuery(false), ret.getQueryString());
}
Also used : SubscriptionMode(com.celements.blog.article.ArticleLoadParameter.SubscriptionMode) HashSet(java.util.HashSet) QueryRestrictionGroup(com.celements.search.lucene.query.QueryRestrictionGroup) Test(org.junit.Test)

Example 19 with QueryRestrictionGroup

use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetDateRestrictions_future.

@Test
public void testGetDateRestrictions_future() {
    Set<DateMode> modes = new HashSet<>(Arrays.asList(DateMode.FUTURE));
    Date date = new Date();
    boolean hasEditRights = true;
    QueryRestrictionGroup ret = builder.getDateRestrictions(modes, date, hasEditRights);
    assertEquals(getFutureQuery(date), ret.getQueryString());
}
Also used : DateMode(com.celements.blog.article.ArticleLoadParameter.DateMode) Date(java.util.Date) HashSet(java.util.HashSet) QueryRestrictionGroup(com.celements.search.lucene.query.QueryRestrictionGroup) Test(org.junit.Test)

Example 20 with QueryRestrictionGroup

use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetDateRestrictions_archived_noEditRights.

@Test
public void testGetDateRestrictions_archived_noEditRights() {
    Set<DateMode> modes = new HashSet<>(Arrays.asList(DateMode.ARCHIVED));
    Date date = new Date();
    boolean hasEditRights = false;
    QueryRestrictionGroup ret = builder.getDateRestrictions(modes, date, hasEditRights);
    assertEquals(getArchivedQuery(date), ret.getQueryString());
}
Also used : DateMode(com.celements.blog.article.ArticleLoadParameter.DateMode) Date(java.util.Date) HashSet(java.util.HashSet) QueryRestrictionGroup(com.celements.search.lucene.query.QueryRestrictionGroup) Test(org.junit.Test)

Aggregations

QueryRestrictionGroup (com.celements.search.lucene.query.QueryRestrictionGroup)45 Test (org.junit.Test)37 HashSet (java.util.HashSet)28 DateMode (com.celements.blog.article.ArticleLoadParameter.DateMode)15 SubscriptionMode (com.celements.blog.article.ArticleLoadParameter.SubscriptionMode)15 Date (java.util.Date)15 SpaceReference (org.xwiki.model.reference.SpaceReference)8 DocumentReference (org.xwiki.model.reference.DocumentReference)7 IQueryRestriction (com.celements.search.lucene.query.IQueryRestriction)4 LuceneQuery (com.celements.search.lucene.query.LuceneQuery)1 QueryRestriction (com.celements.search.lucene.query.QueryRestriction)1 WikiReference (org.xwiki.model.reference.WikiReference)1