@Test public void testMarkupRenderingInInstagram() throws IOException, URISyntaxException { //Given Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_instagram.yaml").toURI()); Path outputDirectory = Paths.get("build/test/asciidoc/instagram"); FileUtils.deleteQuietly(outputDirectory.toFile()); //When Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withTagOrdering(OrderBy.AS_IS) .build(); Swagger2MarkupConverter.from(file).withConfig(config).build() .toFolder(outputDirectory); //Then String[] files = outputDirectory.toFile().list(); assertThat(files).hasSize(4).containsAll(expectedFiles); Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/instagram").toURI()); DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testMarkupRenderingInInstagram.html"); }
@Test public void testWithMaps() throws IOException, URISyntaxException { //Given Path file = Paths.get(AsciidocConverterTest.class.getResource("/json/swagger_maps.json").toURI()); Path outputDirectory = Paths.get("build/test/asciidoc/maps"); FileUtils.deleteQuietly(outputDirectory.toFile()); //When Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withTagOrdering(OrderBy.AS_IS) .build(); Swagger2MarkupConverter.from(file) .withConfig(config) .build() .toFolder(outputDirectory); //Then String[] files = outputDirectory.toFile().list(); assertThat(files).hasSize(4).containsAll(expectedFiles); Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/maps").toURI()); DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testWithMaps.html"); }
@Test public void testOrderByNatural() throws IOException, URISyntaxException { //Given Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_ordering.yaml").toURI()); Path outputDirectory = Paths.get("build/test/asciidoc/ordering_natural"); FileUtils.deleteQuietly(outputDirectory.toFile()); Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withTagOrdering(OrderBy.NATURAL) .withParameterOrdering(OrderBy.NATURAL) .withOperationOrdering(OrderBy.NATURAL) .withPathsGroupedBy(GroupBy.TAGS) .build(); //When Swagger2MarkupConverter.from(file).withConfig(config).build() .toFolder(outputDirectory); //Then String[] files = outputDirectory.toFile().list(); assertThat(files).hasSize(4).containsAll(expectedFiles); Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/ordering_natural").toURI()); DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testOrderingNatural.html"); }
@Test public void testOrderByRegex() throws IOException, URISyntaxException { //Given Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_ordering_regex.yaml").toURI()); Path outputDirectory = Paths.get("build/test/asciidoc/ordering_regex"); FileUtils.deleteQuietly(outputDirectory.toFile()); Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withTagOrdering(OrderBy.NATURAL) .withParameterOrdering(OrderBy.NATURAL) .withOperationOrdering(OrderBy.NATURAL) .withPathsGroupedBy(GroupBy.REGEX) .withHeaderRegex("\\/(\\w+)(\\/|\\w)*$") .build(); //When Swagger2MarkupConverter.from(file).withConfig(config).build() .toFolder(outputDirectory); //Then String[] files = outputDirectory.toFile().list(); assertThat(files).hasSize(4).containsAll(expectedFiles); Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/ordering_regex").toURI()); DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testOrderingRegex.html"); }
@Test public void testOrderByAsIs() throws IOException, URISyntaxException { //Given Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_ordering.yaml").toURI()); Path outputDirectory = Paths.get("build/test/asciidoc/ordering_asis"); FileUtils.deleteQuietly(outputDirectory.toFile()); //When Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withTagOrdering(OrderBy.AS_IS) .withParameterOrdering(OrderBy.AS_IS) .withOperationOrdering(OrderBy.AS_IS) .withDefinitionOrdering(OrderBy.AS_IS) .withPathsGroupedBy(GroupBy.TAGS) .build(); Swagger2MarkupConverter.from(file).withConfig(config).build() .toFolder(outputDirectory); //Then String[] files = outputDirectory.toFile().list(); assertThat(files).hasSize(4).containsAll(expectedFiles); Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/ordering_asis").toURI()); DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testOrderingAsIs.html"); }
builder.withTagOrdering(OrderBy.CUSTOM); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).isEqualTo("You must provide a custom comparator if orderBy == OrderBy.CUSTOM"); builder.withTagOrdering(Ordering.<String>natural()); assertThat(builder.config.getTagOrderBy()).isEqualTo(OrderBy.CUSTOM); assertThat(builder.config.getTagOrdering()).isEqualTo(Ordering.natural());