Search in sources :

Example 26 with QueryRestrictionGroup

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

the class ArticleLuceneQueryBuilderTest method testGetArticleSubsRestrictions_all_noEditRights.

@Test
public void testGetArticleSubsRestrictions_all_noEditRights() {
    DocumentReference blogConfDocRef = new DocumentReference("wiki", "space", "blog");
    Set<SubscriptionMode> modes = new HashSet<>(Arrays.asList(SubscriptionMode.SUBSCRIBED, SubscriptionMode.UNSUBSCRIBED, SubscriptionMode.UNDECIDED));
    boolean hasEditRights = false;
    QueryRestrictionGroup ret = builder.getArticleSubsRestrictions(modes, blogConfDocRef, hasEditRights);
    assertEquals(getSubsQuery(false), 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 27 with QueryRestrictionGroup

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

the class ArticleLuceneQueryBuilderTest method testGetDateRestrictions_published.

@Test
public void testGetDateRestrictions_published() {
    Set<DateMode> modes = new HashSet<>(Arrays.asList(DateMode.PUBLISHED));
    Date date = new Date();
    boolean hasEditRights = true;
    QueryRestrictionGroup ret = builder.getDateRestrictions(modes, date, hasEditRights);
    assertEquals(getPublishedQuery(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 28 with QueryRestrictionGroup

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

the class ArticleLuceneQueryBuilderTest method testGetArticleSubsRestrictions_undecided_unsubscribed_noEditRights.

@Test
public void testGetArticleSubsRestrictions_undecided_unsubscribed_noEditRights() {
    Set<SubscriptionMode> modes = new HashSet<>(Arrays.asList(SubscriptionMode.UNDECIDED, SubscriptionMode.UNSUBSCRIBED));
    boolean hasEditRights = false;
    QueryRestrictionGroup ret = builder.getArticleSubsRestrictions(modes, docRef, hasEditRights);
    assertNull(ret);
}
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 29 with QueryRestrictionGroup

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

the class ArticleLuceneQueryBuilderTest method testGetDateRestrictions_none.

@Test
public void testGetDateRestrictions_none() {
    Set<DateMode> modes = Collections.emptySet();
    Date date = new Date();
    boolean hasEditRights = true;
    QueryRestrictionGroup ret = builder.getDateRestrictions(modes, date, hasEditRights);
    assertNull(ret);
}
Also used : DateMode(com.celements.blog.article.ArticleLoadParameter.DateMode) Date(java.util.Date) QueryRestrictionGroup(com.celements.search.lucene.query.QueryRestrictionGroup) Test(org.junit.Test)

Example 30 with QueryRestrictionGroup

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

the class ArticleLuceneQueryBuilderTest method testGetSubsSpaceRestriction.

@Test
public void testGetSubsSpaceRestriction() throws Exception {
    ArticleLoadParameter param = new ArticleLoadParameter();
    param.setBlogDocRef(docRef);
    param.setDateModes(Arrays.asList(DateMode.PUBLISHED.name()));
    param.setSubscriptionModes(Arrays.asList(SubscriptionMode.SUBSCRIBED.name()));
    SpaceReference spaceRef = new SpaceReference("artSpace", wikiRef);
    expectSpaceRightsCheck(spaceRef, null, true);
    replayDefault();
    QueryRestrictionGroup ret = builder.getSubsSpaceRestriction(param, spaceRef);
    verifyDefault();
    assertEquals(getSubsPublishQuery(spaceRef, param.getExecutionDate()), ret.getQueryString());
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) 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