AnnouncerImpl implements Announcer { @Override @StopTraffic public void destroy() { executor.shutdownNow(); try { executor.awaitTermination(30, SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } if (!started.get()) { return; } try { getFutureValue(announcementClient.unannounce(), DiscoveryException.class); } catch (DiscoveryException e) { if (e.getCause() instanceof ConnectException) { log.error("Cannot connect to discovery server for unannounce: %s", e.getCause().getMessage()); } else { log.error(e); } } } @Inject  AnnouncerImpl(DiscoveryAnnouncementClient announcementClient, Set<ServiceAnnouncement> serviceAnnouncements); @Override void start(); @Override void startIfNotKubernetes(); @Override @StopTraffic void destroy(); @Override void addServiceAnnouncement(ServiceAnnouncement serviceAnnouncement); @Override void removeServiceAnnouncement(UUID serviceId); @Override ListenableFuture<?> forceAnnounce();  }
@Test public void destroyNoStart() { discoveryClient = spy(discoveryClient); announcer = new AnnouncerImpl(discoveryClient, ImmutableSet.of(serviceAnnouncement)); announcer.destroy(); verifyNoMoreInteractions(discoveryClient); }