### Question:
OpenApiParser { public Result parse(String urlString) throws ParsingException { URI openApiUrl = null; try { openApiUrl = new URI(urlString); } catch (URISyntaxException e) { throw new ParsingException("Invalid URL", e); } final ParseOptions options = new ParseOptions(); options.setResolve(false); String openApiDescription; try { openApiDescription = readOpenAPIDescription(openApiUrl); } catch (Exception e) { log.error("Reading OpenAPI description from {} failed", openApiUrl, e); throw e; } final SwaggerParseResult result = new OpenAPIV3Parser().readContents(openApiDescription, null, options); validate(result, openApiUrl); String baseUrl = Optional.ofNullable(result.getOpenAPI().getServers()) .flatMap(s -> s.stream().findFirst()) .map(Server::getUrl) .orElse(""); if (!baseUrl.contains("{")) { baseUrl = openApiUrl.resolve(baseUrl).toString(); } final List<Operation> operations; if (result.getOpenAPI().getPaths() == null) { operations = Collections.emptyList(); } else { operations = new ArrayList<>(); result.getOpenAPI().getPaths().forEach((path, item) -> item.readOperationsMap().forEach((method, operation) -> operations.add(new Operation(method.name(), path.replaceAll("\\{[^/]*}", "*"))))); } return new Result(baseUrl, operations, result.getMessages()); }  Result parse(String urlString); boolean allowProtocol(String protocol);  }### Answer:
@Test public void shouldParseOpenApiYaml() throws OpenApiParser.ParsingException { URL url = getClass().getResource("/openapiparser/valid.yaml"); final OpenApiParser.Result result = new TestOpenApiParser().parse(url.toString()); Assert.assertFalse(result.hasWarnings()); Assert.assertEquals("https: }
@Test public void shouldHaveWarnings() throws OpenApiParser.ParsingException { URL url = getClass().getResource("/openapiparser/warnings.yml"); final OpenApiParser.Result result = new TestOpenApiParser().parse(url.toString()); Assert.assertTrue(result.hasWarnings()); Assert.assertEquals("https: }
@Test public void shouldParseOpenApiJson() throws OpenApiParser.ParsingException { URL url = getClass().getResource("/openapiparser/valid.json"); final OpenApiParser.Result result = new TestOpenApiParser().parse(url.toString()); Assert.assertFalse(result.hasWarnings()); Assert.assertEquals("https: }
@Test(expected = OpenApiParser.ParsingException.class) public void shouldFailIfInvalidProtocol() throws OpenApiParser.ParsingException { URL url = getClass().getResource("/openapiparser/valid.json"); final OpenApiParser.Result result = new OpenApiParser().parse(url.toString()); }
@Test(expected = OpenApiParser.ParsingException.class) public void shouldFailIfDuplicateEndpoint() throws OpenApiParser.ParsingException { URL url = getClass().getResource("/openapiparser/duplicateendpoint.yaml"); final OpenApiParser.Result result = new OpenApiParser().parse(url.toString()); }