|
|
@@ -43,6 +43,11 @@ public class SchemaV6FactoryTest {
|
|
|
final Map.Entry<String, JsonNode> pair = schema.fields().next();
|
|
|
return factory.createMapping(pair.getKey(), pair.getValue());
|
|
|
}
|
|
|
+
|
|
|
+ @Test(expected=IllegalArgumentException.class)
|
|
|
+ public void testRejectsGarbage() {
|
|
|
+ fromSingleElement("{ \"pants\": true }");
|
|
|
+ }
|
|
|
|
|
|
@Test
|
|
|
public void testIDSchema() {
|
|
|
@@ -337,4 +342,77 @@ public class SchemaV6FactoryTest {
|
|
|
assertTrue(sing.accepts(BooleanNode.TRUE));
|
|
|
assertFalse(sing.accepts(new DoubleNode(1.5)));
|
|
|
}
|
|
|
+
|
|
|
+ @Test(expected=IllegalArgumentException.class)
|
|
|
+ public void testAllOfSchemaRequiresArray() {
|
|
|
+ fromSingleElement("{ \"allOf\": true }");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test(expected=IllegalArgumentException.class)
|
|
|
+ public void testAllOfSchemaRequiresNonEmptyArray() {
|
|
|
+ fromSingleElement("{ \"allOf\": [] }");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testAllOfSchemaPassesNonEmptyArray() {
|
|
|
+ try {
|
|
|
+ fromSingleElement("{ \"allOf\": [ false ] }");
|
|
|
+ } catch (IllegalArgumentException ex) {
|
|
|
+ fail("Couldn't parse");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test(expected=IllegalArgumentException.class)
|
|
|
+ public void testAnyOfSchemaRequiresArray() {
|
|
|
+ fromSingleElement("{ \"anyOf\": true }");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test(expected=IllegalArgumentException.class)
|
|
|
+ public void testAnyOfSchemaRequiresNonEmptyArray() {
|
|
|
+ fromSingleElement("{ \"anyOf\": [] }");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testAnyOfSchemaPassesNonEmptyArray() {
|
|
|
+ try {
|
|
|
+ fromSingleElement("{ \"anyOf\": [ false ] }");
|
|
|
+ } catch (IllegalArgumentException ex) {
|
|
|
+ fail("Couldn't parse");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test(expected=IllegalArgumentException.class)
|
|
|
+ public void testOneOfSchemaRequiresArray() {
|
|
|
+ fromSingleElement("{ \"oneOf\": true }");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test(expected=IllegalArgumentException.class)
|
|
|
+ public void testOneOfSchemaRequiresNonEmptyArray() {
|
|
|
+ fromSingleElement("{ \"oneOf\": [] }");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testOneOfSchemaPassesNonEmptyArray() {
|
|
|
+ try {
|
|
|
+ fromSingleElement("{ \"oneOf\": [ false ] }");
|
|
|
+ } catch (IllegalArgumentException ex) {
|
|
|
+ fail("Couldn't parse");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test(expected=IllegalStateException.class)
|
|
|
+ public void testNotSchemaRequiresSubSchema() {
|
|
|
+ fromSingleElement("{ \"not\": [] }");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testNotSchemaPassesBooleanAndObject() {
|
|
|
+ try {
|
|
|
+ fromSingleElement("{ \"not\": {} }");
|
|
|
+ fromSingleElement("{ \"not\": false }");
|
|
|
+ } catch (IllegalArgumentException ex) {
|
|
|
+ fail("Couldn't parse");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|