ContentTypeCleaner { public static String cleanContentType(MimePart mimePart, String contentType) { if (Strings.isNullOrEmpty(contentType)) { return null; } if (REGEX.matcher(contentType).find()) { return contentType; } LOGGER.warn("Can not parse Content-Type: " + contentType); return null; }  static void initialize(); static String cleanContentType(MimePart mimePart, String contentType);  }
@Test void nullContentTypeShouldReturnNull() { assertThat(ContentTypeCleaner .cleanContentType(null, null)) .isNull(); }
@Test void emptyContentTypeShouldReturnNull() { assertThat(ContentTypeCleaner .cleanContentType(null, "")) .isNull(); }
@Test void invalidContentTypeShouldReturnNull() { assertThat(ContentTypeCleaner .cleanContentType(null, "I'mNotValid")) .isNull(); }
@Test void validContentTypeShouldReturnTheRawInput() { String contentType = "application/pdf"; assertThat(ContentTypeCleaner .cleanContentType(null, contentType)) .isEqualTo(contentType); }