@Test
public void testCallRetriesAndFailsWithSocketErrors() throws Exception {

  MockSleeper sleeper = new MockSleeper();
  ArrayList<IOException> exceptions = new ArrayList<>();
  exceptions.add(new SocketTimeoutException("socket"));
  exceptions.add(new SocketTimeoutException("socket"));
  exceptions.add(new IOException("FakeException"));
  CallableTester<IOException> callTester = new CallableTester<>(exceptions);
  BackOff backoff = new RetryBoundedBackOff(5, new BackOffTester());
  IOException thrown =
      assertThrows(
          IOException.class,
          () ->
              ResilientOperation.retry(
                  callTester,
                  backoff,
                  RetryDeterminer.SOCKET_ERRORS,
                  IOException.class,
                  sleeper));
  assertThat(thrown).hasMessageThat().contains("FakeException");
  assertThat(callTester.timesCalled()).isEqualTo(3);
  verifySleeper(sleeper, 2);
}