@Test public void assertAttachmentsExistShouldNotThrowWhenKnownBlobIds() throws Exception { BlobId blobId1 = BlobId.of("unknownBlobId1"); BlobId blobId2 = BlobId.of("unknownBlobId2"); AttachmentId attachmentId1 = AttachmentId.from(blobId1.getRawValue()); AttachmentId attachmentId2 = AttachmentId.from(blobId2.getRawValue()); when(attachmentManager.exists(attachmentId1, session)).thenReturn(true); when(attachmentManager.exists(attachmentId2, session)).thenReturn(true); sut.assertAttachmentsExist( new ValueWithId.CreationMessageEntry( creationMessageId, creationMessageBuilder.attachments( Attachment.builder().size(12L).type("image/jpeg").blobId(blobId1).build(), Attachment.builder().size(23L).type("image/git").blobId(blobId2).build()) .build() ), session); }
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);  }