ScheduledReporter implements Closeable, Reporter { public void start(long period, TimeUnit unit) { start(period, period, unit); } protected  ScheduledReporter(MetricRegistry registry,
                                String name,
                                MetricFilter filter,
                                TimeUnit rateUnit,
                                TimeUnit durationUnit); protected  ScheduledReporter(MetricRegistry registry,
                                String name,
                                MetricFilter filter,
                                TimeUnit rateUnit,
                                TimeUnit durationUnit,
                                ScheduledExecutorService executor); protected  ScheduledReporter(MetricRegistry registry,
                                String name,
                                MetricFilter filter,
                                TimeUnit rateUnit,
                                TimeUnit durationUnit,
                                ScheduledExecutorService executor,
                                boolean shutdownExecutorOnStop); protected  ScheduledReporter(MetricRegistry registry,
                                String name,
                                MetricFilter filter,
                                TimeUnit rateUnit,
                                TimeUnit durationUnit,
                                ScheduledExecutorService executor,
                                boolean shutdownExecutorOnStop,
                                Set<MetricAttribute> disabledMetricAttributes); void start(long period, TimeUnit unit); synchronized void start(long initialDelay, long period, TimeUnit unit); void stop(); @Override void close(); void report(); @SuppressWarnings("rawtypes") abstract void report(SortedMap<String, Gauge> gauges,
                                SortedMap<String, Counter> counters,
                                SortedMap<String, Histogram> histograms,
                                SortedMap<String, Meter> meters,
                                SortedMap<String, Timer> timers);  }
@Test public void shouldUsePeriodAsInitialDelayIfNotSpecifiedOtherwise() throws Exception { reporterWithCustomMockExecutor.start(200, TimeUnit.MILLISECONDS); verify(mockExecutor, times(1)).scheduleAtFixedRate( any(Runnable.class), eq(200L), eq(200L), eq(TimeUnit.MILLISECONDS) ); }
@Test public void shouldStartWithSpecifiedInitialDelay() throws Exception { reporterWithCustomMockExecutor.start(350, 100, TimeUnit.MILLISECONDS); verify(mockExecutor).scheduleAtFixedRate( any(Runnable.class), eq(350L), eq(100L), eq(TimeUnit.MILLISECONDS) ); }
@Test(expected = IllegalArgumentException.class) public void shouldDisallowToStartReportingMultiple() throws Exception { reporter.start(200, TimeUnit.MILLISECONDS); reporter.start(200, TimeUnit.MILLISECONDS); }
@Test(expected = IllegalArgumentException.class) public void shouldDisallowToStartReportingMultipleTimesOnCustomExecutor() throws Exception { reporterWithCustomExecutor.start(200, TimeUnit.MILLISECONDS); reporterWithCustomExecutor.start(200, TimeUnit.MILLISECONDS); }
@Test(expected = IllegalArgumentException.class) public void shouldDisallowToStartReportingMultipleTimesOnExternallyManagedExecutor() throws Exception { reporterWithExternallyManagedExecutor.start(200, TimeUnit.MILLISECONDS); reporterWithExternallyManagedExecutor.start(200, TimeUnit.MILLISECONDS); }