JmxMetricsAccessor implements MetricsAccessor { @Override public <T> Map<String, T> getGaugeValues(String group, String gauge) { return getMetricValues(group, gauge, "Value"); } JmxMetricsAccessor(String url); void connect(); void close(); @Override Map<String, Long> getCounterValues(String group, String counter); @Override Map<String, T> getGaugeValues(String group, String gauge); @Override Map<String, Double> getTimerValues(String group, String timer);  }
@Test public void testGetGaugeValues() throws Exception { ObjectName gaugeObject = JmxUtil.getObjectName(SamzaContainerMetrics.class.getName(), "event-loop-utilization", "samza-container-1"); objectNames.add(gaugeObject); Double loopUtil = 0.8; when(conn.getAttribute(gaugeObject, "Value")).thenReturn(loopUtil); Map<String, Double> result = jmxMetricsAccessor.getGaugeValues(SamzaContainerMetrics.class.getName(), "event-loop-utilization"); assertTrue(result.size() == 1); assertTrue(result.get("samza-container-1").equals(loopUtil)); }