package io.dropwizard.discovery.health;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.api.ExistsBuilder;
import org.apache.curator.framework.imps.CuratorFrameworkState;
import org.apache.zookeeper.data.Stat;
import org.junit.Before;
import org.junit.Test;
import com.codahale.metrics.health.HealthCheck.Result;

public class CuratorHealthCheckTest {

    private final CuratorFramework framework = mock(CuratorFramework.class);
    private final ExistsBuilder exists = mock(ExistsBuilder.class);
    private final CuratorHealthCheck health = new CuratorHealthCheck(framework);

    @Before
    public void setUp() {
        when(framework.checkExists()).thenReturn(exists);
    }

    @Test
    public void testCheckHealthy() throws Exception {
        when(framework.getState()).thenReturn(CuratorFrameworkState.STARTED);
        when(exists.forPath(anyString())).thenReturn(new Stat());
        assertThat(health.check()).isEqualTo(Result.healthy());
    }

    @Test
    public void testCheckNotStarted() throws Exception {
        final Result expected = Result.unhealthy("Client not started");
        assertThat(health.check()).isEqualTo(expected);
    }

    @Test
    public void testCheckMissingRoot() throws Exception {
        when(framework.getState()).thenReturn(CuratorFrameworkState.STARTED);
        when(exists.forPath(anyString())).thenReturn(null);
        final Result expected = Result
                .unhealthy("Root for namespace does not exist");
        assertThat(health.check()).isEqualTo(expected);
    }
}

@@ -118,16 +118,24 @@
 mockito.
+Argument
 Matchers
@@ -146,16 +146,16 @@
 String;%0A
-
 import s
@@ -489,63 +489,8 @@
 est;
-%0Aimport com.codahale.metrics.health.HealthCheck.Result;
 %0A%0Apu
@@ -1101,36 +1101,29 @@
 ck()
-)
 .is
-EqualTo(Result.healthy()
+Healthy()).isTrue(
 );%0A 
@@ -1199,80 +1199,8 @@
 n %7B%0A
-        final Result expected = Result.unhealthy(%22Client not started%22);%0A
     
@@ -1228,36 +1228,38 @@
 .check()
-)
 .is
-EqualTo(expected
+Healthy()).isFalse(
 );%0A    %7D
@@ -1470,112 +1470,8 @@
 l);%0A
-        final Result expected = Result%0A                .unhealthy(%22Root for namespace does not exist%22);%0A
     
@@ -1503,28 +1503,30 @@
 ck()
-).isEqualTo(expected
+.isHealthy()).isFalse(
 );%0A 

Fix tests