@Test public void testViewNonExistingOfficeAttachment() throws Exception { when(attachmentCache.get(CACHE_KEY)).thenReturn(null); when(documentAccessBridge.getAttachmentReferences(ATTACHMENT_REFERENCE.getDocumentReference())).thenReturn( Collections.<AttachmentReference>emptyList()); try { mocker.getComponentUnderTest().createView(ATTACHMENT_RESOURCE_REFERENCE, DEFAULT_VIEW_PARAMETERS); Assert.fail("Expected exception."); } catch (Exception e) { Assert.assertEquals(String.format("Attachment [%s] does not exist.", ATTACHMENT_REFERENCE), e.getMessage()); } }
@Override public XDOM createView(ResourceReference reference, Map<String, ?> parameters) throws Exception { OfficeDocumentView view; if (reference.getType().equals(ResourceType.ATTACHMENT) || reference.getType().equals(ResourceType.UNKNOWN)) { AttachmentReference attachmentReference = this.attachmentResolver.resolve(reference.getReference()); view = getView(reference, attachmentReference, parameters); } else { view = getView(reference, parameters); } return view.getXDOM().clone(); }
DefaultOfficeResourceViewer implements OfficeResourceViewer, Initializable { @Override public XDOM createView(ResourceReference reference, Map<String, ?> parameters) throws Exception { OfficeDocumentView view; if (reference.getType().equals(ResourceType.ATTACHMENT) || reference.getType().equals(ResourceType.UNKNOWN)) { AttachmentReference attachmentReference = this.attachmentResolver.resolve(reference.getReference()); view = getView(reference, attachmentReference, parameters); } else { view = getView(reference, parameters); } return view.getXDOM().clone(); } }
DefaultOfficeResourceViewer implements OfficeResourceViewer, Initializable { @Override public XDOM createView(ResourceReference reference, Map<String, ?> parameters) throws Exception { OfficeDocumentView view; if (reference.getType().equals(ResourceType.ATTACHMENT) || reference.getType().equals(ResourceType.UNKNOWN)) { AttachmentReference attachmentReference = this.attachmentResolver.resolve(reference.getReference()); view = getView(reference, attachmentReference, parameters); } else { view = getView(reference, parameters); } return view.getXDOM().clone(); }  }
DefaultOfficeResourceViewer implements OfficeResourceViewer, Initializable { @Override public XDOM createView(ResourceReference reference, Map<String, ?> parameters) throws Exception { OfficeDocumentView view; if (reference.getType().equals(ResourceType.ATTACHMENT) || reference.getType().equals(ResourceType.UNKNOWN)) { AttachmentReference attachmentReference = this.attachmentResolver.resolve(reference.getReference()); view = getView(reference, attachmentReference, parameters); } else { view = getView(reference, parameters); } return view.getXDOM().clone(); }  @Override void initialize(); @Override XDOM createView(ResourceReference reference, Map<String, ?> parameters); }
DefaultOfficeResourceViewer implements OfficeResourceViewer, Initializable { @Override public XDOM createView(ResourceReference reference, Map<String, ?> parameters) throws Exception { OfficeDocumentView view; if (reference.getType().equals(ResourceType.ATTACHMENT) || reference.getType().equals(ResourceType.UNKNOWN)) { AttachmentReference attachmentReference = this.attachmentResolver.resolve(reference.getReference()); view = getView(reference, attachmentReference, parameters); } else { view = getView(reference, parameters); } return view.getXDOM().clone(); }  @Override void initialize(); @Override XDOM createView(ResourceReference reference, Map<String, ?> parameters);  }