@Test public void checkServerConfShouldReturnNotOkWhenServerConfThrows() { ServerConfProvider mockProvider = mock(ServerConfProvider.class); when(mockProvider.getIdentifier()).thenThrow(new RuntimeException("broken conf!")); ServerConf.reload(mockProvider); HealthCheckProvider testedProvider = HealthChecks.checkServerConfDatabaseStatus(); HealthCheckResult checkedResult = testedProvider.get(); assertTrue("health check result should be a failure", !checkedResult.isOk()); assertThat(checkedResult.getErrorMessage(), containsString("Server Conf database did not respond as expected")); }
public static HealthCheckProvider checkServerConfDatabaseStatus() { return () -> { try { ServerConf.getIdentifier(); } catch (RuntimeException e) { log.error("Got exception while checking server configuration db status", e); return failure("Server Conf database did not respond as expected"); } return OK; }; }
HealthChecks { public static HealthCheckProvider checkServerConfDatabaseStatus() { return () -> { try { ServerConf.getIdentifier(); } catch (RuntimeException e) { log.error("Got exception while checking server configuration db status", e); return failure("Server Conf database did not respond as expected"); } return OK; }; } }
HealthChecks { public static HealthCheckProvider checkServerConfDatabaseStatus() { return () -> { try { ServerConf.getIdentifier(); } catch (RuntimeException e) { log.error("Got exception while checking server configuration db status", e); return failure("Server Conf database did not respond as expected"); } return OK; }; } private  HealthChecks(); }
HealthChecks { public static HealthCheckProvider checkServerConfDatabaseStatus() { return () -> { try { ServerConf.getIdentifier(); } catch (RuntimeException e) { log.error("Got exception while checking server configuration db status", e); return failure("Server Conf database did not respond as expected"); } return OK; }; } private  HealthChecks(); static HealthCheckProvider checkAuthKeyOcspStatus(); static HealthCheckProvider checkServerConfDatabaseStatus(); static Function<HealthCheckProvider, HealthCheckProvider> cacheResultFor(
            int resultValidFor, int errorResultValidFor, TimeUnit timeUnit); static HealthCheckProvider cacheResultOnce(HealthCheckProvider provider,
                                                      HealthCheckResult cachedOnceResult); }
HealthChecks { public static HealthCheckProvider checkServerConfDatabaseStatus() { return () -> { try { ServerConf.getIdentifier(); } catch (RuntimeException e) { log.error("Got exception while checking server configuration db status", e); return failure("Server Conf database did not respond as expected"); } return OK; }; } private  HealthChecks(); static HealthCheckProvider checkAuthKeyOcspStatus(); static HealthCheckProvider checkServerConfDatabaseStatus(); static Function<HealthCheckProvider, HealthCheckProvider> cacheResultFor(
            int resultValidFor, int errorResultValidFor, TimeUnit timeUnit); static HealthCheckProvider cacheResultOnce(HealthCheckProvider provider,
                                                      HealthCheckResult cachedOnceResult);  }