@Test void retrieveShouldThrowOnMailboxExceptionWhenRetrievingMessageContent() throws Exception { when(attachmentManager.getAttachment(any(), any())) .thenThrow(new AttachmentNotFoundException(ID)); MessageResult messageResult = mock(MessageResult.class); when(messageResult.getFullContent()).thenThrow(new MailboxException()); when(messageIdManager.getMessage(MESSAGE_ID, FetchGroup.FULL_CONTENT, session)) .thenReturn(ImmutableList.of(messageResult)); assertThatThrownBy(() -> blobManager.retrieve(BLOB_ID_MESSAGE, session)) .isInstanceOf(RuntimeException.class); }
@Override public Blob retrieve(BlobId blobId, MailboxSession mailboxSession) throws MailboxException, BlobNotFoundException { return getBlobFromAttachment(blobId, mailboxSession) .orElseGet(() -> getBlobFromMessage(blobId, mailboxSession) .orElseThrow(() -> new BlobNotFoundException(blobId))); }
StoreBlobManager implements BlobManager { @Override public Blob retrieve(BlobId blobId, MailboxSession mailboxSession) throws MailboxException, BlobNotFoundException { return getBlobFromAttachment(blobId, mailboxSession) .orElseGet(() -> getBlobFromMessage(blobId, mailboxSession) .orElseThrow(() -> new BlobNotFoundException(blobId))); } }
StoreBlobManager implements BlobManager { @Override public Blob retrieve(BlobId blobId, MailboxSession mailboxSession) throws MailboxException, BlobNotFoundException { return getBlobFromAttachment(blobId, mailboxSession) .orElseGet(() -> getBlobFromMessage(blobId, mailboxSession) .orElseThrow(() -> new BlobNotFoundException(blobId))); } @Inject  StoreBlobManager(AttachmentManager attachmentManager, MessageIdManager messageIdManager,
                            MessageId.Factory messageIdFactory); }
StoreBlobManager implements BlobManager { @Override public Blob retrieve(BlobId blobId, MailboxSession mailboxSession) throws MailboxException, BlobNotFoundException { return getBlobFromAttachment(blobId, mailboxSession) .orElseGet(() -> getBlobFromMessage(blobId, mailboxSession) .orElseThrow(() -> new BlobNotFoundException(blobId))); } @Inject  StoreBlobManager(AttachmentManager attachmentManager, MessageIdManager messageIdManager,
                            MessageId.Factory messageIdFactory); @Override BlobId toBlobId(MessageId messageId); @Override Blob retrieve(BlobId blobId, MailboxSession mailboxSession); }
StoreBlobManager implements BlobManager { @Override public Blob retrieve(BlobId blobId, MailboxSession mailboxSession) throws MailboxException, BlobNotFoundException { return getBlobFromAttachment(blobId, mailboxSession) .orElseGet(() -> getBlobFromMessage(blobId, mailboxSession) .orElseThrow(() -> new BlobNotFoundException(blobId))); } @Inject  StoreBlobManager(AttachmentManager attachmentManager, MessageIdManager messageIdManager,
                            MessageId.Factory messageIdFactory); @Override BlobId toBlobId(MessageId messageId); @Override Blob retrieve(BlobId blobId, MailboxSession mailboxSession); static final ContentType MESSAGE_RFC822_CONTENT_TYPE; }