@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 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"); }
@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"); }
builder.withParameterOrdering(OrderBy.CUSTOM); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).isEqualTo("You must provide a custom comparator if orderBy == OrderBy.CUSTOM"); builder.withParameterOrdering(Swagger2MarkupConfigBuilder.PARAMETER_NAME_NATURAL_ORDERING); assertThat(builder.config.getParameterOrderBy()).isEqualTo(OrderBy.CUSTOM); assertThat(builder.config.getParameterOrdering()).isEqualTo(Swagger2MarkupConfigBuilder.PARAMETER_NAME_NATURAL_ORDERING);