OperationDocumentNameResolver extends OperationDocumentResolver { public String apply(PathOperation operation) { if (config.isSeparatedOperationsEnabled()) return new File(config.getSeparatedOperationsFolder(), markupDocBuilder.addFileExtension(normalizeName(operation.getId()))).getPath(); else return markupDocBuilder.addFileExtension(config.getPathsDocument()); } OperationDocumentNameResolver(Swagger2MarkupConverter.SwaggerContext context); String apply(PathOperation operation);  }
@Test public void testDefault() { Swagger2MarkupConverter.SwaggerContext context = createContext(); assertThat(new OperationDocumentNameResolver(context).apply(operation)).isEqualTo("paths.adoc"); }
@Test public void testWithSeparatedOperations() { Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withSeparatedOperations() .build(); Swagger2MarkupConverter.SwaggerContext context = createContext(config); assertThat(new OperationDocumentNameResolver(context).apply(operation)) .isEqualTo("operations" + fileSeparator + "test_get.adoc"); }
@Test public void testWithSeparatedOperationsAndInterDocumentCrossReferences() { Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withSeparatedOperations() .withInterDocumentCrossReferences() .build(); Swagger2MarkupConverter.SwaggerContext context = createContext(config); assertThat(new OperationDocumentNameResolver(context).apply(operation)) .isEqualTo("operations" + fileSeparator + "test_get.adoc"); }
@Test public void testWithInterDocumentCrossReferencesAndNoOutputPath() { Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withInterDocumentCrossReferences() .build(); Swagger2MarkupConverter.SwaggerContext context = createContext(config); assertThat(new OperationDocumentNameResolver(context).apply(operation)) .isEqualTo("paths.adoc"); }
@Test public void testWithInterDocumentCrossReferences() { Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withInterDocumentCrossReferences() .build(); Swagger2MarkupConverter.SwaggerContext context = createContext(config); context.setOutputPath(Paths.get("/tmp")); assertThat(new OperationDocumentNameResolver(context).apply(operation)) .isEqualTo("paths.adoc"); }
@Test public void testWithInterDocumentCrossReferencesAndPrefix() { Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withInterDocumentCrossReferences("prefix_") .build(); Swagger2MarkupConverter.SwaggerContext context = createContext(config); context.setOutputPath(Paths.get("/tmp")); String method = HttpMethod.GET.toString(); String path = "/test"; SwaggerPathOperation operation = new SwaggerPathOperation(method, path, path + " " + method.toLowerCase(), method + " " + path, new Operation()); assertThat(new OperationDocumentNameResolver(context).apply(operation)) .isEqualTo("paths.adoc"); }
@Test public void testWithInterDocumentCrossReferencesAndMarkdown() { Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withInterDocumentCrossReferences() .withMarkupLanguage(MarkupLanguage.MARKDOWN) .build(); Swagger2MarkupConverter.SwaggerContext context = createContext(config); context.setOutputPath(Paths.get("/tmp")); assertThat(new OperationDocumentNameResolver(context).apply(operation)) .isEqualTo("paths.md"); }