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