### Question:
JsonMetadataExporter implements Exporter { @Override public StringBuilder exportOneScope(MetricRegistry.Type scope) { MetricRegistry registry = MetricRegistries.get(scope); if (registry == null) { return null; } JsonObject obj = registryJSON(registry); return stringify(obj); } JsonMetadataExporter(); @Override String getContentType(); @Override StringBuilder exportOneScope(MetricRegistry.Type scope); @Override StringBuilder exportAllScopes(); @Override StringBuilder exportOneMetric(MetricRegistry.Type scope, MetricID metricID); @Override StringBuilder exportMetricsByName(MetricRegistry.Type scope, String name);  }### Answer:
@Test public void exportByScopeWithMultipleMetrics() { JsonMetadataExporter exporter = new JsonMetadataExporter(); MetricRegistry applicationRegistry = MetricRegistries.get(MetricRegistry.Type.APPLICATION); applicationRegistry.counter("counter1", new Tag("key1", "value1")); applicationRegistry.counter("counter1", new Tag("key1", "value2")); applicationRegistry.counter("counter2", new Tag("color", "red")); String result = exporter.exportOneScope(MetricRegistry.Type.APPLICATION).toString(); JsonObject json = Json.createReader(new StringReader(result)).read().asJsonObject(); JsonArray outerTagsArray = json.getJsonObject("counter1").getJsonArray("tags"); assertEquals(2, outerTagsArray.size()); JsonArray innerArray1 = outerTagsArray.getJsonArray(0); assertEquals(1, innerArray1.size()); assertEquals("key1=value1", innerArray1.getString(0)); JsonArray innerArray2 = outerTagsArray.getJsonArray(1); assertEquals(1, innerArray2.size()); assertEquals("key1=value2", innerArray2.getString(0)); outerTagsArray = json.getJsonObject("counter2").getJsonArray("tags"); assertEquals(1, outerTagsArray.size()); innerArray1 = outerTagsArray.getJsonArray(0); assertEquals(1, innerArray1.size()); assertEquals("color=red", innerArray1.getString(0)); }