@Test
public void testUserProvidedContextTimeout() {

  // Mock up the ApiCallContext as if the user provided a timeout and streamWaitTimeout.
  Mockito.doReturn(NoopApiTracer.getInstance()).when(mockedCallContext).getTracer();
  Mockito.doReturn(Duration.ofHours(5)).when(mockedCallContext).getTimeout();
  Mockito.doReturn(Duration.ofHours(5)).when(mockedCallContext).getStreamWaitTimeout();
  ServerStreamingAttemptCallable<String, String> callable = createCallable(mockedCallContext);
  callable.start();
  // Ensure that the callable did not overwrite the user provided timeouts
  Mockito.verify(mockedCallContext, Mockito.times(1)).getTimeout();
  Mockito.verify(mockedCallContext, Mockito.never()).withTimeout(totalTimeout);
  Mockito.verify(mockedCallContext, Mockito.times(1)).getStreamWaitTimeout();
  Mockito.verify(mockedCallContext, Mockito.never())
      .withStreamWaitTimeout(Mockito.any(Duration.class));
  // Should notify outer observer
  Truth.assertThat(observer.controller).isNotNull();
  // Should configure the inner controller correctly.
  MockServerStreamingCall<String, String> call = innerCallable.popLastCall();
  Truth.assertThat(call.getController().isAutoFlowControlEnabled()).isTrue();
  Truth.assertThat(call.getRequest()).isEqualTo("request");
  // Send a response in auto flow mode.
  call.getController().getObserver().onResponse("response1");
  call.getController().getObserver().onResponse("response2");
  call.getController().getObserver().onComplete();
  // Make sure the responses are received
  Truth.assertThat(observer.responses).containsExactly("response1", "response2").inOrder();
  fakeRetryingFuture.assertSuccess();
}