7
7
import com .fasterxml .jackson .dataformat .csv .CsvSchema ;
8
8
import com .fasterxml .jackson .dataformat .csv .ModuleTestBase ;
9
9
import com .fasterxml .jackson .dataformat .csv .CsvSchema .Column ;
10
+ import com .fasterxml .jackson .dataformat .csv .schema .PropertyOrder74Test .Point ;
11
+ import com .fasterxml .jackson .dataformat .csv .schema .PropertyOrder74Test .PointWithAnnotation ;
10
12
11
13
public class SchemaTest extends ModuleTestBase
12
14
{
@@ -22,16 +24,26 @@ static class ArrayWrapper {
22
24
public List <String > c ;
23
25
}
24
26
27
+ // for [databind#74]
28
+ static class Point {
29
+ public int y ;
30
+ public int x ;
31
+ }
32
+
33
+ @ JsonPropertyOrder ()
34
+ public static class PointWithAnnotation extends Point {}
35
+
25
36
/*
26
37
/**********************************************************************
27
38
/* Test methods
28
39
/**********************************************************************
29
40
*/
30
41
42
+ final CsvMapper MAPPER = mapperForCsv ();
43
+
31
44
public void testUserWithTypedAutoSchema () throws Exception
32
45
{
33
- CsvMapper mapper = mapperForCsv ();
34
- CsvSchema schema = mapper .typedSchemaFor (FiveMinuteUser .class );
46
+ CsvSchema schema = MAPPER .typedSchemaFor (FiveMinuteUser .class );
35
47
assertEquals ("[\" firstName\" ,\" lastName\" ,\" gender\" ,\" verified\" ,\" userImage\" ]" ,
36
48
schema .getColumnDesc ());
37
49
assertEquals (5 , schema .size ());
@@ -65,8 +77,7 @@ public void testUserWithTypedAutoSchema() throws Exception
65
77
66
78
public void testArrayWithTypedAutoSchema () throws Exception
67
79
{
68
- CsvMapper mapper = mapperForCsv ();
69
- CsvSchema schema = mapper .typedSchemaFor (ArrayWrapper .class );
80
+ CsvSchema schema = MAPPER .typedSchemaFor (ArrayWrapper .class );
70
81
assertEquals ("[\" a\" ,\" b\" ,\" c\" ]" ,
71
82
schema .getColumnDesc ());
72
83
assertEquals (3 , schema .size ());
@@ -88,7 +99,7 @@ public void testArrayWithTypedAutoSchema() throws Exception
88
99
_verifyLinks (schema );
89
100
}
90
101
91
- // for [Issue #42]
102
+ // for [dataformat-csv #42]
92
103
public void testReorderByName () throws Exception
93
104
{
94
105
CsvMapper mapper = mapperForCsv ();
@@ -100,11 +111,10 @@ public void testReorderByName() throws Exception
100
111
_verifyLinks (schema );
101
112
}
102
113
103
- // for [Issue #42]
114
+ // for [dataformat-csv #42]
104
115
public void testReorderWithComparator () throws Exception
105
116
{
106
- CsvMapper mapper = mapperForCsv ();
107
- CsvSchema schema = mapper .schemaFor (Mixed .class );
117
+ CsvSchema schema = MAPPER .schemaFor (Mixed .class );
108
118
schema = schema .sortedBy (Collections .<String >reverseOrder ());
109
119
assertEquals (aposToQuotes ("['d','c','b','a']" ), schema .getColumnDesc ());
110
120
@@ -125,4 +135,14 @@ private void _verifyLinks(CsvSchema schema)
125
135
prev = curr ;
126
136
}
127
137
}
138
+
139
+ // For [dataformat-csv#74]: problems applying default do-sort handling
140
+ public void testSchemaWithOrdering () throws Exception
141
+ {
142
+ CsvSchema schema1 = MAPPER .schemaFor (Point .class );
143
+ CsvSchema schema2 = MAPPER .schemaFor (PointWithAnnotation .class );
144
+
145
+ assertEquals (schema1 .size (), schema2 .size ());
146
+ assertEquals (schema1 .column (0 ).getName (), schema2 .column (0 ).getName ());
147
+ }
128
148
}
0 commit comments