@Test
public void constructorWithRegistryAsArgumentUsesServletConfigWhenNull() throws Exception {

    final HealthCheckRegistry healthCheckRegistry = mock(HealthCheckRegistry.class);
    final ServletContext servletContext = mock(ServletContext.class);
    final ServletConfig servletConfig = mock(ServletConfig.class);
    when(servletConfig.getServletContext()).thenReturn(servletContext);
    when(servletContext.getAttribute(eq(HealthCheckServlet.HEALTH_CHECK_REGISTRY)))
            .thenReturn(healthCheckRegistry);
    final HealthCheckServlet healthCheckServlet = new HealthCheckServlet(null);
    healthCheckServlet.init(servletConfig);
    verify(servletConfig, times(1)).getServletContext();
    verify(servletContext, times(1)).getAttribute(eq(HealthCheckServlet.HEALTH_CHECK_REGISTRY));
}