@Test public void assertAttachmentsExistShouldThrowWhenUnknownBlobId() throws MailboxException { BlobId unknownBlobId = BlobId.of("unknownBlobId"); AttachmentId unknownAttachmentId = AttachmentId.from(unknownBlobId.getRawValue()); when(attachmentManager.exists(unknownAttachmentId, session)).thenReturn(false); assertThatThrownBy(() -> sut.assertAttachmentsExist( new ValueWithId.CreationMessageEntry( creationMessageId, creationMessageBuilder.attachments( Attachment.builder().size(12L).type("image/jpeg").blobId(unknownBlobId).build()) .build() ), session)) .isInstanceOf(AttachmentsNotFoundException.class); }
public void assertAttachmentsExist(ValueWithId.CreationMessageEntry entry, MailboxSession session) throws AttachmentsNotFoundException, MailboxException { List<Attachment> attachments = entry.getValue().getAttachments(); List<BlobId> notFounds = listAttachmentsNotFound(attachments, session); if (!notFounds.isEmpty()) { throw new AttachmentsNotFoundException(notFounds); } }
AttachmentChecker { public void assertAttachmentsExist(ValueWithId.CreationMessageEntry entry, MailboxSession session) throws AttachmentsNotFoundException, MailboxException { List<Attachment> attachments = entry.getValue().getAttachments(); List<BlobId> notFounds = listAttachmentsNotFound(attachments, session); if (!notFounds.isEmpty()) { throw new AttachmentsNotFoundException(notFounds); } } }
AttachmentChecker { public void assertAttachmentsExist(ValueWithId.CreationMessageEntry entry, MailboxSession session) throws AttachmentsNotFoundException, MailboxException { List<Attachment> attachments = entry.getValue().getAttachments(); List<BlobId> notFounds = listAttachmentsNotFound(attachments, session); if (!notFounds.isEmpty()) { throw new AttachmentsNotFoundException(notFounds); } } @Inject  AttachmentChecker(AttachmentManager attachmentManager); }
AttachmentChecker { public void assertAttachmentsExist(ValueWithId.CreationMessageEntry entry, MailboxSession session) throws AttachmentsNotFoundException, MailboxException { List<Attachment> attachments = entry.getValue().getAttachments(); List<BlobId> notFounds = listAttachmentsNotFound(attachments, session); if (!notFounds.isEmpty()) { throw new AttachmentsNotFoundException(notFounds); } } @Inject  AttachmentChecker(AttachmentManager attachmentManager); void assertAttachmentsExist(ValueWithId.CreationMessageEntry entry, MailboxSession session); }
AttachmentChecker { public void assertAttachmentsExist(ValueWithId.CreationMessageEntry entry, MailboxSession session) throws AttachmentsNotFoundException, MailboxException { List<Attachment> attachments = entry.getValue().getAttachments(); List<BlobId> notFounds = listAttachmentsNotFound(attachments, session); if (!notFounds.isEmpty()) { throw new AttachmentsNotFoundException(notFounds); } } @Inject  AttachmentChecker(AttachmentManager attachmentManager); void assertAttachmentsExist(ValueWithId.CreationMessageEntry entry, MailboxSession session);  }