Search in sources :

Example 1 with XDOMOfficeDocumentBuilder

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));
}
Also used : InputStream(java.io.InputStream) XDOMOfficeDocumentBuilder(org.xwiki.officeimporter.builder.XDOMOfficeDocumentBuilder) XDOMOfficeDocument(org.xwiki.officeimporter.document.XDOMOfficeDocument) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)1 Test (org.junit.Test)1 XDOMOfficeDocumentBuilder (org.xwiki.officeimporter.builder.XDOMOfficeDocumentBuilder)1 XDOMOfficeDocument (org.xwiki.officeimporter.document.XDOMOfficeDocument)1