use of org.xwiki.office.viewer.OfficeViewer in project xwiki-platform by xwiki.
the class DefaultOfficeViewerScriptServiceTest method view.
@Test
public void view() throws Exception {
Execution execution = mocker.getInstance(Execution.class);
when(execution.getContext()).thenReturn(new ExecutionContext());
AttachmentReference attachmentReference = new AttachmentReference("file.odt", new DocumentReference("wiki", "Space", "Page"));
DocumentModelBridge document = mock(DocumentModelBridge.class);
DocumentAccessBridge documentAccessBridge = mocker.getInstance(DocumentAccessBridge.class);
when(documentAccessBridge.isDocumentViewable(attachmentReference.getDocumentReference())).thenReturn(true);
when(documentAccessBridge.getTranslatedDocumentInstance(attachmentReference.getDocumentReference())).thenReturn(document);
when(document.getSyntax()).thenReturn(Syntax.TEX_1_0);
XDOM xdom = new XDOM(Collections.<Block>emptyList());
OfficeViewer viewer = mocker.getInstance(OfficeViewer.class);
when(viewer.createView(attachmentReference, Collections.<String, String>emptyMap())).thenReturn(xdom);
BlockRenderer xhtmlRenderer = mocker.registerMockComponent(BlockRenderer.class, "xhtml/1.0");
Assert.assertEquals("", mocker.getComponentUnderTest().view(attachmentReference));
TransformationManager transformationManager = mocker.getInstance(TransformationManager.class);
verify(transformationManager).performTransformations(eq(xdom), notNull(TransformationContext.class));
verify(xhtmlRenderer).render(eq(xdom), notNull(WikiPrinter.class));
}
Aggregations