ClassLoadingGaugeSet implements MetricSet { @Override public Map<String, Metric> getMetrics() { final Map<String, Metric> gauges = new HashMap<>(); gauges.put("loaded", (Gauge<Long>) mxBean::getTotalLoadedClassCount); gauges.put("unloaded", (Gauge<Long>) mxBean::getUnloadedClassCount); return gauges; } ClassLoadingGaugeSet();  ClassLoadingGaugeSet(ClassLoadingMXBean mxBean); @Override Map<String, Metric> getMetrics();  }
@Test public void loadedGauge() { final Gauge gauge = (Gauge) gauges.getMetrics().get("loaded"); assertThat(gauge.getValue()).isEqualTo(2L); }
@Test public void unLoadedGauge() { final Gauge gauge = (Gauge) gauges.getMetrics().get("unloaded"); assertThat(gauge.getValue()).isEqualTo(1L); }