MBeanStatsMonitor implements StatisticsListener { public Number getStatistic(final String statName) { Number value = statsMap.getOrDefault(statName, 0); return value != null ? value : 0; } MBeanStatsMonitor(final String name);   MBeanStatsMonitor(final String name, final ValueMonitor monitor); void addStatisticsToMonitor(final Statistics stats); void removeStatisticsFromMonitor(final Statistics stats); void stopListener(); Number getStatistic(final String statName); @Override void handleNotification(final StatisticsNotification notification);  }
@Test public void getStatisticShouldReturnZeroWhenRequestedStatisticDoesNotExist() { assertThat(mbeanStatsMonitor.getStatistic("unknownStatistic")).isNotNull().isEqualTo(0); }