@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)); }
@Override public String toHTML(AttachmentReference attachmentReference, Map<String, Object> parameters) throws Exception { boolean filterStyles = Boolean.valueOf(String.valueOf(parameters.get("filterStyles"))); if (Boolean.valueOf(String.valueOf(parameters.get("useOfficeViewer")))) { return this.officeMacroImporter .render(this.officeMacroImporter.buildXDOM(attachmentReference, filterStyles)); } else { return maybeConvertAttachmentContent(attachmentReference, filterStyles); } }
OfficeAttachmentImporter implements AttachmentImporter { @Override public String toHTML(AttachmentReference attachmentReference, Map<String, Object> parameters) throws Exception { boolean filterStyles = Boolean.valueOf(String.valueOf(parameters.get("filterStyles"))); if (Boolean.valueOf(String.valueOf(parameters.get("useOfficeViewer")))) { return this.officeMacroImporter .render(this.officeMacroImporter.buildXDOM(attachmentReference, filterStyles)); } else { return maybeConvertAttachmentContent(attachmentReference, filterStyles); } } }
OfficeAttachmentImporter implements AttachmentImporter { @Override public String toHTML(AttachmentReference attachmentReference, Map<String, Object> parameters) throws Exception { boolean filterStyles = Boolean.valueOf(String.valueOf(parameters.get("filterStyles"))); if (Boolean.valueOf(String.valueOf(parameters.get("useOfficeViewer")))) { return this.officeMacroImporter .render(this.officeMacroImporter.buildXDOM(attachmentReference, filterStyles)); } else { return maybeConvertAttachmentContent(attachmentReference, filterStyles); } }  }
OfficeAttachmentImporter implements AttachmentImporter { @Override public String toHTML(AttachmentReference attachmentReference, Map<String, Object> parameters) throws Exception { boolean filterStyles = Boolean.valueOf(String.valueOf(parameters.get("filterStyles"))); if (Boolean.valueOf(String.valueOf(parameters.get("useOfficeViewer")))) { return this.officeMacroImporter .render(this.officeMacroImporter.buildXDOM(attachmentReference, filterStyles)); } else { return maybeConvertAttachmentContent(attachmentReference, filterStyles); } }  @Override String toHTML(AttachmentReference attachmentReference, Map<String, Object> parameters); }
OfficeAttachmentImporter implements AttachmentImporter { @Override public String toHTML(AttachmentReference attachmentReference, Map<String, Object> parameters) throws Exception { boolean filterStyles = Boolean.valueOf(String.valueOf(parameters.get("filterStyles"))); if (Boolean.valueOf(String.valueOf(parameters.get("useOfficeViewer")))) { return this.officeMacroImporter .render(this.officeMacroImporter.buildXDOM(attachmentReference, filterStyles)); } else { return maybeConvertAttachmentContent(attachmentReference, filterStyles); } }  @Override String toHTML(AttachmentReference attachmentReference, Map<String, Object> parameters);  }