|
|
@@ -1,6 +1,7 @@
|
|
|
package org.leumasjaffe.json.schema.tester;
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
+import static org.hamcrest.core.Is.*;
|
|
|
|
|
|
import org.junit.Test;
|
|
|
import org.leumasjaffe.json.schema.Tester;
|
|
|
@@ -8,12 +9,25 @@ import org.leumasjaffe.json.schema.Tester;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
|
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
|
|
+import com.fasterxml.jackson.databind.node.JsonNodeType;
|
|
|
import com.fasterxml.jackson.databind.node.NullNode;
|
|
|
|
|
|
public class AllOfTesterTest {
|
|
|
StubTester isArray = JsonNode::isArray;
|
|
|
StubTester isObject = JsonNode::isObject;
|
|
|
StubTester notEmpty = j -> j.size() != 0;
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testAcceptedTypesIsIntersect() {
|
|
|
+ Tester impossible = new AllOfTester(new MockTester(JsonNodeType.OBJECT, null),
|
|
|
+ new MockTester(JsonNodeType.ARRAY, null));
|
|
|
+ assertThat(impossible.acceptedTypes(), is(new JsonNodeType[0]));
|
|
|
+ Tester resticted = new AllOfTester(new MockTester(JsonNodeType.OBJECT, null),
|
|
|
+ isArray);
|
|
|
+ assertThat(resticted.acceptedTypes(), is(new JsonNodeType[]{JsonNodeType.OBJECT}));
|
|
|
+ Tester free = new AllOfTester(isObject, isArray); // lol
|
|
|
+ assertThat(free.acceptedTypes().length, is(Tester.ANY.length));
|
|
|
+ }
|
|
|
|
|
|
@Test
|
|
|
public void testFailsIfAllFail() {
|