### Question:
RFC6838MediaRangeValidator implements MediaRangeValidator { @Override public void checkType(final String type) { validateLength(type,"Type"); validateFirstChar(type,"type"); validateOtherChars(type,"type"); } RFC6838MediaRangeValidator(); @Override void checkType(final String type); @Override void checkSubType(final String subType); @Override void checkSuffix(final String suffix);  }### Answer:
@Test public void failsForTypeWithInvalidFirstChar() throws Exception { try { sut.checkType(".invalidFirstChar"); fail("Should fail type check if first char is not valid"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(),equalTo("Invalid character '.' in type '.invalidFirstChar' at 0")); } }
@Test public void failsIfTypeLengthIsGreaterThanExpected() throws Exception { try { sut.checkType(longName()); fail("Should fail type check if length is greater than expected"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(),equalTo("Type length cannot be greater than 127 ('"+longName()+"' has 128)")); } }
@Test public void acceptsMinimalType() { sut.checkType("A"); }
@Test public void acceptsWildcardType() { sut.checkType("*"); }
@Test public void failsForWrongWildcardType() { try { sut.checkType("*bad"); fail("Should fail type check if bad wildcard type is defined"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(),equalTo("Invalid character '*' in type '*bad' at 0")); } }
@Test public void failsForTypeWithInvalidOtherChar() throws Exception { try { sut.checkType("invalidÓtherChar"); fail("Should fail type check if other char is not valid"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(),equalTo("Invalid character 'Ó' in type 'invalidÓtherChar' at 7")); } }