AvroMetricUtil extends QAUtil { private static Map<String, MetricDescriptor> allMetricsIn(JsonNode cstNode, Schema schema) { if (Type.UNION == schema.getType() && schema.getTypes().size() > 2) throw new RuntimeException("Cannot currently handle more than two major datatypes in a UNION"); Map<String, MetricDescriptor> metrics = new HashMap<>(cstNode.size() + 2); Type type = AvroUtil.primaryTypeIn(schema); boolean allowsNulls = AvroUtil.allowsNull(schema); Iterator<JsonNode> iter = cstNode.getElements(); while (iter.hasNext()) { Map<String, MetricDescriptor> csts = metricsIn(iter.next(), type, allowsNulls); if (csts != null) metrics.putAll(csts); } return metrics; } private  AvroMetricUtil(); static Map<Path<GenericRecord,?>, Map<String, MetricDescriptor>> metricsIn(Schema schema); static boolean hasLocalMetrics(Schema schema); static Map<String, MetricDescriptor> localMetricsIn(Schema schema); static boolean hasLocalMetrics(Field field); static Map<String, MetricDescriptor> localMetricsIn(Field field);  }
@Test public void allMetricsIn() { Map<Path<GenericRecord, ?>, Map<String, MetricDescriptor>> metrics = AvroMetricUtil.metricsIn(Person.SCHEMA$); assertEquals(metrics.size(), 1); }