@@ -97,45 +97,56 @@ public void serializeDoubleProperty() throws IOException {
97
97
String json2 = m .writeValueAsString (p );
98
98
JSONObject jsonObj1 = new JSONObject (json1 );
99
99
JSONObject jsonObj2 = new JSONObject (json2 );
100
-
101
100
JSONAssert .assertEquals (jsonObj1 , jsonObj2 , true );
102
101
}
103
102
104
103
@ Test (description = "it should deserialize a DoubleProperty" )
105
104
public void deserializeDoubleProperty () throws IOException {
106
- final String json = "{\" type\" :\" number\" ,\" format\" :\" double\" }" ;
107
- final Schema p = m .readValue (json , Schema .class );
105
+ final String json1 = "{\" type\" :\" number\" ,\" format\" :\" double\" }" ;
106
+ final Schema p = m .readValue (json1 , Schema .class );
108
107
assertEquals (p .getType (), "number" );
109
108
assertEquals (p .getFormat (), "double" );
110
109
assertEquals (p .getClass (), NumberSchema .class );
111
- assertEquals (m .writeValueAsString (p ), json );
110
+ String json2 = m .writeValueAsString (p );
111
+ JSONObject jsonObj1 = new JSONObject (json1 );
112
+ JSONObject jsonObj2 = new JSONObject (json2 );
113
+ JSONAssert .assertEquals (jsonObj1 , jsonObj2 , true );
112
114
}
113
115
114
116
@ Test (description = "it should serialize a FloatProperty" )
115
117
public void serializeFloatProperty () throws IOException {
116
118
final NumberSchema p = new NumberSchema ()
117
119
._default (new BigDecimal ("1.2" ));
118
120
p .format ("float" );
119
- final String json = "{\" type\" :\" number\" ,\" format\" :\" float\" ,\" default\" :1.2}" ;
120
- assertEquals (m .writeValueAsString (p ), json );
121
+ final String json1 = "{\" type\" :\" number\" ,\" format\" :\" float\" ,\" default\" :1.2}" ;
122
+ String json2 = m .writeValueAsString (p );
123
+ JSONObject jsonObj1 = new JSONObject (json1 );
124
+ JSONObject jsonObj2 = new JSONObject (json2 );
125
+ JSONAssert .assertEquals (jsonObj1 , jsonObj2 , true );
121
126
}
122
127
123
128
@ Test (description = "it should deserialize a FloatProperty" )
124
129
public void deserializeFloatProperty () throws IOException {
125
- final String json = "{\" type\" :\" number\" ,\" format\" :\" float\" }" ;
126
- final Schema p = m .readValue (json , Schema .class );
130
+ final String json1 = "{\" type\" :\" number\" ,\" format\" :\" float\" }" ;
131
+ final Schema p = m .readValue (json1 , Schema .class );
127
132
assertEquals (p .getType (), "number" );
128
133
assertEquals (p .getFormat (), "float" );
129
134
assertEquals (p .getClass (), NumberSchema .class );
130
- assertEquals (m .writeValueAsString (p ), json );
135
+ String json2 = m .writeValueAsString (p );
136
+ JSONObject jsonObj1 = new JSONObject (json1 );
137
+ JSONObject jsonObj2 = new JSONObject (json2 );
138
+ JSONAssert .assertEquals (jsonObj1 , jsonObj2 , true );
131
139
}
132
140
133
141
@ Test (description = "it should serialize an IntegerProperty" )
134
142
public void serializeIntegerProperty () throws IOException {
135
143
final IntegerSchema p = new IntegerSchema ()
136
144
._default (32 );
137
- final String json = "{\" type\" :\" integer\" ,\" format\" :\" int32\" ,\" default\" :32}" ;
138
- assertEquals (m .writeValueAsString (p ), json );
145
+ final String json1 = "{\" type\" :\" integer\" ,\" format\" :\" int32\" ,\" default\" :32}" ;
146
+ String json2 = m .writeValueAsString (p );
147
+ JSONObject jsonObj1 = new JSONObject (json1 );
148
+ JSONObject jsonObj2 = new JSONObject (json2 );
149
+ JSONAssert .assertEquals (jsonObj1 , jsonObj2 , true );
139
150
}
140
151
141
152
@ Test (description = "it should deserialize a IntegerProperty" )
@@ -156,18 +167,24 @@ public void serializeLongProperty() throws IOException {
156
167
final IntegerSchema p = new IntegerSchema ()
157
168
.format ("int64" )
158
169
._default (8675309 );
159
- final String json = "{\" type\" :\" integer\" ,\" format\" :\" int64\" ,\" default\" :8675309}" ;
160
- assertEquals (m .writeValueAsString (p ), json );
170
+ final String json1 = "{\" type\" :\" integer\" ,\" format\" :\" int64\" ,\" default\" :8675309}" ;
171
+ String json2 = m .writeValueAsString (p );
172
+ JSONObject jsonObj1 = new JSONObject (json1 );
173
+ JSONObject jsonObj2 = new JSONObject (json2 );
174
+ JSONAssert .assertEquals (jsonObj1 , jsonObj2 , true );
161
175
}
162
176
163
177
@ Test (description = "it should deserialize a LongProperty" )
164
178
public void deserializeLongProperty () throws IOException {
165
- final String json = "{\" type\" :\" integer\" ,\" format\" :\" int64\" }" ;
166
- final Schema p = m .readValue (json , Schema .class );
179
+ final String json1 = "{\" type\" :\" integer\" ,\" format\" :\" int64\" }" ;
180
+ final Schema p = m .readValue (json1 , Schema .class );
167
181
assertEquals (p .getType (), "integer" );
168
182
assertEquals (p .getFormat (), "int64" );
169
183
assertEquals (p .getClass (), IntegerSchema .class );
170
- assertEquals (m .writeValueAsString (p ), json );
184
+ String json2 = m .writeValueAsString (p );
185
+ JSONObject jsonObj1 = new JSONObject (json1 );
186
+ JSONObject jsonObj2 = new JSONObject (json2 );
187
+ JSONAssert .assertEquals (jsonObj1 , jsonObj2 , true );
171
188
}
172
189
173
190
@ Test (description = "it should serialize a string MapProperty" )
@@ -189,17 +206,23 @@ public void deserializeStringMapProperty() throws IOException {
189
206
@ Test (description = "it should serialize a integer MapProperty" )
190
207
public void serializeIntegerMapProperty () throws IOException {
191
208
final Schema p = new MapSchema ().additionalProperties (new IntegerSchema ());
192
- final String json = "{\" type\" :\" object\" ,\" additionalProperties\" :{\" type\" :\" integer\" ,\" format\" :\" int32\" }}" ;
193
- assertEquals (m .writeValueAsString (p ), json );
209
+ final String json1 = "{\" type\" :\" object\" ,\" additionalProperties\" :{\" type\" :\" integer\" ,\" format\" :\" int32\" }}" ;
210
+ String json2 = m .writeValueAsString (p );
211
+ JSONObject jsonObj1 = new JSONObject (json1 );
212
+ JSONObject jsonObj2 = new JSONObject (json2 );
213
+ JSONAssert .assertEquals (jsonObj1 , jsonObj2 , true );
194
214
}
195
215
196
216
@ Test (description = "it should deserialize a integer MapProperty" )
197
217
public void deserializeIntegerMapProperty () throws IOException {
198
- final String json = "{\" type\" :\" object\" ,\" additionalProperties\" :{\" type\" :\" integer\" ,\" format\" :\" int32\" }}" ;
199
- final Schema p = m .readValue (json , Schema .class );
218
+ final String json1 = "{\" type\" :\" object\" ,\" additionalProperties\" :{\" type\" :\" integer\" ,\" format\" :\" int32\" }}" ;
219
+ final Schema p = m .readValue (json1 , Schema .class );
200
220
assertEquals (p .getType (), "object" );
201
221
assertEquals (p .getClass (), MapSchema .class );
202
- assertEquals (m .writeValueAsString (p ), json );
222
+ String json2 = m .writeValueAsString (p );
223
+ JSONObject jsonObj1 = new JSONObject (json1 );
224
+ JSONObject jsonObj2 = new JSONObject (json2 );
225
+ JSONAssert .assertEquals (jsonObj1 , jsonObj2 , true );
203
226
}
204
227
205
228
@ Test (description = "it should serialize a long MapProperty" )
@@ -281,14 +304,17 @@ public void deserializeEnumStringProperty() throws IOException {
281
304
282
305
@ Test (description = "it should deserialize an IntegerProperty with enums" )
283
306
public void deserializeEnumIntegerProperty () throws IOException {
284
- final String json = "{\" type\" :\" integer\" ,\" format\" :\" int32\" ,\" enum\" :[1,2]}" ;
285
- final Schema p = m .readValue (json , Schema .class );
307
+ final String json1 = "{\" type\" :\" integer\" ,\" format\" :\" int32\" ,\" enum\" :[1,2]}" ;
308
+ final Schema p = m .readValue (json1 , Schema .class );
286
309
assertEquals (p .getType (), "integer" );
287
310
List <Number > _enum = ((IntegerSchema ) p ).getEnum ();
288
311
assertNotNull (_enum );
289
312
assertEquals (_enum , Arrays .asList (1 , 2 ));
290
313
assertEquals (p .getClass (), IntegerSchema .class );
291
- assertEquals (m .writeValueAsString (p ), json );
314
+ String json2 = m .writeValueAsString (p );
315
+ JSONObject jsonObj1 = new JSONObject (json1 );
316
+ JSONObject jsonObj2 = new JSONObject (json2 );
317
+ JSONAssert .assertEquals (jsonObj1 , jsonObj2 , true );
292
318
}
293
319
294
320
@ Test (description = "it should serialize a string array property" )
@@ -327,8 +353,11 @@ public void serializeReadOnlyStringProperty() throws IOException {
327
353
public void deserializeNotReadOnlyStringProperty () throws IOException {
328
354
final StringSchema p = new StringSchema ();
329
355
p .setReadOnly (false );
330
- final String json = "{\" type\" :\" string\" ,\" readOnly\" :false}" ;
331
- assertEquals (m .writeValueAsString (p ), json );
356
+ final String json1 = "{\" type\" :\" string\" ,\" readOnly\" :false}" ;
357
+ String json2 = m .writeValueAsString (p );
358
+ JSONObject jsonObj1 = new JSONObject (json1 );
359
+ JSONObject jsonObj2 = new JSONObject (json2 );
360
+ JSONAssert .assertEquals (jsonObj1 , jsonObj2 , true );
332
361
}
333
362
334
363
@ Test (description = "it should serialize an object property with required set" )
0 commit comments