10
10
11
11
import static org .assertj .core .api .Assertions .assertThat ;
12
12
13
- public abstract class JsonNodeTest {
14
-
15
- protected static JsonNodeFactory nodeFactory ;
13
+ public abstract class JsonNodeTest implements ProviderTest {
16
14
17
15
@ Test
18
16
void nullNode () {
19
- JsonNode node = nodeFactory .create ("null" );
17
+ JsonNode node = getJsonNodeFactory () .create ("null" );
20
18
assertThat (node ).isNotNull ();
21
19
assertThat (node .getNodeType ()).isEqualTo (SimpleType .NULL );
22
20
assertThat (node .isNull ()).isTrue ();
@@ -31,7 +29,7 @@ void nullNode() {
31
29
32
30
@ Test
33
31
void booleanNode () {
34
- JsonNode node = nodeFactory .create ("true" );
32
+ JsonNode node = getJsonNodeFactory () .create ("true" );
35
33
assertThat (node ).isNotNull ();
36
34
assertThat (node .getNodeType ()).isEqualTo (SimpleType .BOOLEAN );
37
35
assertThat (node .isNull ()).isFalse ();
@@ -48,7 +46,7 @@ void booleanNode() {
48
46
@ Test
49
47
void stringNode () {
50
48
String value = "~!@#$%6 anything \uD83D \uDCA9 " ;
51
- JsonNode node = nodeFactory .create ("\" " + value + "\" " );
49
+ JsonNode node = getJsonNodeFactory () .create ("\" " + value + "\" " );
52
50
assertThat (node ).isNotNull ();
53
51
assertThat (node .getNodeType ()).isEqualTo (SimpleType .STRING );
54
52
assertThat (node .isNull ()).isFalse ();
@@ -76,7 +74,7 @@ void stringNode() {
76
74
"2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
77
75
})
78
76
void integerNode (String value ) {
79
- JsonNode node = nodeFactory .create (value );
77
+ JsonNode node = getJsonNodeFactory () .create (value );
80
78
assertThat (node ).isNotNull ();
81
79
assertThat (node .getNodeType ()).isEqualTo (SimpleType .INTEGER );
82
80
assertThat (node .isNull ()).isFalse ();
@@ -114,7 +112,7 @@ void integerNode(String value) {
114
112
"0.9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
115
113
})
116
114
void numberNode (String value ) {
117
- JsonNode node = nodeFactory .create (value );
115
+ JsonNode node = getJsonNodeFactory () .create (value );
118
116
assertThat (node ).isNotNull ();
119
117
assertThat (node .getNodeType ()).isEqualTo (SimpleType .NUMBER );
120
118
assertThat (node .isNull ()).isFalse ();
@@ -138,7 +136,7 @@ void numberNode(String value) {
138
136
@ Test
139
137
void arrayNode () {
140
138
String value = "[null, true, \" a\" , 1, 1.2]" ;
141
- JsonNode node = nodeFactory .create (value );
139
+ JsonNode node = getJsonNodeFactory () .create (value );
142
140
assertThat (node ).isNotNull ();
143
141
assertThat (node .getNodeType ()).isEqualTo (SimpleType .ARRAY );
144
142
assertThat (node .isNull ()).isFalse ();
@@ -155,7 +153,7 @@ void arrayNode() {
155
153
@ Test
156
154
void objectNode () {
157
155
String value = "{\" a\" : null, \" b\" : 1, \" c\" : {}}" ;
158
- JsonNode node = nodeFactory .create (value );
156
+ JsonNode node = getJsonNodeFactory () .create (value );
159
157
assertThat (node ).isNotNull ();
160
158
assertThat (node .getNodeType ()).isEqualTo (SimpleType .OBJECT );
161
159
assertThat (node .isNull ()).isFalse ();
@@ -171,37 +169,37 @@ void objectNode() {
171
169
172
170
@ Test
173
171
void jsonPointerForNull () {
174
- JsonNode node = nodeFactory .create ("null" );
172
+ JsonNode node = getJsonNodeFactory () .create ("null" );
175
173
assertThat (node .getJsonPointer ()).isEmpty ();
176
174
}
177
175
178
176
@ Test
179
177
void jsonPointerForBoolean () {
180
- JsonNode node = nodeFactory .create ("false" );
178
+ JsonNode node = getJsonNodeFactory () .create ("false" );
181
179
assertThat (node .getJsonPointer ()).isEmpty ();
182
180
}
183
181
184
182
@ Test
185
183
void jsonPointerForString () {
186
- JsonNode node = nodeFactory .create ("\" anything\" " );
184
+ JsonNode node = getJsonNodeFactory () .create ("\" anything\" " );
187
185
assertThat (node .getJsonPointer ()).isEmpty ();
188
186
}
189
187
190
188
@ Test
191
189
void jsonPointerForInteger () {
192
- JsonNode node = nodeFactory .create ("123" );
190
+ JsonNode node = getJsonNodeFactory () .create ("123" );
193
191
assertThat (node .getJsonPointer ()).isEmpty ();
194
192
}
195
193
196
194
@ Test
197
195
void jsonPointerForNumber () {
198
- JsonNode node = nodeFactory .create ("123.321" );
196
+ JsonNode node = getJsonNodeFactory () .create ("123.321" );
199
197
assertThat (node .getJsonPointer ()).isEmpty ();
200
198
}
201
199
202
200
@ Test
203
201
void jsonPointerForArray () {
204
- JsonNode node = nodeFactory .create ("[[1, 2], []]" );
202
+ JsonNode node = getJsonNodeFactory () .create ("[[1, 2], []]" );
205
203
assertThat (node .getJsonPointer ()).isEmpty ();
206
204
List <JsonNode > nodes = node .asArray ();
207
205
assertThat (nodes .get (0 ).getJsonPointer ()).isEqualTo ("/0" );
@@ -212,7 +210,7 @@ void jsonPointerForArray() {
212
210
213
211
@ Test
214
212
void jsonPointerForObject () {
215
- JsonNode node = nodeFactory .create ("{\" a\" : [1, {\" b\" : 2}]}" );
213
+ JsonNode node = getJsonNodeFactory () .create ("{\" a\" : [1, {\" b\" : 2}]}" );
216
214
assertThat (node .getJsonPointer ()).isEmpty ();
217
215
Map <String , JsonNode > object = node .asObject ();
218
216
assertThat (object .get ("a" ).getJsonPointer ()).isEqualTo ("/a" );
@@ -223,6 +221,8 @@ void jsonPointerForObject() {
223
221
224
222
@ Test
225
223
void nullEquals () {
224
+ JsonNodeFactory nodeFactory = getJsonNodeFactory ();
225
+
226
226
JsonNode node1 = nodeFactory .create ("null" );
227
227
JsonNode node2 = nodeFactory .create ("null" );
228
228
assertThat (node1 .isEqualTo (node2 )).isTrue ();
@@ -238,6 +238,8 @@ void nullEquals() {
238
238
239
239
@ Test
240
240
void booleanEquals () {
241
+ JsonNodeFactory nodeFactory = getJsonNodeFactory ();
242
+
241
243
JsonNode node1 = nodeFactory .create ("true" );
242
244
JsonNode node2 = nodeFactory .create ("true" );
243
245
assertThat (node1 .isEqualTo (node2 )).isTrue ();
@@ -254,6 +256,8 @@ void booleanEquals() {
254
256
255
257
@ Test
256
258
void stringEquals () {
259
+ JsonNodeFactory nodeFactory = getJsonNodeFactory ();
260
+
257
261
JsonNode node1 = nodeFactory .create ("\" a\" " );
258
262
JsonNode node2 = nodeFactory .create ("\" a\" " );
259
263
assertThat (node1 .isEqualTo (node2 )).isTrue ();
@@ -270,6 +274,8 @@ void stringEquals() {
270
274
271
275
@ Test
272
276
void integerEquals () {
277
+ JsonNodeFactory nodeFactory = getJsonNodeFactory ();
278
+
273
279
JsonNode node1 = nodeFactory .create ("123" );
274
280
JsonNode node2 = nodeFactory .create ("123" );
275
281
assertThat (node1 .isEqualTo (node2 )).isTrue ();
@@ -287,6 +293,8 @@ void integerEquals() {
287
293
288
294
@ Test
289
295
void numberEquals () {
296
+ JsonNodeFactory nodeFactory = getJsonNodeFactory ();
297
+
290
298
JsonNode node1 = nodeFactory .create ("1.01" );
291
299
JsonNode node2 = nodeFactory .create ("1.01" );
292
300
assertThat (node1 .isEqualTo (node2 )).isTrue ();
@@ -303,6 +311,8 @@ void numberEquals() {
303
311
304
312
@ Test
305
313
void arrayEquals () {
314
+ JsonNodeFactory nodeFactory = getJsonNodeFactory ();
315
+
306
316
String value = "[null, true, \" a\" , 1, 1.2]" ;
307
317
JsonNode node1 = nodeFactory .create (value );
308
318
JsonNode node2 = nodeFactory .create (value );
@@ -323,6 +333,8 @@ void arrayEquals() {
323
333
324
334
@ Test
325
335
void objectEquals () {
336
+ JsonNodeFactory nodeFactory = getJsonNodeFactory ();
337
+
326
338
String value = "{\" a\" : [1, {\" b\" : 2}], \" b\" : 1}" ;
327
339
JsonNode node1 = nodeFactory .create (value );
328
340
JsonNode node2 = nodeFactory .create (value );
0 commit comments