|
2 | 2 |
|
3 | 3 | import static org.junit.Assert.assertFalse;
|
4 | 4 | import static org.junit.Assert.assertTrue;
|
5 |
| -import static org.mockito.Matchers.any; |
6 | 5 | import static org.mockito.Mockito.mock;
|
7 | 6 | import static org.mockito.Mockito.spy;
|
8 | 7 | import static org.mockito.Mockito.verify;
|
|
12 | 11 | import java.math.BigInteger;
|
13 | 12 | import java.util.ArrayList;
|
14 | 13 |
|
| 14 | +import org.everit.json.schema.listener.CombinedSchemaMatchEvent; |
| 15 | +import org.everit.json.schema.listener.CombinedSchemaMismatchEvent; |
15 | 16 | import org.everit.json.schema.listener.ValidationListener;
|
16 | 17 | import org.json.JSONArray;
|
17 | 18 | import org.json.JSONObject;
|
@@ -121,21 +122,22 @@ public void notPermittedTypeFailure(Object subject) {
|
121 | 122 | public void triggersCombinedSchemaEvents() {
|
122 | 123 | ValidationListener listener = mock(ValidationListener.class);
|
123 | 124 | StringSchema stringSchema = StringSchema.builder().requiresString(true).build();
|
124 |
| - TrueSchema trueSchema = TrueSchema.builder().build(); |
125 | 125 | EmptySchema emptySchema = EmptySchema.builder().build();
|
| 126 | + ObjectSchema objectSchema = ObjectSchema.builder().requiresObject(true).build(); |
126 | 127 | CombinedSchema combinedSchema = CombinedSchema.builder().criterion(CombinedSchema.ONE_CRITERION)
|
127 | 128 | .subschema(stringSchema)
|
128 | 129 | .subschema(emptySchema)
|
129 |
| - // .subschema(trueSchema) |
| 130 | + .subschema(objectSchema) |
130 | 131 | .build();
|
131 | 132 | ValidationFailureReporter reporter = spy(new CollectingFailureReporter(combinedSchema));
|
132 | 133 | JSONObject instance = new JSONObject();
|
133 | 134 |
|
134 | 135 | new ValidatingVisitor(instance, reporter, ReadWriteValidator.NONE, listener).visit(combinedSchema);
|
135 | 136 |
|
136 |
| - verify(listener).combinedSchemaMismatch(any()); |
137 |
| - verify(listener).combinedSchemaMatch(any()); //new CombinedSchemaValidationEvent(combinedSchema, trueSchema, instance) |
138 |
| - // verify(listener).combinedSchemaMatch(any()); //new CombinedSchemaValidationEvent(combinedSchema, emptySchema, instance) |
| 137 | + ValidationException exc = new ValidationException(stringSchema, String.class, instance); |
| 138 | + verify(listener).combinedSchemaMismatch(new CombinedSchemaMismatchEvent(combinedSchema, stringSchema, instance, exc)); |
| 139 | + verify(listener).combinedSchemaMatch(new CombinedSchemaMatchEvent(combinedSchema, emptySchema, instance)); |
| 140 | + verify(listener).combinedSchemaMatch(new CombinedSchemaMatchEvent(combinedSchema, objectSchema, instance)); |
139 | 141 | }
|
140 | 142 |
|
141 | 143 | }
|
0 commit comments