use of org.xwiki.officeimporter.builder.XDOMOfficeDocumentBuilder in project xwiki-platform by xwiki.
the class OfficeAttachmentImporterTest method toHTML.
@Test
public void toHTML() throws Exception {
when(this.authorization.hasAccess(Right.EDIT, attachmentReference)).thenReturn(true);
when(this.documentAccessBridge.getAttachmentVersion(attachmentReference)).thenReturn("1.3");
when(this.officeServer.getState()).thenReturn(ServerState.CONNECTED);
InputStream attachmentContent = mock(InputStream.class);
when(this.documentAccessBridge.getAttachmentContent(attachmentReference)).thenReturn(attachmentContent);
XDOMOfficeDocumentBuilder documentBuilder = this.mocker.getInstance(XDOMOfficeDocumentBuilder.class);
XDOMOfficeDocument xdomOfficeDocument = mock(XDOMOfficeDocument.class);
when(documentBuilder.build(attachmentContent, "my.doc", attachmentReference.getDocumentReference(), true)).thenReturn(xdomOfficeDocument);
when(xdomOfficeDocument.getArtifacts()).thenReturn(Collections.emptyMap());
when(xdomOfficeDocument.getContentAsString("annotatedxhtml/1.0")).thenReturn("test");
Map<String, Object> parameters = Collections.singletonMap("filterStyles", "true");
assertEquals("test", this.mocker.getComponentUnderTest().toHTML(attachmentReference, parameters));
}
Aggregations