UaaMetricsEmitter { public long getMetricDelta(String name, long gaugeValue) { long result = gaugeValue; Long data = delta.get(name); delta.put(name, gaugeValue); if (data != null) { result = gaugeValue - data; } return result; } UaaMetricsEmitter(MetricsUtils metricsUtils, StatsDClient statsDClient, MBeanServerConnection server); @Scheduled(fixedRate = 5000, initialDelay = 0) void emitMetrics(); @Scheduled(fixedRate = 5000, initialDelay = 1000) void emitGlobalRequestMetrics(); @Scheduled(fixedRate = 5000, initialDelay = 1000) void emitUrlGroupRequestMetrics(); void emitGlobalServerStats(UaaMetrics metrics); void emitGlobalRequestMetrics(UaaMetrics metrics); @Scheduled(fixedRate = 5000, initialDelay = 2000) void emitVmVitals(); @Scheduled(fixedRate = 5000, initialDelay = 3000) void emitJvmVitals(); void throwIfOtherThanNotFound(Exception x); Number getValueFromBean(Object mbean, String getter); Object getValueFromMap(Map<String, ?> map, String path); void enableNotification(); long getMetricDelta(String name, long gaugeValue); boolean isNotificationEnabled();  }
@Test void getMetricDelta() { String name = "metric.name"; assertEquals(5L, uaaMetricsEmitter.getMetricDelta(name, 5L)); assertEquals(0L, uaaMetricsEmitter.getMetricDelta(name, 5L)); assertEquals(3L, uaaMetricsEmitter.getMetricDelta(name, 8L)); }