Search in sources :

Example 81 with SpaceReference

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

the class BlogServiceTest method testGetBlogConfigDocRef.

@Test
public void testGetBlogConfigDocRef() throws Exception {
    DocumentReference docRef = new DocumentReference(wikiRef.getName(), "space", "blog");
    SpaceReference spaceRef = new SpaceReference("blogSpace", wikiRef);
    expect(blogCacheMock.getCachedDocRefs(eq(spaceRef))).andReturn(ImmutableSet.of(docRef)).once();
    replayDefault();
    DocumentReference ret = blogService.getBlogConfigDocRef(spaceRef);
    verifyDefault();
    assertEquals(docRef, ret);
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 82 with SpaceReference

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

the class BlogServiceTest method testGetBlogSpaceRef_noBObj.

@Test
public void testGetBlogSpaceRef_noBObj() throws Exception {
    DocumentReference docRef = new DocumentReference(wikiRef.getName(), "space", "blog");
    XWikiDocument doc = new XWikiDocument(docRef);
    expect(xwiki.getDocument(eq(docRef), same(context))).andReturn(doc).once();
    replayDefault();
    SpaceReference ret = blogService.getBlogSpaceRef(docRef);
    verifyDefault();
    assertNull(ret);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) SpaceReference(org.xwiki.model.reference.SpaceReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 83 with SpaceReference

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

the class BlogServiceTest method testGetSubribedToBlogs.

@Test
public void testGetSubribedToBlogs() throws Exception {
    DocumentReference docRef = new DocumentReference(wikiRef.getName(), "space", "blog");
    String space1 = "space1";
    String space2 = "space2";
    String space3 = "space3";
    String space4 = "space4";
    XWikiDocument doc = getBlogDoc(docRef, BlogClasses.PROPERTY_BLOG_CONFIG_SUBSCRIBE_TO, space1 + "," + space2 + "," + space3 + "," + space4);
    DocumentReference docRef1 = new DocumentReference(wikiRef.getName(), "space", "blog1");
    XWikiDocument doc1 = getBlogDoc(docRef1, BlogClasses.PROPERTY_BLOG_CONFIG_BLOGSPACE, space1);
    doc1.getXObject(blogService.getBlogConfigClassRef(wikiRef)).setIntValue(BlogClasses.PROPERTY_BLOG_CONFIG_IS_SUBSCRIBABLE, 1);
    DocumentReference docRef2 = new DocumentReference(wikiRef.getName(), "space", "blog2");
    XWikiDocument doc2 = getBlogDoc(docRef2, BlogClasses.PROPERTY_BLOG_CONFIG_BLOGSPACE, space2);
    doc2.getXObject(blogService.getBlogConfigClassRef(wikiRef)).setIntValue(BlogClasses.PROPERTY_BLOG_CONFIG_IS_SUBSCRIBABLE, 0);
    DocumentReference docRef3 = new DocumentReference(wikiRef.getName(), "space", "blog3");
    XWikiDocument doc3 = getBlogDoc(docRef3, BlogClasses.PROPERTY_BLOG_CONFIG_BLOGSPACE, space3);
    doc3.getXObject(blogService.getBlogConfigClassRef(wikiRef)).setIntValue(BlogClasses.PROPERTY_BLOG_CONFIG_IS_SUBSCRIBABLE, 1);
    expect(blogCacheMock.getCachedDocRefs(eq(new SpaceReference(space1, wikiRef)))).andReturn(ImmutableSet.of(docRef1)).once();
    expect(blogCacheMock.getCachedDocRefs(eq(new SpaceReference(space2, wikiRef)))).andReturn(ImmutableSet.of(docRef2)).once();
    expect(blogCacheMock.getCachedDocRefs(eq(new SpaceReference(space3, wikiRef)))).andReturn(ImmutableSet.of(docRef3)).once();
    expect(blogCacheMock.getCachedDocRefs(eq(new SpaceReference(space4, wikiRef)))).andReturn(ImmutableSet.<DocumentReference>of()).once();
    expect(xwiki.getDocument(eq(docRef), same(context))).andReturn(doc).once();
    expect(xwiki.getDocument(eq(docRef1), same(context))).andReturn(doc1).once();
    expect(xwiki.getDocument(eq(docRef2), same(context))).andReturn(doc2).once();
    expect(xwiki.getDocument(eq(docRef3), same(context))).andReturn(doc3).once();
    replayDefault();
    List<DocumentReference> ret = blogService.getSubribedToBlogs(docRef);
    verifyDefault();
    assertEquals(Arrays.asList(docRef1, docRef3), ret);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) SpaceReference(org.xwiki.model.reference.SpaceReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 84 with SpaceReference

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

the class BlogServiceTest method testGetSubribedToBlogsSpaceRefs.

@Test
public void testGetSubribedToBlogsSpaceRefs() throws Exception {
    DocumentReference docRef = new DocumentReference(wikiRef.getName(), "space", "blog");
    String space1 = "space1";
    String space2 = "space2";
    String space3 = "space3";
    String space4 = "space4";
    XWikiDocument doc = getBlogDoc(docRef, BlogClasses.PROPERTY_BLOG_CONFIG_SUBSCRIBE_TO, space1 + "," + space2 + "," + space3 + "," + space4);
    DocumentReference docRef1 = new DocumentReference(wikiRef.getName(), "space", "blog1");
    XWikiDocument doc1 = getBlogDoc(docRef1, BlogClasses.PROPERTY_BLOG_CONFIG_BLOGSPACE, space1);
    doc1.getXObject(blogService.getBlogConfigClassRef(wikiRef)).setIntValue(BlogClasses.PROPERTY_BLOG_CONFIG_IS_SUBSCRIBABLE, 1);
    DocumentReference docRef2 = new DocumentReference(wikiRef.getName(), "space", "blog2");
    XWikiDocument doc2 = getBlogDoc(docRef2, BlogClasses.PROPERTY_BLOG_CONFIG_BLOGSPACE, space2);
    doc2.getXObject(blogService.getBlogConfigClassRef(wikiRef)).setIntValue(BlogClasses.PROPERTY_BLOG_CONFIG_IS_SUBSCRIBABLE, 0);
    DocumentReference docRef3 = new DocumentReference(wikiRef.getName(), "space", "blog3");
    XWikiDocument doc3 = getBlogDoc(docRef3, BlogClasses.PROPERTY_BLOG_CONFIG_BLOGSPACE, space3);
    doc3.getXObject(blogService.getBlogConfigClassRef(wikiRef)).setIntValue(BlogClasses.PROPERTY_BLOG_CONFIG_IS_SUBSCRIBABLE, 1);
    expect(blogCacheMock.getCachedDocRefs(eq(new SpaceReference(space1, wikiRef)))).andReturn(ImmutableSet.of(docRef1)).once();
    expect(blogCacheMock.getCachedDocRefs(eq(new SpaceReference(space2, wikiRef)))).andReturn(ImmutableSet.of(docRef2)).once();
    expect(blogCacheMock.getCachedDocRefs(eq(new SpaceReference(space3, wikiRef)))).andReturn(ImmutableSet.of(docRef3)).once();
    expect(blogCacheMock.getCachedDocRefs(eq(new SpaceReference(space4, wikiRef)))).andReturn(ImmutableSet.<DocumentReference>of()).once();
    expect(xwiki.getDocument(eq(docRef), same(context))).andReturn(doc).once();
    expect(xwiki.getDocument(eq(docRef1), same(context))).andReturn(doc1).times(2);
    expect(xwiki.getDocument(eq(docRef2), same(context))).andReturn(doc2).once();
    expect(xwiki.getDocument(eq(docRef3), same(context))).andReturn(doc3).times(2);
    replayDefault();
    List<SpaceReference> ret = blogService.getSubribedToBlogsSpaceRefs(docRef);
    verifyDefault();
    assertEquals(Arrays.asList(new SpaceReference(space1, wikiRef), new SpaceReference(space3, wikiRef)), ret);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) SpaceReference(org.xwiki.model.reference.SpaceReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 85 with SpaceReference

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

the class DeprecatedLocalReferenceEntityReferenceSerializerTest method testSerializeSpaceReferenceWithChild.

@Test
public void testSerializeSpaceReferenceWithChild() {
    EntityReference reference = this.serializer.serialize(new SpaceReference("space", new WikiReference("wiki")));
    Assert.assertEquals(EntityType.SPACE, reference.getType());
    Assert.assertEquals("space", reference.getName());
    Assert.assertNull(reference.getParent());
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) EntityReference(org.xwiki.model.reference.EntityReference) 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