use of org.xwiki.model.reference.WikiReference 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();
}
use of org.xwiki.model.reference.WikiReference 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();
}
use of org.xwiki.model.reference.WikiReference 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();
}
use of org.xwiki.model.reference.WikiReference in project celements-blog by celements.
the class BlogCacheTest method testGetCachedDocRefs_nullKey.
@Test
public void testGetCachedDocRefs_nullKey() throws Exception {
WikiReference wikiRef = new WikiReference("wiki");
DocumentReference docRef = new DocumentReference(wikiRef.getName(), "space", "blog");
expectXWQL(wikiRef, Arrays.asList(docRef));
expect(cache.blogService.getBlogSpaceRef(eq(docRef))).andReturn(null).once();
replayDefault();
assertEquals(ImmutableSet.of(), cache.getCachedDocRefs(wikiRef));
verifyDefault();
}
use of org.xwiki.model.reference.WikiReference in project celements-blog by celements.
the class BlogUpdateListenerTest method testGetRequiredObjClassRef.
@Test
public void testGetRequiredObjClassRef() {
String wikiName = "myWiki";
DocumentReference classRef = new DocumentReference(wikiName, BlogClasses.BLOG_CONFIG_CLASS_SPACE, BlogClasses.BLOG_CONFIG_CLASS_DOC);
assertEquals(classRef, listener.getRequiredObjClassRef(new WikiReference(wikiName)));
}
Aggregations