Search in sources :

Example 11 with DateMode

use of com.celements.blog.article.ArticleLoadParameter.DateMode in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetDateRestrictions_all_noEditRights.

@Test
public void testGetDateRestrictions_all_noEditRights() {
    Set<DateMode> modes = new HashSet<>(Arrays.asList(DateMode.PUBLISHED, DateMode.ARCHIVED, DateMode.FUTURE));
    Date date = new Date();
    boolean hasEditRights = false;
    QueryRestrictionGroup ret = builder.getDateRestrictions(modes, date, hasEditRights);
    String expectedQuery = "(" + getPublishedQuery(date) + " OR " + getArchivedQuery(date) + ")";
    assertEquals(expectedQuery, 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 12 with DateMode

use of com.celements.blog.article.ArticleLoadParameter.DateMode in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetDateRestrictions_archived.

@Test
public void testGetDateRestrictions_archived() {
    Set<DateMode> modes = new HashSet<>(Arrays.asList(DateMode.ARCHIVED));
    Date date = new Date();
    boolean hasEditRights = true;
    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)

Example 13 with DateMode

use of com.celements.blog.article.ArticleLoadParameter.DateMode in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetDateRestrictions_archived_future.

@Test
public void testGetDateRestrictions_archived_future() {
    Set<DateMode> modes = new HashSet<>(Arrays.asList(DateMode.ARCHIVED, DateMode.FUTURE));
    Date date = new Date();
    boolean hasEditRights = true;
    QueryRestrictionGroup ret = builder.getDateRestrictions(modes, date, hasEditRights);
    String expectedQuery = "(" + getFutureQuery(date) + " OR " + getArchivedQuery(date) + ")";
    assertEquals(expectedQuery, 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 14 with DateMode

use of com.celements.blog.article.ArticleLoadParameter.DateMode in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetDateRestrictions_published_future.

@Test
public void testGetDateRestrictions_published_future() {
    Set<DateMode> modes = new HashSet<>(Arrays.asList(DateMode.PUBLISHED, DateMode.FUTURE));
    Date date = new Date();
    boolean hasEditRights = true;
    QueryRestrictionGroup ret = builder.getDateRestrictions(modes, date, hasEditRights);
    String expectedQuery = "(" + getPublishedQuery(date) + " OR " + getFutureQuery(date) + ")";
    assertEquals(expectedQuery, 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 15 with DateMode

use of com.celements.blog.article.ArticleLoadParameter.DateMode in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetDateRestrictions_published_noEditRights.

@Test
public void testGetDateRestrictions_published_noEditRights() {
    Set<DateMode> modes = new HashSet<>(Arrays.asList(DateMode.PUBLISHED));
    Date date = new Date();
    boolean hasEditRights = false;
    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)

Aggregations

DateMode (com.celements.blog.article.ArticleLoadParameter.DateMode)16 QueryRestrictionGroup (com.celements.search.lucene.query.QueryRestrictionGroup)15 Date (java.util.Date)15 Test (org.junit.Test)15 HashSet (java.util.HashSet)14 SubscriptionMode (com.celements.blog.article.ArticleLoadParameter.SubscriptionMode)1 XWikiException (com.xpn.xwiki.XWikiException)1 ArrayList (java.util.ArrayList)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 SpaceReference (org.xwiki.model.reference.SpaceReference)1