Skip to content

Commit 346063c

Browse files
committed
migrated NotSchema to new ViolationException constructor
1 parent fa0a508 commit 346063c

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

core/src/main/java/org/everit/json/schema/NotSchema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ public void validate(final Object subject) {
5959
} catch (ValidationException e) {
6060
return;
6161
}
62-
throw new ValidationException("subject must not be valid agains schema " + mustNotMatch);
62+
throw new ValidationException(this, "subject must not be valid agains schema " + mustNotMatch);
6363
}
6464
}

core/src/test/java/org/everit/json/schema/NotSchemaTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,19 @@
1515
*/
1616
package org.everit.json.schema;
1717

18-
import org.everit.json.schema.BooleanSchema;
19-
import org.everit.json.schema.NotSchema;
20-
import org.everit.json.schema.ValidationException;
2118
import org.junit.Test;
2219

2320
public class NotSchemaTest {
2421

2522
@Test
26-
public void success() {
27-
NotSchema.builder().mustNotMatch(BooleanSchema.INSTANCE).build().validate("foo");
23+
public void failure() {
24+
NotSchema subject = NotSchema.builder().mustNotMatch(BooleanSchema.INSTANCE).build();
25+
TestSupport.exceptFailure(subject, true);
2826
}
2927

30-
@Test(expected = ValidationException.class)
31-
public void failure() {
32-
NotSchema.builder().mustNotMatch(BooleanSchema.INSTANCE).build().validate(true);
28+
@Test
29+
public void success() {
30+
NotSchema.builder().mustNotMatch(BooleanSchema.INSTANCE).build().validate("foo");
3331
}
3432

3533
}

core/src/test/java/org/everit/json/schema/TestSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static void exceptFailure(final Schema failingSchema, final Object input)
99
failingSchema.validate(input);
1010
Assert.fail(failingSchema + " did not fail for " + input);
1111
} catch (ValidationException e) {
12-
Assert.assertEquals(failingSchema, e.getViolatedSchema());
12+
Assert.assertSame(failingSchema, e.getViolatedSchema());
1313
}
1414
}
1515

0 commit comments

Comments
 (0)