Search in sources :

Example 71 with SpaceReference

use of org.xwiki.model.reference.SpaceReference in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetBlogRestriction_noEdit_future.

@Test
public void testGetBlogRestriction_noEdit_future() throws Exception {
    ArticleLoadParameter param = new ArticleLoadParameter();
    param.setBlogDocRef(docRef);
    param.setDateModes(Arrays.asList(DateMode.FUTURE.name()));
    SpaceReference spaceRef = new SpaceReference("artSpace", wikiRef);
    expect(builder.blogService.getBlogSpaceRef(eq(docRef))).andReturn(spaceRef).once();
    expectSpaceRightsCheck(spaceRef, true, false);
    replayDefault();
    IQueryRestriction ret = builder.getBlogRestriction(param);
    verifyDefault();
    assertNull(ret);
}
Also used : IQueryRestriction(com.celements.search.lucene.query.IQueryRestriction) SpaceReference(org.xwiki.model.reference.SpaceReference) Test(org.junit.Test)

Example 72 with SpaceReference

use of org.xwiki.model.reference.SpaceReference 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());
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) DocumentReference(org.xwiki.model.reference.DocumentReference) QueryRestrictionGroup(com.celements.search.lucene.query.QueryRestrictionGroup) Test(org.junit.Test)

Example 73 with SpaceReference

use of org.xwiki.model.reference.SpaceReference in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetBlogRestriction_noView.

@Test
public void testGetBlogRestriction_noView() throws Exception {
    ArticleLoadParameter param = new ArticleLoadParameter();
    param.setBlogDocRef(docRef);
    SpaceReference spaceRef = new SpaceReference("artSpace", wikiRef);
    expect(builder.blogService.getBlogSpaceRef(eq(docRef))).andReturn(spaceRef).once();
    expectSpaceRightsCheck(spaceRef, false, null);
    replayDefault();
    IQueryRestriction ret = builder.getBlogRestriction(param);
    verifyDefault();
    assertNull(ret);
}
Also used : IQueryRestriction(com.celements.search.lucene.query.IQueryRestriction) SpaceReference(org.xwiki.model.reference.SpaceReference) Test(org.junit.Test)

Example 74 with SpaceReference

use of org.xwiki.model.reference.SpaceReference 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);
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) QueryRestrictionGroup(com.celements.search.lucene.query.QueryRestrictionGroup) Test(org.junit.Test)

Example 75 with SpaceReference

use of org.xwiki.model.reference.SpaceReference in project celements-blog by celements.

the class ArticleLuceneQueryBuilderTest method testGetSubsSpaceRestriction_noSubsQuery.

@Test
public void testGetSubsSpaceRestriction_noSubsQuery() throws Exception {
    ArticleLoadParameter param = new ArticleLoadParameter();
    param.setBlogDocRef(docRef);
    param.setDateModes(Arrays.asList(DateMode.PUBLISHED.name()));
    param.setSubscriptionModes(Collections.<String>emptyList());
    SpaceReference spaceRef = new SpaceReference("artSpace", wikiRef);
    expectSpaceRightsCheck(spaceRef, null, true);
    replayDefault();
    QueryRestrictionGroup ret = builder.getSubsSpaceRestriction(param, spaceRef);
    verifyDefault();
    assertNull(ret);
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) QueryRestrictionGroup(com.celements.search.lucene.query.QueryRestrictionGroup) Test(org.junit.Test)

Aggregations

SpaceReference (org.xwiki.model.reference.SpaceReference)142 DocumentReference (org.xwiki.model.reference.DocumentReference)96 Test (org.junit.Test)83 WikiReference (org.xwiki.model.reference.WikiReference)58 EntityReference (org.xwiki.model.reference.EntityReference)24 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)21 ArrayList (java.util.ArrayList)11 ResourceReference (org.xwiki.rendering.listener.reference.ResourceReference)11 XWikiException (com.xpn.xwiki.XWikiException)9 QueryRestrictionGroup (com.celements.search.lucene.query.QueryRestrictionGroup)8 Expectations (org.jmock.Expectations)8 XWikiContext (com.xpn.xwiki.XWikiContext)7 DocumentAccessBridge (org.xwiki.bridge.DocumentAccessBridge)7 DefaultComponentDescriptor (org.xwiki.component.descriptor.DefaultComponentDescriptor)7 ComponentManager (org.xwiki.component.manager.ComponentManager)7 NamespacedComponentManager (org.xwiki.component.manager.NamespacedComponentManager)7 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)7 EntityReferenceResolver (org.xwiki.model.reference.EntityReferenceResolver)7 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)7 DocumentResourceReference (org.xwiki.rendering.listener.reference.DocumentResourceReference)7