### Question:
ImmutableMediaType implements MediaType { @Override public int hashCode() { return mediaRangeHashCode() ^ standardParametersHashCode() ^ customParametersHashCode(); } 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 equalParameterlessMediaTypesHaveSameHashCode() { final ImmutableMediaType one=new ImmutableMediaType(MediaRangeSyntax.RFC7230, "application", "rdf", "xml", null); final ImmutableMediaType other=new ImmutableMediaType(MediaRangeSyntax.RFC7230, "application", "rdf", "xml", null); assertThat(one.hashCode(),equalTo(other.hashCode())); }
@Test public void mediaTypesWithSameConfigurationHaveSameHashCode() { final ImmutableMediaType one=defaultMediaType().build(); final ImmutableMediaType other=defaultMediaType().build(); assertThat(one.hashCode(),equalTo(other.hashCode())); }
@Test public void mediaTypesWithDifferentMediaRangeHaveDifferentHashCode() { final ImmutableMediaType one=defaultMediaType().build(); final ImmutableMediaType other=defaultMediaType().withAlternativeMediaRange().build(); assertThat(one.hashCode(),not(equalTo(other.hashCode()))); }
@Test public void mediaTypesWithDifferentTypeAreHaveDifferentHashCode() { final ImmutableMediaType one=defaultMediaType().build(); final ImmutableMediaType other=defaultMediaType().withAlternativeType().build(); assertThat(one.hashCode(),not(equalTo(other.hashCode()))); }
@Test public void mediaTypesWithDifferentSubtypeHaveDifferentHashCode() { final ImmutableMediaType one=defaultMediaType().build(); final ImmutableMediaType other=defaultMediaType().withAlternativeSubtype().build(); assertThat(one.hashCode(),not(equalTo(other.hashCode()))); }
@Test public void mediaTypesWithDifferentSuffixHaveDifferentHashCode() { final ImmutableMediaType one=defaultMediaType().withSuffix().build(); final ImmutableMediaType other=defaultMediaType().withAlternativeSuffix().build(); assertThat(one.hashCode(),not(equalTo(other.hashCode()))); }
@Test public void mediaTypesWithDifferentCharsetsHaveDifferentHashCode() { final ImmutableMediaType one=defaultMediaType().build(); final ImmutableMediaType other=defaultMediaType().withAlternativeCharset().build(); assertThat(one.hashCode(),not(equalTo(other.hashCode()))); }
@Test public void mediaTypesWithDifferentParameterNumberHaveDifferentHashCode() { final ImmutableMediaType one=defaultMediaType().build(); final ImmutableMediaType other=defaultMediaType().withAdditionalParameter().build(); assertThat(one.hashCode(),not(equalTo(other.hashCode()))); }
@Test public void mediaTypesWithDifferentValuesForTheSameParameterHaveDifferentHashCode() { final ImmutableMediaType one=defaultMediaType().build(); final ImmutableMediaType other=defaultMediaType().withAlternativeParameter().build(); assertThat(one.hashCode(),not(equalTo(other.hashCode()))); }