ContentType { public static ContentType of(String value) { Preconditions.checkArgument(!Strings.isNullOrEmpty(value), "'content type' is mandatory"); return new ContentType(value); } ContentType(String value); static ContentType of(String value); static ContentType of(MimeType mimeType); static ContentType of(MimeType mimeType, Optional<Charset> charset); ContentTypeField asMime4J(); MimeType mimeType(); MediaType mediaType(); SubType subType(); Optional<Charset> charset(); String asString(); @Override final boolean equals(Object o); @Override final int hashCode();  }
@Test void mimeTypeOfShouldThrowWhenInvalid() { assertThatThrownBy(() -> ContentType.MimeType.of("aaa")) .isInstanceOf(IllegalArgumentException.class); }
@Test void mimeTypeOfShouldThrowWhenEmpty() { assertThatThrownBy(() -> ContentType.of("")) .isInstanceOf(IllegalArgumentException.class); }
@Test void mimeTypeOfShouldThrowWhenNull() { assertThatThrownBy(() -> ContentType.of((String) null)) .isInstanceOf(IllegalArgumentException.class); }
@Test void mimeTypeOfShouldReturnExpectedValue() { assertThat(ContentType.MimeType.of("text/html")) .isEqualTo(ContentType.MimeType.of( ContentType.MediaType.of("text"), ContentType.SubType.of("html"))); }
@Test void mediaTypeOfShouldThrowWhenEmpty() { assertThatThrownBy(() -> ContentType.MediaType.of("")) .isInstanceOf(IllegalStateException.class); }
@Test void subTypeOfShouldThrowWhenEmpty() { assertThatThrownBy(() -> ContentType.SubType.of("")) .isInstanceOf(IllegalStateException.class); }
@Test void asMime4JShouldNotThrowWhenInvalidContentType() { ContentType invalid = ContentType.of("/invalid"); assertThatCode(invalid::asMime4J) .doesNotThrowAnyException(); }
@Test void mimeTypeShouldThrowWhenInvalidContentType() { ContentType invalid = ContentType.of("invalid"); assertThatThrownBy(invalid::mimeType) .isInstanceOf(IllegalStateException.class); }
@Test void mediaTypeShouldThrowWhenInvalidContentType() { ContentType invalid = ContentType.of("invalid"); assertThatThrownBy(invalid::mediaType) .isInstanceOf(IllegalStateException.class); }
@Test void subTypeShouldThrowWhenInvalidContentType() { ContentType invalid = ContentType.of("invalid"); assertThatThrownBy(invalid::subType) .isInstanceOf(IllegalStateException.class); }
@Test void charsetShouldThrowWhenInvalidCharset() { ContentType invalid = ContentType.of("text/plain; charset=invalid"); assertThatThrownBy(invalid::charset) .isInstanceOf(IllegalArgumentException.class); }