use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.
the class ArticleLuceneQueryBuilderTest method testGetSubsRestrictions_oneSub.
@Test
public void testGetSubsRestrictions_oneSub() throws Exception {
DocumentReference subsBlogDocRef = new DocumentReference("subsBlog", spaceRef);
SpaceReference subsSpaceRef = new SpaceReference("artSpace", wikiRef);
ArticleLoadParameter param = new ArticleLoadParameter();
param.setBlogDocRef(docRef);
param.setSubscribedToBlogs(Arrays.asList(subsBlogDocRef));
param.setDateModes(Arrays.asList(DateMode.PUBLISHED.name()));
param.setSubscriptionModes(Arrays.asList(SubscriptionMode.SUBSCRIBED.name()));
expect(builder.blogService.getBlogSpaceRef(eq(subsBlogDocRef))).andReturn(subsSpaceRef).once();
expectSpaceRightsCheck(subsSpaceRef, true, true);
replayDefault();
QueryRestrictionGroup ret = builder.getSubsRestrictions(param);
verifyDefault();
assertNotNull(ret);
String expected = "(" + RESTR_ARTICLE_ISSUBS + " AND " + getSubsPublishQuery(subsSpaceRef, param.getExecutionDate()) + ")";
assertEquals(expected, ret.getQueryString());
}
use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.
the class ArticleLuceneQueryBuilderTest method testGetDateRestrictions_archived_future_noEditRights.
@Test
public void testGetDateRestrictions_archived_future_noEditRights() {
Set<DateMode> modes = new HashSet<>(Arrays.asList(DateMode.ARCHIVED, DateMode.FUTURE));
Date date = new Date();
boolean hasEditRights = false;
QueryRestrictionGroup ret = builder.getDateRestrictions(modes, date, hasEditRights);
assertEquals(getArchivedQuery(date), ret.getQueryString());
}
use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.
the class ArticleLuceneQueryBuilderTest method testGetDateRestrictions_published_archived_noEditRights.
@Test
public void testGetDateRestrictions_published_archived_noEditRights() {
Set<DateMode> modes = new HashSet<>(Arrays.asList(DateMode.PUBLISHED, DateMode.ARCHIVED));
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());
}
use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.
the class ArticleLuceneQueryBuilderTest method testGetSubsSpaceRestriction_noDateQuery.
@Test
public void testGetSubsSpaceRestriction_noDateQuery() throws Exception {
ArticleLoadParameter param = new ArticleLoadParameter();
param.setBlogDocRef(docRef);
param.setDateModes(Collections.<String>emptyList());
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();
assertNull(ret);
}
use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.
the class ArticleLuceneQueryBuilderTest method testGetArticleSubsRestrictions_undecided_noEditRights.
@Test
public void testGetArticleSubsRestrictions_undecided_noEditRights() {
Set<SubscriptionMode> modes = new HashSet<>(Arrays.asList(SubscriptionMode.UNDECIDED));
boolean hasEditRights = false;
QueryRestrictionGroup ret = builder.getArticleSubsRestrictions(modes, docRef, hasEditRights);
assertNull(ret);
}
Aggregations