AvroConstraintUtil extends QAUtil { public static Map<Path<GenericRecord,?>, Collection<Constraint<?>>> constraintsIn(Schema schema, boolean flagUnknowns, ConstraintFactory<Schema.Type> factory) { return constraintParamsIn(schema, factory); } private  AvroConstraintUtil(); static void add(Schema schema, ValueConstraint<?> constraint); static boolean hasLocalConstraints(Schema schema); static Collection<Constraint<?>> localConstraintsIn(Schema schema, ConstraintFactory<Schema.Type> factory); static boolean hasLocalConstraints(Field field); static Collection<Constraint<?>> localConstraintsIn(Field field, ConstraintFactory<Schema.Type> factory); static void showIssues(Map<Path<GenericRecord,?>, Collection<Violation>> issuesByPath, PrintStream out); static Map<Path<GenericRecord,?>, Collection<Constraint<?>>> constraintsIn(Schema schema, boolean flagUnknowns, ConstraintFactory<Schema.Type> factory); static final String TypeKey; static final String AllowNullKey; }
@Test public void constraintsIn() { byte[] schemaBytes = AbstractConstraintTest.readResource("person.avsc"); Schema sc = AvroUtil.parseSchema(new String(schemaBytes)); Map<Path<GenericRecord, ?>, Collection<Constraint<?>>> constraints = AvroConstraintUtil.constraintsIn(sc, true, AvroConfiguration.ConstraintFactory); assertEquals(10, constraints.size()); }
@Test public void constraintsIn2() { byte[] schemaBytes = AbstractConstraintTest.readResource("GoodBadMix.avsc"); Schema sc = AvroUtil.parseSchema(new String(schemaBytes)); Map<Path<GenericRecord, ?>, Collection<Constraint<?>>> constraints = AvroConstraintUtil.constraintsIn(sc, true, AvroConfiguration.ConstraintFactory); assertEquals(3, constraints.size()); }