// Path: core/src/main/java/com/bazaarvoice/ostrich/HealthCheckResults.java
// public interface HealthCheckResults {
//     /**
//      * @return {@code true} if there is a healthy result, {@code false} otherwise.
//      */
//     boolean hasHealthyResult();
// 
//     /**
//      * @return All results in the aggregate, regardless of health.
//      */
//     Iterable<HealthCheckResult> getAllResults();
// 
//     /**
//      * Returns a healthy result if {@link #hasHealthyResult} is {@code true}. Returns {@code null} when
//      * {@code hasHealthyResult} is false. If there are multiple healthy results, there is no guarantee as to which gets
//      * returned.
//      * @return A result in the aggregate whose {@link HealthCheckResult#isHealthy} method returns {@code true}, or
//      * {@code null} if there are none.
//      */
//     HealthCheckResult getHealthyResult();
// 
//     /**
//      * @return Results in the aggregate whose {@link HealthCheckResult#isHealthy} method returns {@code false}.
//      */
//     Iterable<HealthCheckResult> getUnhealthyResults();
// }


import com.bazaarvoice.ostrich.HealthCheckResults;
import com.bazaarvoice.ostrich.RetryPolicy;
import com.bazaarvoice.ostrich.ServicePool;
import com.google.common.reflect.Reflection;
import org.junit.Test;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
        when(pool.checkForHealthyEndPoint()).thenReturn(results);
        Service service = ServicePoolProxy.create(Service.class, mock(RetryPolicy.class), pool,
                mock(PartitionContextSupplier.class), true);

        assertSame(results, ServicePoolProxies.checkForHealthyEndPoint(service));
    }

    @Test(expected = NullPointerException.class)
    public void testGetPoolNullProxy() {
        ServicePoolProxies.getPool(null);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testGetPoolNonServicePoolProxy() {
        ServicePoolProxies.getPool(Reflection.newProxy(Service.class, mock(InvocationHandler.class)));
    }

    @SuppressWarnings("unchecked")
    @Test
    public void testGetPool() {
        ServicePool<Service> pool = mock(ServicePool.class);
        Service service = ServicePoolProxy.create(Service.class, mock(RetryPolicy.class), pool,
                mock(PartitionContextSupplier.class), true);

        assertSame(pool, ServicePoolProxies.getPool(service));
    }

    @SuppressWarnings("unchecked")
    @Test
    public void testGetValidEndPointCount() {
// Path: core/src/main/java/com/bazaarvoice/ostrich/HealthCheckResults.java
// public interface HealthCheckResults {
//     /**
//      * @return {@code true} if there is a healthy result, {@code false} otherwise.
//      */
//     boolean hasHealthyResult();
// 
//     /**
//      * @return All results in the aggregate, regardless of health.
//      */
//     Iterable<HealthCheckResult> getAllResults();
// 
//     /**
//      * Returns a healthy result if {@link #hasHealthyResult} is {@code true}. Returns {@code null} when
//      * {@code hasHealthyResult} is false. If there are multiple healthy results, there is no guarantee as to which gets
//      * returned.
//      * @return A result in the aggregate whose {@link HealthCheckResult#isHealthy} method returns {@code true}, or
//      * {@code null} if there are none.
//      */
//     HealthCheckResult getHealthyResult();
// 
//     /**
//      * @return Results in the aggregate whose {@link HealthCheckResult#isHealthy} method returns {@code false}.
//      */
//     Iterable<HealthCheckResult> getUnhealthyResults();
// }


// Path: core/src/test/java/com/bazaarvoice/ostrich/pool/ServicePoolProxiesTest.java
import com.bazaarvoice.ostrich.HealthCheckResults;
import com.bazaarvoice.ostrich.RetryPolicy;
import com.bazaarvoice.ostrich.ServicePool;
import com.google.common.reflect.Reflection;
import org.junit.Test;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

        when(pool.checkForHealthyEndPoint()).thenReturn(results);
        Service service = ServicePoolProxy.create(Service.class, mock(RetryPolicy.class), pool,
                mock(PartitionContextSupplier.class), true);

        assertSame(results, ServicePoolProxies.checkForHealthyEndPoint(service));
    }

    @Test(expected = NullPointerException.class)
    public void testGetPoolNullProxy() {
        ServicePoolProxies.getPool(null);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testGetPoolNonServicePoolProxy() {
        ServicePoolProxies.getPool(Reflection.newProxy(Service.class, mock(InvocationHandler.class)));
    }

    @SuppressWarnings("unchecked")
    @Test
    public void testGetPool() {
        ServicePool<Service> pool = mock(ServicePool.class);
        Service service = ServicePoolProxy.create(Service.class, mock(RetryPolicy.class), pool,
                mock(PartitionContextSupplier.class), true);

        assertSame(pool, ServicePoolProxies.getPool(service));
    }

    @SuppressWarnings("unchecked")
    @Test
    public void testGetValidEndPointCount() {
        ServicePool<Service> pool = mock(ServicePool.class);