ApiMediaType { public static ApiMediaType parse(String acceptHeader) throws ApiMediaTypeException { ApiMediaType mediaType; if (acceptHeader == null || acceptHeader.contains(VERSION_1_5_0) || acceptHeader.contains(JSON) || acceptHeader.contains(APPLICATION_ANY) || acceptHeader.contains(ANY)) { mediaType = new ApiMediaType(ApiVersion.VERSION_1_5_0, ApiFormat.JSON, VERSION_1_5_0); } else if (acceptHeader.contains(VERSION_1_4_0)) { mediaType = new ApiMediaType(ApiVersion.VERSION_1_4_0, ApiFormat.JSON, VERSION_1_4_0); } else if (acceptHeader.contains(VERSION_1_3_0)) { mediaType = new ApiMediaType(ApiVersion.VERSION_1_3_0, ApiFormat.JSON, VERSION_1_3_0); } else if (acceptHeader.contains(VERSION_1_2_0)) { mediaType = new ApiMediaType(ApiVersion.VERSION_1_2_0, ApiFormat.JSON, VERSION_1_2_0); } else if (acceptHeader.contains(VERSION_1_1_0)) { mediaType = new ApiMediaType(ApiVersion.VERSION_1_1_0, ApiFormat.JSON, VERSION_1_1_0); } else if (acceptHeader.contains(VERSION_1_0_0)) { mediaType = new ApiMediaType(ApiVersion.VERSION_1_0_0, ApiFormat.JSON, VERSION_1_0_0); } else { throw ApiMediaTypeException.invalidVersion(acceptHeader); } return mediaType; } private  ApiMediaType(ApiVersion version, ApiFormat format, String externalForm); static ApiMediaType parse(String acceptHeader); ApiFormat getFormat(); ApiVersion getVersion(); String toExternalForm(); static final String VERSION_1_5_0; static final String VERSION_1_4_0; static final String VERSION_1_3_0; static final String VERSION_1_2_0; static final String VERSION_1_1_0; static final String VERSION_1_0_0; static final String JSON; }
@Test(expected = ApiMediaTypeException.class) public void testParseJsonWithInvalidVersion() throws Exception { ApiMediaType.parse("application/v0.0.0+json"); }