CombinedSchema extends Schema { public static Builder allOf(Collection<Schema> schemas) { return builder(schemas).criterion(ALL_CRITERION); } CombinedSchema(Builder builder); static Builder allOf(Collection<Schema> schemas); static Builder anyOf(Collection<Schema> schemas); static Builder builder(); static Builder builder(Collection<Schema> subschemas); static Builder oneOf(Collection<Schema> schemas); ValidationCriterion getCriterion(); Collection<Schema> getSubschemas(); @Override boolean definesProperty(String field); @Override boolean equals(Object o); @Override int hashCode(); static final ValidationCriterion ALL_CRITERION; static final ValidationCriterion ANY_CRITERION; static final ValidationCriterion ONE_CRITERION; }
@Test public void validateAll() { TestSupport.failureOf(CombinedSchema.allOf(SUBSCHEMAS)) .input(20) .expectedKeyword("allOf") .expect(); }
@Test public void reportCauses() { try { CombinedSchema.allOf(SUBSCHEMAS).build().validate(24); Assert.fail("did not throw exception"); } catch (ValidationException e) { assertEquals(1, e.getCausingExceptions().size()); } }
@Test public void toStringTest() { CombinedSchema subject = CombinedSchema .allOf(asList(BooleanSchema.INSTANCE, NullSchema.INSTANCE)) .description("descr") .build(); JSONObject actual = new JSONObject(subject.toString()); assertThat(actual, sameJsonAs(new JSONObject("{\"allOf\":[" + BooleanSchema.INSTANCE.toString() + ", " + NullSchema.INSTANCE + "], \"description\":\"descr\"}"))); }