HealthCheckRegistry { public void register(String name, HealthCheck healthCheck) { HealthCheck registered; synchronized (lock) { if (healthChecks.containsKey(name)) { throw new IllegalArgumentException("A health check named " + name + " already exists"); } registered = healthCheck; if (healthCheck.getClass().isAnnotationPresent(Async.class)) { registered = new AsyncHealthCheckDecorator(healthCheck, asyncExecutorService); } healthChecks.put(name, registered); } onHealthCheckAdded(name, registered); } HealthCheckRegistry();  HealthCheckRegistry(int asyncExecutorPoolSize);  HealthCheckRegistry(ScheduledExecutorService asyncExecutorService); void addListener(HealthCheckRegistryListener listener); void removeListener(HealthCheckRegistryListener listener); void register(String name, HealthCheck healthCheck); void unregister(String name); SortedSet<String> getNames(); HealthCheck getHealthCheck(String name); HealthCheck.Result runHealthCheck(String name); SortedMap<String, HealthCheck.Result> runHealthChecks(); SortedMap<String, HealthCheck.Result> runHealthChecks(HealthCheckFilter filter); SortedMap<String, HealthCheck.Result> runHealthChecks(ExecutorService executor); SortedMap<String, HealthCheck.Result> runHealthChecks(ExecutorService executor, HealthCheckFilter filter); void shutdown();  }
@Test(expected = IllegalArgumentException.class) public void registeringHealthCheckTwiceThrowsException() { registry.register("hc1", hc1); }