Refactor HealthCheckTest
This commit is contained in:
parent
5c99b291d5
commit
e17dd32c49
|
@ -1,16 +1,18 @@
|
|||
package com.baeldung.metrics.healthchecks;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.codahale.metrics.health.HealthCheck;
|
||||
import com.codahale.metrics.health.HealthCheckRegistry;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class HealthCheckTest {
|
||||
|
||||
@Test
|
||||
public void whenUseHealthCheck_thenHealthChecked() {
|
||||
HealthCheckRegistry healthCheckRegistry = new HealthCheckRegistry();
|
||||
|
@ -21,9 +23,8 @@ public class HealthCheckTest {
|
|||
assertThat(healthCheckRegistry.getNames().size(), equalTo(2));
|
||||
|
||||
Map<String, HealthCheck.Result> results = healthCheckRegistry.runHealthChecks();
|
||||
for (Map.Entry<String, HealthCheck.Result> entry : results.entrySet()) {
|
||||
assertThat(entry.getValue().isHealthy(), equalTo(true));
|
||||
}
|
||||
assertFalse(results.isEmpty());
|
||||
results.forEach((k, v) -> assertTrue(v.isHealthy()));
|
||||
|
||||
healthCheckRegistry.unregister("uc");
|
||||
assertThat(healthCheckRegistry.getNames().size(), equalTo(1));
|
||||
|
|
Loading…
Reference in New Issue