@Test public void fromShouldRemoveTagsWhenExists() { Cid cid = Cid.from("<123>"); assertThat(cid.getValue()).isEqualTo("123"); }
@Test public void fromShouldNotRemoveTagsWhenNone() { Cid cid = Cid.from("123"); assertThat(cid.getValue()).isEqualTo("123"); }
@Test public void fromShouldNotRemoveTagsWhenNotEndTag() { Cid cid = Cid.from("<123"); assertThat(cid.getValue()).isEqualTo("<123"); }
@Test public void fromShouldNotRemoveTagsWhenNotStartTag() { Cid cid = Cid.from("123>"); assertThat(cid.getValue()).isEqualTo("123>"); }
@Test public void fromShouldThrowWhenEmptyAfterRemoveTags() { expectedException.expect(IllegalArgumentException.class); Cid.from("<>"); }
@Test public void fromShouldThrowWhenNull() { expectedException.expect(IllegalArgumentException.class); Cid.from(null); }
@Test public void fromShouldThrowWhenEmpty() { expectedException.expect(IllegalArgumentException.class); Cid.from(""); }
@Test public void fromShouldThrowWhenBlank() { expectedException.expect(IllegalArgumentException.class); Cid.from(" "); }
@Test public void fromShouldThrowWhenBlankAfterRemoveTags() { expectedException.expect(IllegalArgumentException.class); Cid.from("< >"); }
@Test public void buildShouldSetAttributesWhenAllAreGiven() { AttachmentId attachmentId = AttachmentId.from("1"); MessageAttachmentRepresentation expectedMessageAttachmentRepresentation = new MessageAttachmentRepresentation(attachmentId, Optional.of("name"), Optional.of(Cid.from("cid")), true); MessageAttachmentRepresentation messageAttachmentRepresentation = MessageAttachmentRepresentation.builder() .attachmentId(attachmentId) .name("name") .cid(Cid.from("cid")) .isInline(true) .build(); assertThat(messageAttachmentRepresentation).isEqualTo(expectedMessageAttachmentRepresentation); } }
@Test public void fromRelaxedNoUnwrapShouldNotRemoveTagsWhenNone() { assertThat(Cid.parser() .relaxed() .parse("123")) .contains(Cid.from("123")); }
@Test public void fromStrictNoUnwrapShouldNotRemoveTagsWhenNotEndTag() { assertThat(Cid.parser() .strict() .parse("<123")) .contains(Cid.from("<123")); }
@Test public void fromRelaxedNoUnwrapShouldNotRemoveTagsWhenNotStartTag() { assertThat(Cid.parser() .relaxed() .parse("123>")) .contains(Cid.from("123>")); }
@Test public void fromStrictNoUnwrapShouldNotRemoveTagsWhenNone() { assertThat(Cid.parser() .strict() .parse("123")) .contains(Cid.from("123")); }
@Test public void fromRelaxedNoUnwrapShouldNotRemoveTagsWhenNotEndTag() { assertThat(Cid.parser() .relaxed() .parse("<123")) .contains(Cid.from("<123")); }
@Test public void fromStrictNoUnwrapShouldNotRemoveTagsWhenNotStartTag() { assertThat(Cid.parser() .strict() .parse("123>")) .contains(Cid.from("123>")); }
@Test public void fromRelaxedUnwrapShouldNotRemoveTagsWhenNotEndTag() { assertThat(Cid.parser() .relaxed() .unwrap() .parse("<123")) .contains(Cid.from("<123")); }
@Test public void fromRelaxedUnwrapShouldNotRemoveTagsWhenNotStartTag() { assertThat(Cid.parser() .relaxed() .unwrap() .parse("123>")) .contains(Cid.from("123>")); }
@Test public void fromRelaxedUnwrapShouldNotRemoveTagsWhenNone() { assertThat(Cid.parser() .relaxed() .unwrap() .parse("123")) .contains(Cid.from("123")); }
@Test public void isInlinedWithCidShouldReturnFalseWhenIsNotInline() throws Exception { Attachment attachment = Attachment.builder() .bytes("content".getBytes()) .type("type") .build(); MessageAttachment messageAttachment = MessageAttachment.builder() .attachment(attachment) .name("name") .cid(Cid.from("cid")) .isInline(false) .build(); assertThat(messageAttachment.isInlinedWithCid()).isFalse(); }