package keywhiz.service.resources;

import com.codahale.metrics.health.HealthCheck;
import com.codahale.metrics.health.HealthCheckRegistry;
import io.dropwizard.setup.Environment;
import java.util.TreeMap;
import javax.ws.rs.InternalServerErrorException;
import org.junit.Before;
import org.junit.Test;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class StatusResponseTest {
  HealthCheckRegistry registry;
  Environment environment;
  StatusResource status;

  @Before
  public void setUp() throws Exception {
    this.registry = mock(HealthCheckRegistry.class);
    this.environment = mock(Environment.class);
    this.status = new StatusResource(environment);

    when(environment.healthChecks()).thenReturn(registry);
  }

  @Test
  public void testStatusOk() throws Exception {
    when(registry.runHealthChecks()).thenReturn(new TreeMap<>());
    status.get();
  }

  @Test(expected = InternalServerErrorException.class)
  public void testStatusWarn() throws Exception {
    TreeMap<String, HealthCheck.Result> map = new TreeMap<>();
    map.put("test", HealthCheck.Result.unhealthy("failing"));

    when(registry.runHealthChecks()).thenReturn(map);
    status.get();
  }
}
@@ -248,16 +248,50 @@
 eption;%0A
+import javax.ws.rs.core.Response;%0A
 import o
@@ -331,16 +331,74 @@
 .Test;%0A%0A
+import static org.assertj.core.api.Assertions.assertThat;%0A
 import s
@@ -978,24 +978,37 @@
 ap%3C%3E());%0A   
+ Response r =
  status.get(
@@ -1016,65 +1016,64 @@
 ;%0A  
-%7D%0A%0A  @Test(expected = InternalServerErrorException.class)
+  assertThat(r.getStatus()).isEqualTo(200);%0A  %7D%0A%0A  @Test
 %0A  p
@@ -1303,27 +1303,86 @@
 p);%0A    
-status.get(
+Response r = status.get();%0A    assertThat(r.getStatus()).isEqualTo(500
 );%0A  %7D%0A%7D

Fix tests to check status code, and not expect exception