From 144f1b76657f844d314b514d5d79d424dfd8b91b Mon Sep 17 00:00:00 2001 From: Carsten Wickner Date: Tue, 19 Dec 2023 00:24:20 +0100 Subject: [PATCH] chore: harmonise indentations --- .../JsonPropertySorterIntegrationTest.java | 131 +++++++++--------- 1 file changed, 65 insertions(+), 66 deletions(-) diff --git a/jsonschema-module-jackson/src/test/java/com/github/victools/jsonschema/module/jackson/JsonPropertySorterIntegrationTest.java b/jsonschema-module-jackson/src/test/java/com/github/victools/jsonschema/module/jackson/JsonPropertySorterIntegrationTest.java index 7bb02616..e0cfdbfe 100644 --- a/jsonschema-module-jackson/src/test/java/com/github/victools/jsonschema/module/jackson/JsonPropertySorterIntegrationTest.java +++ b/jsonschema-module-jackson/src/test/java/com/github/victools/jsonschema/module/jackson/JsonPropertySorterIntegrationTest.java @@ -38,71 +38,70 @@ public class JsonPropertySorterIntegrationTest { - @ParameterizedTest - @CsvSource({ - "TestObject, one two three", - "TestContainer, one two three" - }) - public void testJsonPropertyOrderWithChildAnnotations(String targetTypeName, String expectedFieldOrder) throws Exception { - JacksonModule module = new JacksonModule(JacksonOption.RESPECT_JSONPROPERTY_ORDER, - JacksonOption.INCLUDE_ONLY_JSONPROPERTY_ANNOTATED_METHODS); - SchemaGeneratorConfig config = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2019_09, OptionPreset.PLAIN_JSON) - .with(Option.NONSTATIC_NONVOID_NONGETTER_METHODS, Option.FIELDS_DERIVED_FROM_ARGUMENTFREE_METHODS) - .with(module) - .build(); - Class targetType = Stream.of(JsonPropertySorterIntegrationTest.class.getDeclaredClasses()) - .filter(testType -> testType.getSimpleName().equals(targetTypeName)) - .findFirst() - .orElseThrow(IllegalArgumentException::new); - SchemaGenerator generator = new SchemaGenerator(config); - JsonNode result = generator.generateSchema(targetType); - - ObjectNode properties = (ObjectNode) result.get(config.getKeyword(SchemaKeyword.TAG_PROPERTIES)); - List resultPropertyNames = new ArrayList<>(); - properties.fieldNames().forEachRemaining(resultPropertyNames::add); - Assertions.assertEquals(Arrays.asList(expectedFieldOrder.split(" ")), resultPropertyNames); - } - - @JsonPropertyOrder({ "one", "two", "three" }) - public static class TestContainer { - - @JsonProperty("three") - private Integer thirdInteger; - @JsonProperty("one") - private String firstString; - - @JsonProperty("two") - public boolean getSecondValue() { - return true; - } - - } - - @JsonPropertyOrder({ "one", "two" , "three"}) - public static class TestObject { - - private TestContainer container; - private String secondString; - - @JsonIgnore - public TestContainer getContainer() { - return this.container; - } - - @JsonProperty("three") - public Integer getInteger() { - return this.container.thirdInteger; - } - - @JsonProperty("two") - public String getSecondString() { - return this.secondString; - } - - @JsonProperty("one") - public String getString() { - return this.container.firstString; - } - } + @ParameterizedTest + @CsvSource({ + "TestObject, one two three", + "TestContainer, one two three" + }) + public void testJsonPropertyOrderWithChildAnnotations(String targetTypeName, String expectedFieldOrder) throws Exception { + JacksonModule module = new JacksonModule(JacksonOption.RESPECT_JSONPROPERTY_ORDER, + JacksonOption.INCLUDE_ONLY_JSONPROPERTY_ANNOTATED_METHODS); + SchemaGeneratorConfig config = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2019_09, OptionPreset.PLAIN_JSON) + .with(Option.NONSTATIC_NONVOID_NONGETTER_METHODS, Option.FIELDS_DERIVED_FROM_ARGUMENTFREE_METHODS) + .with(module) + .build(); + Class targetType = Stream.of(JsonPropertySorterIntegrationTest.class.getDeclaredClasses()) + .filter(testType -> testType.getSimpleName().equals(targetTypeName)) + .findFirst() + .orElseThrow(IllegalArgumentException::new); + SchemaGenerator generator = new SchemaGenerator(config); + JsonNode result = generator.generateSchema(targetType); + + ObjectNode properties = (ObjectNode) result.get(config.getKeyword(SchemaKeyword.TAG_PROPERTIES)); + List resultPropertyNames = new ArrayList<>(); + properties.fieldNames().forEachRemaining(resultPropertyNames::add); + Assertions.assertEquals(Arrays.asList(expectedFieldOrder.split(" ")), resultPropertyNames); + } + + @JsonPropertyOrder({"one", "two", "three"}) + public static class TestContainer { + + @JsonProperty("three") + private Integer thirdInteger; + @JsonProperty("one") + private String firstString; + + @JsonProperty("two") + public boolean getSecondValue() { + return true; + } + } + + @JsonPropertyOrder({"one", "two", "three"}) + public static class TestObject { + + private TestContainer container; + private String secondString; + + @JsonIgnore + public TestContainer getContainer() { + return this.container; + } + + @JsonProperty("three") + public Integer getInteger() { + return this.container.thirdInteger; + } + + @JsonProperty("two") + public String getSecondString() { + return this.secondString; + } + + @JsonProperty("one") + public String getString() { + return this.container.firstString; + } + } }