MimeTypeAggregator { public void add(String type) { checkTypeFormat(type); if (alreadyMatchesAllTypes()) { return; } String[] parts = type.split(DELIMITER, 2); String newTopLevelType = parts[0].toLowerCase(Locale.US); String newSubType = parts[1].toLowerCase(Locale.US); if (isNotInitialized()) { topLevelType = newTopLevelType; subType = newSubType; } else if (matchesTopLevelType(newTopLevelType)) { topLevelType = ASTERISK_WILDCARD; subType = ASTERISK_WILDCARD; } else if (!matchesSubType(newSubType)) { subType = ASTERISK_WILDCARD; } }  String getType(); void add(String type);  }
@Test(expected = IllegalArgumentException.class) public void addShouldThrowExceptionWhenMimeTypeIsInvalidOne() { new MimeTypeAggregator().add("something"); }
@Test(expected = IllegalArgumentException.class) public void addShouldThrowExceptionWhenMimeTypeIsInvalidTwo() { new MimeTypeAggregator().add("application/octet_stream"); }
@Test(expected = IllegalArgumentException.class) public void addShouldThrowExceptionWhenMimeTypeIsInvalidThree() { new MimeTypeAggregator().add("/"); }
@Test(expected = IllegalArgumentException.class) public void addShouldThrowExceptionWhenMimeTypeIsInvalidFour() { new MimeTypeAggregator().add("a/b/c"); }