use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class WikiTemplateManagerScriptTest method setUp.
@Before
public void setUp() throws Exception {
wikiTemplateManager = mocker.getInstance(WikiTemplateManager.class);
wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
authorizationManager = mocker.getInstance(AuthorizationManager.class);
entityReferenceSerializer = mocker.getInstance(new DefaultParameterizedType(null, EntityReferenceSerializer.class, String.class));
xcontextProvider = mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
xcontext = mock(XWikiContext.class);
when(xcontextProvider.get()).thenReturn(xcontext);
execution = mocker.getInstance(Execution.class);
executionContext = new ExecutionContext();
when(execution.getContext()).thenReturn(executionContext);
currentUserRef = new DocumentReference("mainWiki", "XWiki", "User");
when(xcontext.getUserReference()).thenReturn(currentUserRef);
currentDoc = mock(XWikiDocument.class);
when(xcontext.getDoc()).thenReturn(currentDoc);
when(xcontext.getMainXWiki()).thenReturn("mainWiki");
when(entityReferenceSerializer.serialize(currentUserRef)).thenReturn("mainWiki:XWiki.User");
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class XWikiLinkLabelGeneratorTest method generateWhenNestedPage.
@Test
public void generateWhenNestedPage() throws Exception {
ResourceReference resourceReference = new DocumentResourceReference("WebHome");
DocumentReference documentReference = new DocumentReference("wiki", Arrays.asList("space1", "NestedPage"), "WebHome");
EntityReferenceResolver<ResourceReference> resourceReferenceResolver = this.mocker.getInstance(new DefaultParameterizedType(null, EntityReferenceResolver.class, ResourceReference.class));
when(resourceReferenceResolver.resolve(resourceReference, EntityType.DOCUMENT)).thenReturn(documentReference);
DocumentAccessBridge dab = this.mocker.getInstance(DocumentAccessBridge.class);
DocumentModelBridge dmb = mock(DocumentModelBridge.class);
when(dab.getTranslatedDocumentInstance(documentReference)).thenReturn(dmb);
when(dmb.getTitle()).thenReturn("My title");
EntityReferenceSerializer<String> localSerializer = this.mocker.getInstance(EntityReferenceSerializer.TYPE_STRING, "local");
when(localSerializer.serialize(new SpaceReference("wiki", "space1", "NestedPage"))).thenReturn("space1.NestedPage");
assertEquals("%l%la%n%na%N%NA " + "[wiki:space1.NestedPage.WebHome] NestedPage NestedPage Web Home Nested Page (My title) " + "[wiki:space1.NestedPage.WebHome] NestedPage NestedPage Web Home Nested Page (My title)", this.mocker.getComponentUnderTest().generate(resourceReference));
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class XWikiLinkLabelGeneratorTest method generateWhenDocumentFailsToLoad.
@Test
public void generateWhenDocumentFailsToLoad() throws Exception {
ResourceReference resourceReference = new DocumentResourceReference("HelloWorld");
DocumentReference documentReference = new DocumentReference("xwiki", "Main", "HelloWorld");
EntityReferenceResolver<ResourceReference> resourceReferenceResolver = this.mocker.getInstance(new DefaultParameterizedType(null, EntityReferenceResolver.class, ResourceReference.class));
when(resourceReferenceResolver.resolve(resourceReference, EntityType.DOCUMENT)).thenReturn(documentReference);
DocumentAccessBridge dab = this.mocker.getInstance(DocumentAccessBridge.class);
when(dab.getTranslatedDocumentInstance(documentReference)).thenThrow(new Exception("error"));
EntityReferenceSerializer<String> localSerializer = this.mocker.getInstance(EntityReferenceSerializer.TYPE_STRING, "local");
when(localSerializer.serialize(new SpaceReference("xwiki", "Main"))).thenReturn("Main");
assertEquals("%l%la%n%na%N%NA " + "[xwiki:Main.HelloWorld] Main HelloWorld Hello World Hello World (HelloWorld) " + "[xwiki:Main.HelloWorld] Main HelloWorld Hello World Hello World (HelloWorld)", this.mocker.getComponentUnderTest().generate(resourceReference));
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class VfsResourceReferenceSerializerTest method setUp.
@Before
public void setUp() throws Exception {
Provider<ComponentManager> componentManagerProvider = this.mocker.registerMockComponent(new DefaultParameterizedType(null, Provider.class, ComponentManager.class), "context");
when(componentManagerProvider.get()).thenReturn(this.mocker);
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class VfsResourceReferenceSerializerTest method serializeWhenSpecificSchemeSerializer.
@Test
public void serializeWhenSpecificSchemeSerializer() throws Exception {
VfsResourceReference reference = new VfsResourceReference(URI.create("attach:attachment"), "path1/path2/test.txt");
ExtendedURL extendedURL = new ExtendedURL(Arrays.asList("vfs", "attach:wiki:space.page@attachment", "path1", "path2", "test.txt"));
ResourceReferenceSerializer<VfsResourceReference, ExtendedURL> serializer = this.mocker.registerMockComponent(new DefaultParameterizedType(null, ResourceReferenceSerializer.class, VfsResourceReference.class, ExtendedURL.class), "attach");
when(serializer.serialize(reference)).thenReturn(extendedURL);
assertEquals("/vfs/attach%3Awiki%3Aspace.page%40attachment/path1/path2/test.txt", this.mocker.getComponentUnderTest().serialize(reference).toString());
}
Aggregations