@Test
public void reportsUnhealthy() throws Exception {

  Connection connection;
  try (Connection c = dataSource.getConnection()) {
    connection = c;
  }
  when(managedDataSource.getConnection()).thenReturn(connection);
  JooqHealthCheck healthCheck = new JooqHealthCheck(managedDataSource, RETURN_UNHEALTHY);
  HealthCheck.Result result = healthCheck.check();
  assertThat(result.isHealthy()).isFalse();
  assertThat(result.getMessage()).isEqualTo("Unhealthy connection to database.");
}