### Question:
NettyAllocatorMetricSet implements MetricSet { @Override public Map<String, Metric> getMetrics() { Map<String, Metric> gauges = new HashMap<>(); gauges.put(name(namespace, "usedDirectMemory"), (Gauge<Long>) metric::usedDirectMemory); gauges.put(name(namespace, "usedHeapMemory"), (Gauge<Long>) metric::usedHeapMemory); return copyOf(gauges); } NettyAllocatorMetricSet(String namespace,  ByteBufAllocatorMetric metric); @Override Map<String, Metric> getMetrics();  }### Answer:
@Test public void gaugeReportsDirectMemoryUsageValue() throws Exception { when(metricUnderTest.usedDirectMemory()).thenReturn(1L); NettyAllocatorMetricSet metricSet = new NettyAllocatorMetricSet("test-metric", metricUnderTest); Gauge<Long> metric = (Gauge<Long>) metricSet.getMetrics().get("test-metric.usedDirectMemory"); assertThat(metric.getValue(), is(1L)); }
@Test public void gaugeReportsHeapMemoryUsageValue() throws Exception { when(metricUnderTest.usedHeapMemory()).thenReturn(1L); NettyAllocatorMetricSet metricSet = new NettyAllocatorMetricSet("test-metric", metricUnderTest); Gauge<Long> metric = (Gauge<Long>) metricSet.getMetrics().get("test-metric.usedHeapMemory"); assertThat(metric.getValue(), is(1L)); }