diff --git a/csv/src/test/java/com/fasterxml/jackson/dataformat/csv/schema/SchemaTest.java b/csv/src/test/java/com/fasterxml/jackson/dataformat/csv/schema/CsvSchemaTest.java similarity index 89% rename from csv/src/test/java/com/fasterxml/jackson/dataformat/csv/schema/SchemaTest.java rename to csv/src/test/java/com/fasterxml/jackson/dataformat/csv/schema/CsvSchemaTest.java index 0f55771f..f11510ff 100644 --- a/csv/src/test/java/com/fasterxml/jackson/dataformat/csv/schema/SchemaTest.java +++ b/csv/src/test/java/com/fasterxml/jackson/dataformat/csv/schema/CsvSchemaTest.java @@ -2,13 +2,14 @@ import java.util.*; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.csv.CsvMapper; import com.fasterxml.jackson.dataformat.csv.CsvSchema; import com.fasterxml.jackson.dataformat.csv.ModuleTestBase; import com.fasterxml.jackson.dataformat.csv.CsvSchema.Column; -public class SchemaTest extends ModuleTestBase +public class CsvSchemaTest extends ModuleTestBase { @JsonPropertyOrder({ "a", "b", "c", "d" }) static class Mixed { @@ -31,7 +32,7 @@ static class Point { @JsonPropertyOrder() public static class PointWithAnnotation extends Point {} - // for [dataformat-csv#142] + // for [dataformats-text#142] interface Named { public String getFirstName(); public String getLastName(); @@ -41,7 +42,18 @@ static abstract class YZ { public abstract int getY(); public abstract int getZ(); } - + + // for [dataformats-text#115] + static class PointWithExplicitIndices115 { + public int z; + + @JsonProperty(required = true, value = "y", index = 1) + public int y; + + @JsonProperty(required = true, value = "x", index = 2) + public int x; + } + /* /********************************************************************** /* Test methods @@ -206,4 +218,16 @@ public void testSchemaComposition() throws Exception assertEquals("lastName", it.next().getName()); assertEquals("x", it.next().getName()); } + + // For [dataformat-csv#115]: honor JsonProperty index + public void testSchemaWithExplicitIndices() + { + CsvSchema pointSchema = MAPPER.typedSchemaFor(PointWithExplicitIndices115.class); + + assertEquals("y", pointSchema.column(0).getName()); + assertEquals("x", pointSchema.column(1).getName()); + assertEquals("z", pointSchema.column(2).getName()); + + _verifyLinks(pointSchema); + } } diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 925d26f1..c350bdee 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -13,6 +13,8 @@ Modules: #7: Add `CsvParser.Feature.EMPTY_STRING_AS_NULL` to allow coercing empty Strings into `null` values (contributed by Tyler C-R) +#115: JsonProperty index is not honored by CsvSchema builder + -- actually fixed by [databind#2555] 2.10.2 (not yet released)