### Question:
HealthHandler implements HealthService.Iface { @Override public Health getHealth() { return handler.getHealth(); } HealthHandler(); @Override Health getHealth();  }### Answer:
@Test public void testGetHealthFailsUponMissingDB() throws MalformedURLException { TestUtils.deleteAllDatabases(); HealthHandler healthHandler = new HealthHandler(); final Health health = healthHandler.getHealth(); assertEquals(Status.DOWN, health.status); assertEquals(HealthDatabaseHandler.DATABASES_TO_CHECK.size(), health.getDetails().size()); }
@Test public void testGetHealth() throws MalformedURLException { for (String database : HealthDatabaseHandler.DATABASES_TO_CHECK) { TestUtils.createDatabase(DatabaseSettings.getConfiguredHttpClient(), database); } HealthHandler healthHandler = new HealthHandler(); final Health health = healthHandler.getHealth(); assertEquals(Status.UP, health.status); assertEquals(new HashMap<>(), health.getDetails()); for (String database : HealthDatabaseHandler.DATABASES_TO_CHECK) { TestUtils.deleteDatabase(DatabaseSettings.getConfiguredHttpClient(), database); } }
@Test public void testGetHealthWithPartialDBMissing() throws MalformedURLException { final String couchDbDatabase = DatabaseSettings.COUCH_DB_DATABASE; TestUtils.createDatabase(DatabaseSettings.getConfiguredHttpClient(), couchDbDatabase); HealthHandler healthHandler = new HealthHandler(); final Health health = healthHandler.getHealth(); assertEquals(Status.ERROR, health.getStatus()); assertEquals(HealthDatabaseHandler.DATABASES_TO_CHECK.size() -1, health.getDetails().size()); TestUtils.deleteDatabase(DatabaseSettings.getConfiguredHttpClient(), couchDbDatabase); }