DependencyPinger implements Dependency, StatusUpdateProducer, Runnable { @Override public Iterator<StatusUpdateListener> listeners() { return updateHandler.listeners(); } DependencyPinger(@Nonnull final Dependency dependency);   DependencyPinger(
            @Nonnull final Dependency dependency,
            @Nonnull final SystemReporter systemReporter
    );   DependencyPinger(
            @Nonnull final Dependency dependency,
            @Nonnull final DependencyChecker checker
    );   DependencyPinger(
            @Nonnull final ExecutorService executorService,
            @Nonnull final Dependency dependency,
            @Nonnull final SystemReporter systemReporter
    );   DependencyPinger(
            @Nonnull final ExecutorService executorService,
            @Nonnull final Dependency dependency,
            final long pingPeriod,
            @Nonnull final SystemReporter systemReporter
    );   DependencyPinger(
            @Nonnull final Dependency dependency,
            final long pingPeriod,
            @Nonnull final DependencyChecker dependencyChecker
    ); @Override void run(); @Override @Nonnull CheckResult call(); @Nonnull @Override String toString(); @Export(name = "total-failures") long getTotalFailures(); @Export(name = "total-successes") long getTotalSuccesses(); @Export(name = "failures", doc = "Rolling count of recent failures") String getFailures(); @Export(name = "consecutive-failures", doc = "Number of times failed consecutively") int getConsecutiveFailures(); @Override long getPingPeriod(); @Override String getId(); @Override String getDescription(); @Override String getDocumentationUrl(); @Override long getTimeout(); @Override Urgency getUrgency(); @Override DependencyType getType(); @Override String getServicePool(); @Override void clear(); @Override void addListener(final StatusUpdateListener listener); @Override Iterator<StatusUpdateListener> listeners(); @Nonnull Dependency getDependency();  }
@Test public void testListeners() { final StatusUpdateListener listener1 = EasyMock.createMock(StatusUpdateListener.class); final StatusUpdateListener listener2 = EasyMock.createMock(StatusUpdateListener.class); final StatusUpdateListener listener3 = EasyMock.createMock(StatusUpdateListener.class); final ControlledDependency dependency = ControlledDependency.build(); dependency.setInError(true); final DependencyPinger pinger = new DependencyPinger(MoreExecutors.newDirectExecutorService(), dependency, systemReporter); pinger.addListener(listener1); pinger.addListener(listener2); pinger.addListener(listener3); final Iterator<StatusUpdateListener> actual = pinger.listeners(); assertEquals(ImmutableList.of(listener1, listener2, listener3), Arrays.asList(Iterators.toArray(actual, StatusUpdateListener.class))); for (final Iterator<StatusUpdateListener> it = pinger.listeners(); it.hasNext() ; it.next()) { pinger.addListener(EasyMock.createMock(StatusUpdateListener.class)); } }