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);
}
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);
}
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);
}
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);
}
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());
}
Aggregations