MessageAttachmentMetadata { public static Builder builder() { return new Builder(); } MessageAttachmentMetadata(AttachmentMetadata attachment, Optional<String> name, Optional<Cid> cid, boolean isInline); static Builder builder(); static boolean hasNonInlinedAttachment(List<MessageAttachmentMetadata> attachments); AttachmentMetadata getAttachment(); AttachmentId getAttachmentId(); Optional<String> getName(); Optional<Cid> getCid(); boolean isInline(); boolean isInlinedWithCid(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }
@Test void buildShouldThrowWhenAttachmentIsNotGiven() { assertThatThrownBy(() -> MessageAttachmentMetadata.builder() .build()) .isInstanceOf(IllegalStateException.class); }
@Test void builderShouldThrowWhenAttachmentIsNull() { assertThatThrownBy(() -> MessageAttachmentMetadata.builder() .attachment(null)) .isInstanceOf(IllegalArgumentException.class); }
@Test void buildShouldWorkWhenMandatoryAttributesAreGiven() { AttachmentMetadata attachment = AttachmentMetadata.builder() .attachmentId(AttachmentId.from("1")) .size(36) .type("type") .build(); MessageAttachmentMetadata expectedMessageAttachment = new MessageAttachmentMetadata(attachment, Optional.empty(), Optional.empty(), false); MessageAttachmentMetadata messageAttachment = MessageAttachmentMetadata.builder() .attachment(attachment) .build(); assertThat(messageAttachment).isEqualTo(expectedMessageAttachment); }