@Test public void retryableCallClone() throws InterruptedException {

  RetryableCalls retryableCalls = new RetryableCalls();
  MockWebServer server = new MockWebServer();
  Retrofit retrofit = new Retrofit.Builder()
      .baseUrl(server.url("/"))
      .addCallAdapterFactory(retryableCalls.getFactory())
      .addConverterFactory(new ToStringConverterFactory())
      .build();
  Service service = retrofit.create(Service.class);
  final CountDownLatch callLatch = new CountDownLatch(1);
  server.enqueue(new MockResponse().setBody("Hi"));
  RetryableCall<String> call = service.getString();
  call.enqueue(new RetryableCallback<String>() {
    @Override public void onResponse(RetryableCall<String> call, Response<String> response) {
      callLatch.countDown();
    }
    @Override public void onFailure(RetryableCall<String> call, Throwable t) {
      throw new AssertionError();
    }
    @Override public void onFailureButCanRetry(RetryableCall<String> call, IOException e) {
      throw new AssertionError();
    }
  });
  assertThat(callLatch.await(10, SECONDS)).isTrue();
  RetryableCall<String> clone = call.clone();
  assertThat(clone).isNotSameAs(call);
  assertThat(clone.isExecuted()).isFalse();
  final CountDownLatch cloneLatch = new CountDownLatch(1);
  server.enqueue(new MockResponse().setBody("Hi"));
  clone.enqueue(new RetryableCallback<String>() {
    @Override public void onResponse(RetryableCall<String> call, Response<String> response) {
      cloneLatch.countDown();
    }
    @Override public void onFailure(RetryableCall<String> call, Throwable t) {
      throw new AssertionError();
    }
    @Override public void onFailureButCanRetry(RetryableCall<String> call, IOException e) {
      throw new AssertionError();
    }
  });
  assertThat(cloneLatch.await(10, SECONDS)).isTrue();
}