DefinitionDocumentNameResolver extends DocumentResolver { public String apply(String definitionName) { if (config.isSeparatedDefinitionsEnabled()) return new File(config.getSeparatedDefinitionsFolder(), markupDocBuilder.addFileExtension(normalizeName(definitionName))).getPath(); else return markupDocBuilder.addFileExtension(config.getDefinitionsDocument()); } DefinitionDocumentNameResolver(Swagger2MarkupConverter.SwaggerContext context); String apply(String definitionName);  }
@Test public void testDefault() { Swagger2MarkupConverter.SwaggerContext context = createContext(); assertThat(new DefinitionDocumentNameResolver(context).apply("DefinitionName")).isEqualTo("definitions.adoc"); }
@Test public void testWithInterDocumentCrossReferencesAndNoOutputPath() { Swagger2MarkupConfig config = (Swagger2MarkupConfig) new Swagger2MarkupConfigBuilder() .withInterDocumentCrossReferences() .build(); Swagger2MarkupConverter.SwaggerContext context = createContext(config); assertThat(new DefinitionDocumentNameResolver(context).apply("DefinitionName")) .isEqualTo("definitions.adoc"); }
@Test public void testWithInterDocumentCrossReferences() { Swagger2MarkupConfig config = (Swagger2MarkupConfig) new Swagger2MarkupConfigBuilder() .withInterDocumentCrossReferences() .build(); Swagger2MarkupConverter.SwaggerContext context = createContext(config); context.setOutputPath(Paths.get("/tmp")); assertThat(new DefinitionDocumentNameResolver(context).apply("DefinitionName")) .isEqualTo("definitions.adoc"); }
@Test public void testWithInterDocumentCrossReferencesAndPrefix() { Swagger2MarkupConfig config = (Swagger2MarkupConfig) new Swagger2MarkupConfigBuilder() .withInterDocumentCrossReferences("prefix_") .build(); Swagger2MarkupConverter.SwaggerContext context = createContext(config); context.setOutputPath(Paths.get("/tmp")); assertThat(new DefinitionDocumentNameResolver(context).apply("DefinitionName")) .isEqualTo("definitions.adoc"); }
@Test public void testWithInterDocumentCrossReferencesAndMarkdown() { Swagger2MarkupConfig config = (Swagger2MarkupConfig) new Swagger2MarkupConfigBuilder() .withInterDocumentCrossReferences() .withMarkupLanguage(MarkupLanguage.MARKDOWN) .build(); Swagger2MarkupConverter.SwaggerContext context = createContext(config); context.setOutputPath(Paths.get("/tmp")); assertThat(new DefinitionDocumentNameResolver(context).apply("DefinitionName")) .isEqualTo("definitions.md"); }