MetricUtil { public static String getDataRetrievalValue(MappedMetricData mappedMetricData, String dataRetrievalTagKey) { val metricData = mappedMetricData.getMetricData(); val metricDefinition = metricData.getMetricDefinition(); val metricTags = metricDefinition.getTags(); return getValueFromTagKey(metricTags, dataRetrievalTagKey); }  static Map<String, String> defaultKvTags(); static Set<String> defaultVTags(); static MetricDefinition metricDefinition(); static MetricDefinition metricDefinition(Map<String, String> kvTags, Set<String> vTags); static MetricData metricData(MetricDefinition metricDef); static MetricData metricData(MetricDefinition metricDef, double value); static MetricData metricData(MetricDefinition metricDef, double value, long epochSecond); static String getDataRetrievalValue(MappedMetricData mappedMetricData, String dataRetrievalTagKey);  }
@Test public void testGetDataRetrievalValueOrMetricKey_getValue() { val mappedUuid = UUID.randomUUID(); Map<String, String> tags = new HashMap<>(); tags.put("function", "sum(test.metrics)"); val metricDefinition = new MetricDefinition(new TagCollection(tags)); val metricData = new MetricData(metricDefinition, 100.0, Instant.now().getEpochSecond()); val mappedMetricData = new MappedMetricData(metricData, mappedUuid); val value = MetricUtil.getDataRetrievalValue(mappedMetricData, "function"); assertEquals("sum(test.metrics)", value); }