ConsulHealthCheck extends HealthCheck { @Override protected Result check() throws Exception { try { consul.agentClient().ping(); return Result.healthy(); } catch (ConsulException e) { LOGGER.warn("Unable to ping consul", e); } return Result.unhealthy("Could not ping consul"); } ConsulHealthCheck(final Consul consul);   }
@Test public void testCheckHealthy() throws Exception { final Result actual = healthCheck.check(); verify(agent).ping(); assertThat(actual.isHealthy()).isTrue(); }
@Test public void testCheckUnhealthy() throws Exception { doThrow(new ConsulException("error")).when(agent).ping(); final Result actual = healthCheck.check(); verify(agent).ping(); assertThat(actual.isHealthy()).isFalse(); }