use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.
the class ArticleLuceneQueryBuilderTest method testGetDateRestrictions_published_future_noEditRights.
@Test
public void testGetDateRestrictions_published_future_noEditRights() {
Set<DateMode> modes = new HashSet<>(Arrays.asList(DateMode.PUBLISHED, DateMode.FUTURE));
Date date = new Date();
boolean hasEditRights = false;
QueryRestrictionGroup ret = builder.getDateRestrictions(modes, date, hasEditRights);
assertEquals(getPublishedQuery(date), ret.getQueryString());
}
use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.
the class ArticleLuceneQueryBuilderTest method testGetDateRestrictions_all.
@Test
public void testGetDateRestrictions_all() {
Set<DateMode> modes = new HashSet<>(Arrays.asList(DateMode.PUBLISHED, DateMode.ARCHIVED, DateMode.FUTURE));
Date date = new Date();
boolean hasEditRights = true;
QueryRestrictionGroup ret = builder.getDateRestrictions(modes, date, hasEditRights);
assertEquals("", ret.getQueryString());
}
use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.
the class ArticleLuceneQueryBuilderTest method testGetSubsSpaceRestriction_noEditRights.
@Test
public void testGetSubsSpaceRestriction_noEditRights() throws Exception {
ArticleLoadParameter param = new ArticleLoadParameter();
param.setBlogDocRef(docRef);
param.setDateModes(Arrays.asList(DateMode.PUBLISHED.name(), DateMode.FUTURE.name()));
param.setSubscriptionModes(Arrays.asList(SubscriptionMode.SUBSCRIBED.name(), SubscriptionMode.UNSUBSCRIBED.name()));
SpaceReference spaceRef = new SpaceReference("artSpace", wikiRef);
expectSpaceRightsCheck(spaceRef, null, false);
replayDefault();
QueryRestrictionGroup ret = builder.getSubsSpaceRestriction(param, spaceRef);
verifyDefault();
assertEquals(getSubsPublishQuery(spaceRef, param.getExecutionDate()), ret.getQueryString());
}
use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.
the class ArticleLuceneQueryBuilderTest method testGetArticleSubsRestrictions_subscribed_unsubscribed_noEditRights.
@Test
public void testGetArticleSubsRestrictions_subscribed_unsubscribed_noEditRights() {
Set<SubscriptionMode> modes = new HashSet<>(Arrays.asList(SubscriptionMode.SUBSCRIBED, SubscriptionMode.UNSUBSCRIBED));
boolean hasEditRights = false;
QueryRestrictionGroup ret = builder.getArticleSubsRestrictions(modes, docRef, hasEditRights);
assertEquals(getSubsQuery(false), ret.getQueryString());
}
use of com.celements.search.lucene.query.QueryRestrictionGroup in project celements-blog by celements.
the class ArticleLuceneQueryBuilderTest method testGetSubsRestrictions_multipleSub.
@Test
public void testGetSubsRestrictions_multipleSub() throws Exception {
DocumentReference subsBlogDocRef1 = new DocumentReference("subsBlog1", spaceRef);
DocumentReference subsBlogDocRef2 = new DocumentReference("subsBlog2", spaceRef);
DocumentReference subsBlogDocRef3 = new DocumentReference("subsBlog3", spaceRef);
DocumentReference subsBlogDocRef4 = new DocumentReference("subsBlog4", spaceRef);
SpaceReference subsSpaceRef1 = new SpaceReference("artSpace1", wikiRef);
SpaceReference subsSpaceRef2 = new SpaceReference("artSpace2", wikiRef);
SpaceReference subsSpaceRef3 = new SpaceReference("artSpace3", wikiRef);
ArticleLoadParameter param = new ArticleLoadParameter();
param.setBlogDocRef(docRef);
param.setSubscribedToBlogs(Arrays.asList(subsBlogDocRef1, subsBlogDocRef2, subsBlogDocRef3, subsBlogDocRef4));
param.setDateModes(Arrays.asList(DateMode.PUBLISHED.name()));
param.setSubscriptionModes(Arrays.asList(SubscriptionMode.SUBSCRIBED.name()));
expect(builder.blogService.getBlogSpaceRef(eq(subsBlogDocRef1))).andReturn(subsSpaceRef1).once();
expectSpaceRightsCheck(subsSpaceRef1, true, true);
expect(builder.blogService.getBlogSpaceRef(eq(subsBlogDocRef2))).andReturn(subsSpaceRef2).once();
expectSpaceRightsCheck(subsSpaceRef2, false, null);
expect(builder.blogService.getBlogSpaceRef(eq(subsBlogDocRef3))).andReturn(subsSpaceRef3).once();
expectSpaceRightsCheck(subsSpaceRef3, true, true);
expect(builder.blogService.getBlogSpaceRef(eq(subsBlogDocRef4))).andReturn(null).once();
expectSpaceRightsCheck(null, false, null);
replayDefault();
QueryRestrictionGroup ret = builder.getSubsRestrictions(param);
verifyDefault();
assertNotNull(ret);
String expected = "(" + RESTR_ARTICLE_ISSUBS + " AND (" + getSubsPublishQuery(subsSpaceRef1, param.getExecutionDate()) + " OR " + getSubsPublishQuery(subsSpaceRef3, param.getExecutionDate()) + "))";
assertEquals(expected, ret.getQueryString());
}
Aggregations