Skip to content

Commit f4bda90

Browse files
committed
migrated NullSchema to new ViolationException constructor
1 parent 346063c commit f4bda90

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
*/
2323
public class NullSchema extends Schema {
2424

25-
public static final NullSchema INSTANCE = new NullSchema(builder());
26-
2725
/**
2826
* Builder class for {@link NullSchema}.
2927
*/
@@ -35,6 +33,8 @@ public NullSchema build() {
3533
}
3634
}
3735

36+
public static final NullSchema INSTANCE = new NullSchema(builder());
37+
3838
public static Builder builder() {
3939
return new Builder();
4040
}
@@ -46,7 +46,8 @@ public NullSchema(final Builder builder) {
4646
@Override
4747
public void validate(final Object subject) {
4848
if (!(subject == null || subject == JSONObject.NULL)) {
49-
throw new ValidationException("expected: null, found: " + subject.getClass().getSimpleName());
49+
throw new ValidationException(this, "expected: null, found: "
50+
+ subject.getClass().getSimpleName());
5051
}
5152
}
5253
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@
1515
*/
1616
package org.everit.json.schema;
1717

18-
import org.everit.json.schema.NullSchema;
19-
import org.everit.json.schema.ValidationException;
2018
import org.json.JSONObject;
2119
import org.junit.Test;
2220

2321
public class NullSchemaTest {
2422

25-
@Test(expected = ValidationException.class)
23+
@Test
2624
public void failure() {
27-
NullSchema.INSTANCE.validate("null");
25+
TestSupport.exceptFailure(NullSchema.INSTANCE, "null");
2826
}
2927

3028
@Test

0 commit comments

Comments
 (0)