AnnouncerImpl implements Announcer { @Override public void start() { checkState(!executor.isShutdown(), "Announcer has been destroyed"); if (started.compareAndSet(false, true)) { announce(); } } @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 testBasic() { assertAnnounced(); announcer.start(); assertAnnounced(serviceAnnouncement); }
@Test public void idempotentStart() { announcer.start(); announcer.start(); announcer.start(); }