ClassLoadingGaugeSet implements MetricSet { @Override public Map<MetricName, Metric> getMetrics() { final Map<MetricName, Metric> gauges = new HashMap<MetricName, Metric>(); gauges.put(MetricName.build("loaded"), new PersistentGauge<Long>() { @Override public Long getValue() { return mxBean.getTotalLoadedClassCount(); } }); gauges.put(MetricName.build("loaded_current"), new PersistentGauge<Integer>() { @Override public Integer getValue() { return mxBean.getLoadedClassCount(); } }); gauges.put(MetricName.build("unloaded"), new PersistentGauge<Long>() { @Override public Long getValue() { return mxBean.getUnloadedClassCount(); } }); return gauges; } ClassLoadingGaugeSet();  ClassLoadingGaugeSet(ClassLoadingMXBean mxBean); @Override Map<MetricName, Metric> getMetrics(); @Override long lastUpdateTime();  }
@Test public void unLoadedGauge() throws Exception { final Gauge gauge = (Gauge) gauges.getMetrics().get(MetricName.build("unloaded")); assertThat(gauge.getValue()).isEqualTo(1L); }
@Test public void loadedCurrentGauge() throws Exception { final Gauge gauge = (Gauge) gauges.getMetrics().get(MetricName.build("loaded_current")); assertThat(gauge.getValue()).isEqualTo(1); }
@Test public void loadedGauge() throws Exception { final Gauge gauge = (Gauge) gauges.getMetrics().get(MetricName.build("loaded")); assertThat(gauge.getValue()).isEqualTo(2L); }