@@ -27,9 +27,9 @@ public class ArraySchemaTest {
27
27
@ Test
28
28
public void additionalItemsSchema () {
29
29
ArraySchema .builder ()
30
- .addItemSchema (BooleanSchema .INSTANCE )
31
- .schemaOfAdditionalItems (NullSchema .INSTANCE )
32
- .build ().validate (ARRAYS .get ("additionalItemsSchema" ));
30
+ .addItemSchema (BooleanSchema .INSTANCE )
31
+ .schemaOfAdditionalItems (NullSchema .INSTANCE )
32
+ .build ().validate (ARRAYS .get ("additionalItemsSchema" ));
33
33
}
34
34
35
35
@ Test
@@ -42,34 +42,30 @@ public void additionalItemsSchemaFailure() {
42
42
ARRAYS .get ("additionalItemsSchemaFailure" ));
43
43
}
44
44
45
- @ Test ( expected = ValidationException . class )
45
+ @ Test
46
46
public void booleanItems () {
47
- ArraySchema .builder ().allItemSchema (BooleanSchema .INSTANCE ).build ()
48
- . validate ( ARRAYS .get ("boolArrFailure" ));
47
+ ArraySchema subject = ArraySchema .builder ().allItemSchema (BooleanSchema .INSTANCE ).build ();
48
+ TestSupport . expectFailure ( subject , BooleanSchema . INSTANCE , "#/2" , ARRAYS .get ("boolArrFailure" ));
49
49
}
50
50
51
51
@ Test
52
52
public void doesNotRequireExplicitArray () {
53
53
ArraySchema .builder ()
54
- .requiresArray (false )
55
- .uniqueItems (true )
56
- .build ().validate (ARRAYS .get ("doesNotRequireExplicitArray" ));
57
- }
58
-
59
- private void exceptFailure (final Schema failingSchema , final String testInputName ) {
60
- TestSupport .expectFailure (failingSchema , ARRAYS .get (testInputName ));
54
+ .requiresArray (false )
55
+ .uniqueItems (true )
56
+ .build ().validate (ARRAYS .get ("doesNotRequireExplicitArray" ));
61
57
}
62
58
63
59
@ Test
64
60
public void maxItems () {
65
61
ArraySchema subject = ArraySchema .builder ().maxItems (0 ).build ();
66
- exceptFailure (subject , "onlyOneItem" );
62
+ TestSupport . expectFailure (subject , "#" , ARRAYS . get ( " onlyOneItem") );
67
63
}
68
64
69
65
@ Test
70
66
public void minItems () {
71
67
ArraySchema subject = ArraySchema .builder ().minItems (2 ).build ();
72
- exceptFailure (subject , "onlyOneItem" );
68
+ TestSupport . expectFailure (subject , "#" , ARRAYS . get ( " onlyOneItem") );
73
69
}
74
70
75
71
@ Test
@@ -79,7 +75,7 @@ public void noAdditionalItems() {
79
75
.addItemSchema (BooleanSchema .INSTANCE )
80
76
.addItemSchema (NullSchema .INSTANCE )
81
77
.build ();
82
- exceptFailure (subject , "twoItemTupleWithAdditional" );
78
+ TestSupport . expectFailure (subject , "#" , ARRAYS . get ( " twoItemTupleWithAdditional") );
83
79
}
84
80
85
81
@ Test
@@ -96,7 +92,7 @@ public void nonUniqueArrayOfArrays() {
96
92
@ Test (expected = SchemaException .class )
97
93
public void tupleAndListFailure () {
98
94
ArraySchema .builder ().addItemSchema (BooleanSchema .INSTANCE ).allItemSchema (NullSchema .INSTANCE )
99
- .build ();
95
+ .build ();
100
96
}
101
97
102
98
@ Test
@@ -106,30 +102,32 @@ public void tupleWithOneItem() {
106
102
ARRAYS .get ("tupleWithOneItem" ));
107
103
}
108
104
109
- @ Test ( expected = ValidationException . class )
105
+ @ Test
110
106
public void typeFailure () {
111
- ArraySchema .builder ().build (). validate ( true );
107
+ TestSupport . expectFailure ( ArraySchema .builder ().build (), true );
112
108
}
113
109
114
- @ Test ( expected = ValidationException . class )
110
+ @ Test
115
111
public void uniqueItemsObjectViolation () {
116
- ArraySchema .builder ().uniqueItems (true ).build ().validate (ARRAYS .get ("nonUniqueObjects" ));
112
+ ArraySchema subject = ArraySchema .builder ().uniqueItems (true ).build ();
113
+ TestSupport .expectFailure (subject , "#" , ARRAYS .get ("nonUniqueObjects" ));
117
114
}
118
115
119
- @ Test ( expected = ValidationException . class )
116
+ @ Test
120
117
public void uniqueItemsViolation () {
121
- ArraySchema .builder ().uniqueItems (true ).build ().validate (ARRAYS .get ("nonUniqueItems" ));
118
+ ArraySchema subject = ArraySchema .builder ().uniqueItems (true ).build ();
119
+ TestSupport .expectFailure (subject , "#" , ARRAYS .get ("nonUniqueItems" ));
122
120
}
123
121
124
122
@ Test
125
123
public void uniqueItemsWithSameToString () {
126
124
ArraySchema .builder ().uniqueItems (true ).build ()
127
- .validate (ARRAYS .get ("uniqueItemsWithSameToString" ));
125
+ .validate (ARRAYS .get ("uniqueItemsWithSameToString" ));
128
126
}
129
127
130
128
@ Test
131
129
public void uniqueObjectValues () {
132
130
ArraySchema .builder ().uniqueItems (true ).build ()
133
- .validate (ARRAYS .get ("uniqueObjectValues" ));
131
+ .validate (ARRAYS .get ("uniqueObjectValues" ));
134
132
}
135
133
}
0 commit comments