MetricsCollector { public void subscriptionCreated (Object destination) { metrics.getCounter(identifierPrefix, "subscriptions", String.valueOf(destination)).inc(); totalNumberOfSubscriptions.inc(); } MetricsCollector(Metrics metrics);   MetricsCollector(String identifier, Metrics metrics); void unparsableMessageReceived(Object destination); void messageReceived(Object destination); void subscriptionCreated(Object destination); void subscriptionDestroyed(Object destination);  }
@Test void subscriptionCreated() { sut.subscriptionCreated("destination2"); assertThat(metrics.getCounter("test", "messageReceiver", "subscriptions", "total").getCount(), is(1L)); assertThat(metrics.getCounter("test", "messageReceiver", "subscriptions", "destination2").getCount(), is(1L)); }
@Test void subscriptionCreatedCanBeInvokedWithNull() { sut.subscriptionCreated(null); assertThat(metrics.getCounter("test", "messageReceiver", "subscriptions", "total").getCount(), is(1L)); assertThat(metrics.getCounter("test", "messageReceiver", "subscriptions", "null").getCount(), is(1L)); }