Search in sources :

Example 76 with SpaceReference

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

the class ArticleLuceneQueryBuilderTest method testGetBlogRestriction_withoutBlogArticles.

@Test
public void testGetBlogRestriction_withoutBlogArticles() throws Exception {
    ArticleLoadParameter param = new ArticleLoadParameter();
    param.setBlogDocRef(docRef);
    param.setWithBlogArticles(false);
    SpaceReference spaceRef = new SpaceReference("artSpace", wikiRef);
    expect(builder.blogService.getBlogSpaceRef(eq(docRef))).andReturn(spaceRef).once();
    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 77 with SpaceReference

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

the class ArticleLuceneQueryBuilderTest method testGetBlogRestriction_noEdit.

@Test
public void testGetBlogRestriction_noEdit() throws Exception {
    ArticleLoadParameter param = new ArticleLoadParameter();
    param.setBlogDocRef(docRef);
    param.setDateModes(Arrays.asList(DateMode.ARCHIVED.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();
    assertEquals("(space:(+\"" + spaceRef.getName() + "\") AND " + getArchivedQuery(param.getExecutionDate()) + ")", ret.getQueryString());
}
Also used : IQueryRestriction(com.celements.search.lucene.query.IQueryRestriction) SpaceReference(org.xwiki.model.reference.SpaceReference) Test(org.junit.Test)

Example 78 with SpaceReference

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

the class BlogCacheTest method testGetCachedDocRefs.

@Test
public void testGetCachedDocRefs() throws Exception {
    WikiReference wikiRef = new WikiReference("wiki");
    SpaceReference spaceRef1 = new SpaceReference("blogSpace1", wikiRef);
    SpaceReference spaceRef2 = new SpaceReference("blogSpace2", wikiRef);
    SpaceReference spaceRef3 = new SpaceReference("blogSpace3", wikiRef);
    DocumentReference docRef1 = new DocumentReference(wikiRef.getName(), "space", "blog1");
    DocumentReference docRef2 = new DocumentReference(wikiRef.getName(), "space", "blog2");
    expectXWQL(wikiRef, Arrays.asList(docRef1, docRef2));
    expect(cache.blogService.getBlogSpaceRef(eq(docRef1))).andReturn(spaceRef1).once();
    expect(cache.blogService.getBlogSpaceRef(eq(docRef2))).andReturn(spaceRef2).once();
    replayDefault();
    assertEquals(ImmutableSet.of(docRef1), cache.getCachedDocRefs(spaceRef1));
    assertEquals(ImmutableSet.of(docRef2), cache.getCachedDocRefs(spaceRef2));
    assertEquals(ImmutableSet.of(), cache.getCachedDocRefs(spaceRef3));
    assertEquals(ImmutableSet.of(docRef1, docRef2), cache.getCachedDocRefs(wikiRef));
    verifyDefault();
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 79 with SpaceReference

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

the class BlogCacheTest method testGetCachedDocRefs_multiWiki.

@Test
public void testGetCachedDocRefs_multiWiki() throws Exception {
    WikiReference wikiRef1 = new WikiReference("wiki1");
    SpaceReference spaceRef1 = new SpaceReference("blogSpace1", wikiRef1);
    DocumentReference docRef1 = new DocumentReference(wikiRef1.getName(), "space", "blog1");
    WikiReference wikiRef2 = new WikiReference("wiki2");
    SpaceReference spaceRef2 = new SpaceReference("blogSpace2", wikiRef2);
    DocumentReference docRef2 = new DocumentReference(wikiRef2.getName(), "space", "blog2");
    SpaceReference spaceRef3 = new SpaceReference("blogSpace3", wikiRef1);
    expectXWQL(wikiRef1, Arrays.asList(docRef1));
    expect(cache.blogService.getBlogSpaceRef(eq(docRef1))).andReturn(spaceRef1).once();
    expectXWQL(wikiRef2, Arrays.asList(docRef2));
    expect(cache.blogService.getBlogSpaceRef(eq(docRef2))).andReturn(spaceRef2).once();
    replayDefault();
    assertEquals(ImmutableSet.of(docRef1), cache.getCachedDocRefs(spaceRef1));
    assertEquals(ImmutableSet.of(docRef2), cache.getCachedDocRefs(spaceRef2));
    assertEquals(ImmutableSet.of(), cache.getCachedDocRefs(spaceRef3));
    assertEquals(ImmutableSet.of(docRef1), cache.getCachedDocRefs(wikiRef1));
    assertEquals(ImmutableSet.of(docRef2), cache.getCachedDocRefs(wikiRef2));
    verifyDefault();
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 80 with SpaceReference

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

the class BlogCacheTest method testGetCachedDocRefs_QueryException.

@Test
public void testGetCachedDocRefs_QueryException() throws Exception {
    WikiReference wikiRef = new WikiReference("wiki");
    SpaceReference spaceRef = new SpaceReference("blogSpace", wikiRef);
    expectXWQL(wikiRef, null);
    replayDefault();
    try {
        cache.getCachedDocRefs(spaceRef);
        fail("expecting CacheLoadingException");
    } catch (CacheLoadingException exc) {
    // expected
    }
    verifyDefault();
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) CacheLoadingException(com.celements.common.cache.CacheLoadingException) WikiReference(org.xwiki.model.reference.WikiReference) 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