### Question:
TotalHealthCheckGauge implements Gauge<Integer> { @Override public Integer getValue() { final SortedMap<String, HealthCheck.Result> results = registry.runHealthChecks(); return results.values().stream().allMatch(HealthCheck.Result::isHealthy) ? 1 : 0; } TotalHealthCheckGauge(final HealthCheckRegistry registry); @Override Integer getValue();  }### Answer:
@Test public void testAllHealthy() { final HealthCheckRegistry registry = new HealthCheckRegistry(); registry.register("pass1", stubHealthCheck(HealthCheck.Result.healthy())); registry.register("pass2", stubHealthCheck(HealthCheck.Result.healthy())); final TotalHealthCheckGauge gauge = new TotalHealthCheckGauge(registry); assertThat(gauge.getValue(), is(1)); }
@Test public void testOneFails() { final HealthCheckRegistry registry = new HealthCheckRegistry(); registry.register("pass1", stubHealthCheck(HealthCheck.Result.healthy())); registry.register("fail1", stubHealthCheck(HealthCheck.Result.unhealthy("error"))); final TotalHealthCheckGauge gauge = new TotalHealthCheckGauge(registry); assertThat(gauge.getValue(), is(0)); }
@Test public void testAllFail() { final HealthCheckRegistry registry = new HealthCheckRegistry(); registry.register("fail1", stubHealthCheck(HealthCheck.Result.unhealthy("error"))); registry.register("fail2", stubHealthCheck(HealthCheck.Result.unhealthy("error"))); final TotalHealthCheckGauge gauge = new TotalHealthCheckGauge(registry); assertThat(gauge.getValue(), is(0)); }