@@ -63,7 +63,7 @@ public void doubleValueOverflow() throws IOException {
63
63
JsonNode doc = mapper .readTree (value );
64
64
65
65
Set <ValidationMessage > messages = v .validate (doc );
66
- assertFalse (format ("Expecing validation error with maximum %s and value %s" , maximum , value ), messages .isEmpty ());
66
+ assertFalse (format ("Expecting validation error with maximum %s and value %s" , maximum , value ), messages .isEmpty ());
67
67
}
68
68
}
69
69
@@ -86,7 +86,7 @@ public void documentParsedWithBigDecimal() throws IOException {
86
86
JsonNode doc = bigDecimalMapper .readTree (value );
87
87
88
88
Set <ValidationMessage > messages = v .validate (doc );
89
- assertFalse (format ("Expecing validation error with maximum %s and value %s" , maximum , value ), messages .isEmpty ());
89
+ assertFalse (format ("Expecting validation error with maximum %s and value %s" , maximum , value ), messages .isEmpty ());
90
90
}
91
91
}
92
92
@@ -109,7 +109,7 @@ public void documentAndSchemaParsedWithBigDecimal() throws IOException {
109
109
JsonNode doc = bigDecimalMapper .readTree (value );
110
110
111
111
Set <ValidationMessage > messages = v .validate (doc );
112
- assertFalse (format ("Expecing validation error with maximum %s and value %s" , maximum , value ), messages .isEmpty ());
112
+ assertFalse (format ("Expecting validation error with maximum %s and value %s" , maximum , value ), messages .isEmpty ());
113
113
}
114
114
}
115
115
@@ -198,7 +198,7 @@ public void longUnderMaxValueOverflow() throws IOException {
198
198
JsonNode doc = mapper .readTree (value );
199
199
200
200
Set <ValidationMessage > messages = v .validate (doc );
201
- assertFalse (format ("Expecing validation error with maximum %s and value %s" , maximum , value ), messages .isEmpty ());
201
+ assertFalse (format ("Expecting validation error with maximum %s and value %s" , maximum , value ), messages .isEmpty ());
202
202
}
203
203
}
204
204
@@ -218,7 +218,7 @@ public void longValueOverflowWithInverseEffect() throws IOException {
218
218
JsonNode doc = mapper .readTree (value );
219
219
220
220
Set <ValidationMessage > messages = v .validate (doc );
221
- assertTrue (format ("Expecing no validation errors as maximum %s is greater than value %s" , maximum , value ), messages .isEmpty ());
221
+ assertTrue (format ("Expecting no validation errors as maximum %s is greater than value %s" , maximum , value ), messages .isEmpty ());
222
222
}
223
223
}
224
224
@@ -238,7 +238,7 @@ public void BigIntegerBothWithinLongRangePositive() throws IOException {
238
238
JsonNode doc = bigIntegerMapper .readTree (value );
239
239
240
240
Set <ValidationMessage > messages = v .validate (doc );
241
- assertTrue (format ("Expecing no validation errors as maximum %s is greater than value %s" , maximum , value ), messages .isEmpty ());
241
+ assertTrue (format ("Expecting no validation errors as maximum %s is greater than value %s" , maximum , value ), messages .isEmpty ());
242
242
}
243
243
}
244
244
@@ -298,7 +298,7 @@ public void BigIntegerNotOverflow() throws IOException {
298
298
JsonNode doc = bigIntegerMapper .readTree (value );
299
299
300
300
Set <ValidationMessage > messages = v .validate (doc );
301
- assertTrue (format ("Expecing no validation errors as maximum %s is greater than value %s" , maximum , value ), messages .isEmpty ());
301
+ assertTrue (format ("Expecting no validation errors as maximum %s is greater than value %s" , maximum , value ), messages .isEmpty ());
302
302
}
303
303
}
304
304
@@ -318,7 +318,7 @@ public void BigIntegerBothAboveLongRangePositive() throws IOException {
318
318
JsonNode doc = bigIntegerMapper .readTree (value );
319
319
320
320
Set <ValidationMessage > messages = v .validate (doc );
321
- assertTrue (format ("Expecing no validation errors as maximum %s is greater than value %s" , maximum , value ), messages .isEmpty ());
321
+ assertTrue (format ("Expecting no validation errors as maximum %s is greater than value %s" , maximum , value ), messages .isEmpty ());
322
322
}
323
323
}
324
324
@@ -358,7 +358,7 @@ public void BigIntegerNotOverflowOnLongRangeEdge() throws IOException {
358
358
JsonNode doc = bigIntegerMapper .readTree (value );
359
359
360
360
Set <ValidationMessage > messages = v .validate (doc );
361
- assertTrue (format ("Expecing no validation errors as maximum %s is greater than value %s" , maximum , value ), messages .isEmpty ());
361
+ assertTrue (format ("Expecting no validation errors as maximum %s is greater than value %s" , maximum , value ), messages .isEmpty ());
362
362
}
363
363
}
364
364
@@ -378,7 +378,47 @@ public void BigIntegerOverflowOnLongRangeEdge() throws IOException {
378
378
JsonNode doc = bigIntegerMapper .readTree (value );
379
379
380
380
Set <ValidationMessage > messages = v .validate (doc );
381
- assertTrue (format ("Expecing no validation errors as maximum %s is greater than value %s" , maximum , value ), messages .isEmpty ());
381
+ assertTrue (format ("Expecting no validation errors as maximum %s is greater than value %s" , maximum , value ), messages .isEmpty ());
382
+ }
383
+ }
384
+
385
+ @ Test
386
+ public void testIntegerTypeWithFloatMaxPositive () throws IOException {
387
+ String [][] values = {
388
+ // maximum, value
389
+ {"37.7" , "37" }
390
+ };
391
+
392
+ for (String [] aTestCycle : values ) {
393
+ String maximum = aTestCycle [0 ];
394
+ String value = aTestCycle [1 ];
395
+ String schema = format ("{ \" $schema\" :\" http://json-schema.org/draft-04/schema#\" , \" type\" : \" integer\" , \" maximum\" : %s, \" exclusiveMaximum\" : false}" , maximum );
396
+
397
+ JsonSchema v = factory .getSchema (mapper .readTree (schema ));
398
+ JsonNode doc = bigIntegerMapper .readTree (value );
399
+
400
+ Set <ValidationMessage > messages = v .validate (doc );
401
+ assertTrue (format ("Expecting no validation errors as maximum %s is greater than value %s" , maximum , value ), messages .isEmpty ());
402
+ }
403
+ }
404
+
405
+ @ Test
406
+ public void testIntegerTypeWithFloatMaxNegative () throws IOException {
407
+ String [][] values = {
408
+ // maximum, value
409
+ {"37.7" , "38" }
410
+ };
411
+
412
+ for (String [] aTestCycle : values ) {
413
+ String maximum = aTestCycle [0 ];
414
+ String value = aTestCycle [1 ];
415
+ String schema = format ("{ \" $schema\" :\" http://json-schema.org/draft-04/schema#\" , \" type\" : \" integer\" , \" maximum\" : %s, \" exclusiveMaximum\" : false}" , maximum );
416
+
417
+ JsonSchema v = factory .getSchema (mapper .readTree (schema ));
418
+ JsonNode doc = bigIntegerMapper .readTree (value );
419
+
420
+ Set <ValidationMessage > messages = v .validate (doc );
421
+ assertFalse (format ("Expecting validation error with maximum %s and value %s" , maximum , value ), messages .isEmpty ());
382
422
}
383
423
}
384
424
}
0 commit comments