### Question:
ImmutableMediaType implements MediaType { @Override public String toHeader() { return MediaTypes.toHeader(this); } ImmutableMediaType(final MediaRangeSyntax syntax, final String type, final String subtype, String suffix, final Map<String, String> parameters); @Override String type(); @Override String subType(); @Override Charset charset(); @Override String suffix(); @Override Map<String,String> parameters(); @Override boolean isWildcard(); @Override String toHeader(); @Override int hashCode(); @Override boolean equals(final Object other); @Override String toString();  }### Answer:
@Test public void parameterlessRegularMediaTypeHeaderRepresentationIsValid() throws Exception { ImmutableMediaType sut = new ImmutableMediaType(MediaRangeSyntax.RFC6838, "type", "subtype", null, null); assertThat(sut.toHeader(),equalTo("type/subtype")); }
@Test public void parameterlessStructuredMediaTypeHeaderRepresentationIsValid() throws Exception { ImmutableMediaType sut = new ImmutableMediaType(MediaRangeSyntax.RFC6838, "type", "subtype", "suffix", null); assertThat(sut.toHeader(),equalTo("type/subtype+suffix")); }
@Test public void mediaTypeWithCharsetHeaderRepresentationIsValid() throws Exception { ImmutableMediaType sut = new ImmutableMediaType(MediaRangeSyntax.RFC6838, "type", "subtype", null, ImmutableMap.<String,String>builder().put("charset","\"UTF-8\"").build()); assertThat(sut.toHeader(),equalTo("type/subtype;charset=utf-8")); }
@Test public void mediaTypeWithCharsetHeaderAndOtherParametersHeaderRepresentationIsValid() throws Exception { ImmutableMediaType sut = new ImmutableMediaType(MediaRangeSyntax.RFC6838, "type", "subtype", null, ImmutableMap.<String,String>builder().put("param","value").put("charset","\"UTF-8\"").build()); assertThat(sut.toHeader(),equalTo("type/subtype;charset=utf-8;param=value")); }