OperationDocumentResolverDefault extends OperationDocumentResolver { public String apply(PathOperation operation) { if (!config.isInterDocumentCrossReferencesEnabled() || context.getOutputPath() == null) return null; else return defaultString(config.getInterDocumentCrossReferencesPrefix()) + operationDocumentNameResolver.apply(operation); } OperationDocumentResolverDefault(Swagger2MarkupConverter.SwaggerContext context); String apply(PathOperation operation);  }
@Test public void testDefault() { Swagger2MarkupConverter.SwaggerContext context = createContext(); assertThat(new OperationDocumentResolverDefault(context).apply(operation)).isNull(); }
@Test public void testWithSeparatedOperations() { Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withSeparatedOperations() .build(); Swagger2MarkupConverter.SwaggerContext context = createContext(config); assertThat(new OperationDocumentResolverDefault(context).apply(operation)).isNull(); }
@Test public void testWithSeparatedOperationsAndInterDocumentCrossReferences() { Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withSeparatedOperations() .withInterDocumentCrossReferences() .build(); Swagger2MarkupConverter.SwaggerContext context = createContext(config); context.setOutputPath(Paths.get("/tmp")); assertThat(new OperationDocumentResolverDefault(context).apply(operation)) .isEqualTo("operations" + fileSeparator + "test_get.adoc"); }
@Test public void testWithInterDocumentCrossReferences() { Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withInterDocumentCrossReferences() .build(); Swagger2MarkupConverter.SwaggerContext context = createContext(config); context.setOutputPath(Paths.get("/tmp")); assertThat(new OperationDocumentResolverDefault(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")); assertThat(new OperationDocumentResolverDefault(context).apply(operation)) .isEqualTo("prefix_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 OperationDocumentResolverDefault(context).apply(operation)) .isEqualTo("paths.md"); }