@Test
public void testHedgingWhenOneIsSlow() throws Exception {

  final ClientProtocol goodMock = Mockito.mock(ClientProtocol.class);
  Mockito.when(goodMock.getStats()).thenAnswer(new Answer<long[]>() {
    @Override
    public long[] answer(InvocationOnMock invocation) throws Throwable {
      Thread.sleep(1000);
      return new long[]{1};
    }
  });
  final ClientProtocol badMock = Mockito.mock(ClientProtocol.class);
  Mockito.when(badMock.getStats()).thenThrow(new IOException("Bad mock !!"));
  RequestHedgingProxyProvider<ClientProtocol> provider =
      new RequestHedgingProxyProvider<>(conf, nnUri, ClientProtocol.class,
          createFactory(goodMock, badMock));
  long[] stats = provider.getProxy().proxy.getStats();
  Assert.assertTrue(stats.length == 1);
  Assert.assertEquals(1, stats[0]);
  Mockito.verify(badMock).getStats();
  Mockito.verify(goodMock).getStats();
}