@Test void testMonitorNameFollowsGivenMonitorNameBuilderSpecifics() { String testPrefix = "additional-monitor-name."; PayloadTypeMessageMonitorWrapper<CapacityMonitor> testSubject = new PayloadTypeMessageMonitorWrapper<>( name -> CapacityMonitor.buildMonitor(name, meterRegistry), payloadType -> testPrefix + payloadType.getName()); String expectedMonitorName = testPrefix + STRING_MESSAGE.getPayloadType().getName(); testSubject.onMessageIngested(STRING_MESSAGE); assertEquals(1, meterRegistry.find(expectedMonitorName + ".capacity").meters().size()); }
@Override public MonitorCallback onMessageIngested(Message<?> message) { String monitorName = monitorNameBuilder.apply(message.getPayloadType()); MessageMonitor<Message<?>> messageMonitorForPayloadType = payloadTypeMonitors.computeIfAbsent(monitorName, monitorSupplier); return messageMonitorForPayloadType.onMessageIngested(message); }
PayloadTypeMessageMonitorWrapper implements MessageMonitor<Message<?>> { @Override public MonitorCallback onMessageIngested(Message<?> message) { String monitorName = monitorNameBuilder.apply(message.getPayloadType()); MessageMonitor<Message<?>> messageMonitorForPayloadType = payloadTypeMonitors.computeIfAbsent(monitorName, monitorSupplier); return messageMonitorForPayloadType.onMessageIngested(message); } }
PayloadTypeMessageMonitorWrapper implements MessageMonitor<Message<?>> { @Override public MonitorCallback onMessageIngested(Message<?> message) { String monitorName = monitorNameBuilder.apply(message.getPayloadType()); MessageMonitor<Message<?>> messageMonitorForPayloadType = payloadTypeMonitors.computeIfAbsent(monitorName, monitorSupplier); return messageMonitorForPayloadType.onMessageIngested(message); } PayloadTypeMessageMonitorWrapper(Function<String, T> monitorSupplier);  PayloadTypeMessageMonitorWrapper(Function<String, T> monitorSupplier,
                                            Function<Class<?>, String> monitorNameBuilder); }
PayloadTypeMessageMonitorWrapper implements MessageMonitor<Message<?>> { @Override public MonitorCallback onMessageIngested(Message<?> message) { String monitorName = monitorNameBuilder.apply(message.getPayloadType()); MessageMonitor<Message<?>> messageMonitorForPayloadType = payloadTypeMonitors.computeIfAbsent(monitorName, monitorSupplier); return messageMonitorForPayloadType.onMessageIngested(message); } PayloadTypeMessageMonitorWrapper(Function<String, T> monitorSupplier);  PayloadTypeMessageMonitorWrapper(Function<String, T> monitorSupplier,
                                            Function<Class<?>, String> monitorNameBuilder); @Override MonitorCallback onMessageIngested(Message<?> message); }
PayloadTypeMessageMonitorWrapper implements MessageMonitor<Message<?>> { @Override public MonitorCallback onMessageIngested(Message<?> message) { String monitorName = monitorNameBuilder.apply(message.getPayloadType()); MessageMonitor<Message<?>> messageMonitorForPayloadType = payloadTypeMonitors.computeIfAbsent(monitorName, monitorSupplier); return messageMonitorForPayloadType.onMessageIngested(message); } PayloadTypeMessageMonitorWrapper(Function<String, T> monitorSupplier);  PayloadTypeMessageMonitorWrapper(Function<String, T> monitorSupplier,
                                            Function<Class<?>, String> monitorNameBuilder); @Override MonitorCallback onMessageIngested(Message<?> message);  }