17
17
18
18
import static org .hamcrest .CoreMatchers .containsString ;
19
19
import static org .junit .Assert .assertEquals ;
20
+ import static org .junit .Assert .assertSame ;
20
21
import static org .junit .Assert .assertThat ;
22
+ import static org .junit .Assert .fail ;
21
23
22
24
import java .io .ByteArrayInputStream ;
23
25
import java .io .InputStream ;
24
26
import java .util .List ;
25
27
26
28
import org .everit .json .schema .loader .SchemaLoader ;
27
- import org .junit .Assert ;
28
29
29
30
public class TestSupport {
30
31
@@ -114,8 +115,17 @@ public static SchemaLoader.SchemaLoaderBuilder v6Loader() {
114
115
return SchemaLoader .builder ().draftV6Support ();
115
116
}
116
117
118
+ public static SchemaLoader .SchemaLoaderBuilder v7Loader () {
119
+ return SchemaLoader .builder ().draftV7Support ();
120
+ }
121
+
117
122
public static Schema loadAsV6 (Object schema ) {
118
- SchemaLoader loader = v6Loader ().schemaJson (schema ).draftV6Support ().build ();
123
+ SchemaLoader loader = v6Loader ().schemaJson (schema ).build ();
124
+ return loader .load ().build ();
125
+ }
126
+
127
+ public static Schema loadAsV7 (Object schema ) {
128
+ SchemaLoader loader = v7Loader ().schemaJson (schema ).build ();
119
129
return loader .load ().build ();
120
130
}
121
131
@@ -138,7 +148,7 @@ public static void expectFailure(final Schema failingSchema,
138
148
try {
139
149
test (failingSchema , expectedPointer , input );
140
150
} catch (ValidationException e ) {
141
- Assert . assertSame (expectedViolatedSchemaClass , e .getViolatedSchema ().getClass ());
151
+ assertSame (expectedViolatedSchemaClass , e .getViolatedSchema ().getClass ());
142
152
}
143
153
}
144
154
@@ -152,7 +162,7 @@ public static void expectFailure(final Schema failingSchema,
152
162
try {
153
163
test (failingSchema , expectedPointer , input );
154
164
} catch (ValidationException e ) {
155
- Assert . assertSame (expectedViolatedSchema , e .getViolatedSchema ());
165
+ assertSame (expectedViolatedSchema , e .getViolatedSchema ());
156
166
}
157
167
}
158
168
@@ -164,9 +174,9 @@ public static void expectFailure(final Schema failingSchema, final String expect
164
174
public static void expectFailure (final Failure failure ) {
165
175
try {
166
176
failure .validator .performValidation (failure .subject , failure .input );
167
- Assert . fail (failure .subject + " did not fail for " + failure .input );
177
+ fail (failure .subject + " did not fail for " + failure .input );
168
178
} catch (ValidationException e ) {
169
- Assert . assertSame (failure .expectedViolatedSchema (), e .getViolatedSchema ());
179
+ assertSame (failure .expectedViolatedSchema (), e .getViolatedSchema ());
170
180
assertEquals (failure .expectedPointer , e .getPointerToViolation ());
171
181
assertEquals (failure .expectedSchemaLocation , e .getSchemaLocation ());
172
182
if (failure .expectedKeyword != null ) {
@@ -186,7 +196,7 @@ private static void test(final Schema failingSchema, final String expectedPointe
186
196
final Object input ) {
187
197
try {
188
198
failingSchema .validate (input );
189
- Assert . fail (failingSchema + " did not fail for " + input );
199
+ fail (failingSchema + " did not fail for " + input );
190
200
} catch (ValidationException e ) {
191
201
if (expectedPointer != null ) {
192
202
assertEquals (expectedPointer , e .getPointerToViolation ());
0 commit comments