### Question:
MediaTypes { public static MediaType of(String type, String subtype) { requireNonNull(type,TYPE_CANNOT_BE_NULL); requireNonNull(subtype,"Subtype cannot be null"); return fromString(type+"/"+subtype); } private  MediaTypes(); static MediaRangeSyntax preferredSyntax(); static void preferredSyntax(MediaRangeSyntax syntax); static MediaType wildcard(); static MediaType wildcard(String type); static MediaType wildcard(String type, String suffix); static MediaType fromString(final String mediaType); static MediaType of(String type, String subtype); static MediaType of(String type, String subtype, String suffix); static MediaTypeBuilder from(MediaType mediaType); static boolean isWildcardType(final MediaType mediaType); static boolean isWildcardSubType(final MediaType mediaType); static boolean isStructured(final MediaType mediaType); static boolean includes(final MediaType one, final MediaType other); static boolean areCompatible(final MediaType one, final MediaType other); static String toHeader(final MediaType mediaType); static boolean isStandardParameter(final String parameter); static final String WILDCARD_TYPE; static final String PARAM_CHARSET; }### Answer:
@Test public void createsSimpleMediaTypes() { MediaType mt=MediaTypes.of("application","json"); assertThat(mt.type(),equalTo("application")); assertThat(mt.subType(),equalTo("json")); assertThat(mt.suffix(),nullValue()); assertThat(mt.charset(),nullValue()); assertThat(mt.parameters().size(),equalTo(0)); }
@Test public void createsStructuredMediaTypes() { MediaType mt=MediaTypes.of("application","ld","json"); assertThat(mt.type(),equalTo("application")); assertThat(mt.subType(),equalTo("ld")); assertThat(mt.suffix(),equalTo("json")); assertThat(mt.charset(),nullValue()); assertThat(mt.parameters().size(),equalTo(0)); }
@Test public void cannotCreateMediaTypeWithWildcardSuffix() { try { MediaTypes.of("type", "subtype", "*"); fail("Should not be able to create a media type with wildcard suffix"); } catch (InvalidMediaTypeException e) { assertThat(e.getMessage(),equalTo("Could not create media type")); assertThat(e.getCause().getMessage(),equalTo("Structured syntax suffix cannot be a wildcard")); } }