@Test
public void testTimeoutToDeadlineConversion() {

  MethodDescriptor<Color, Money> descriptor = FakeServiceGrpc.METHOD_RECOGNIZE;
  @SuppressWarnings("unchecked")
  ClientCall<Color, Money> mockClientCall = Mockito.mock(ClientCall.class);
  @SuppressWarnings("unchecked")
  ClientCall.Listener<Money> mockListener = Mockito.mock(ClientCall.Listener.class);
  @SuppressWarnings("unchecked")
  Channel mockChannel = Mockito.mock(ManagedChannel.class);
  ArgumentCaptor<CallOptions> capturedCallOptions = ArgumentCaptor.forClass(CallOptions.class);
  Mockito.when(mockChannel.newCall(Mockito.eq(descriptor), capturedCallOptions.capture()))
      .thenReturn(mockClientCall);
  Duration timeout = Duration.ofSeconds(10);
  Deadline minExpectedDeadline = Deadline.after(timeout.getSeconds(), TimeUnit.SECONDS);
  GrpcCallContext context =
      GrpcCallContext.createDefault().withChannel(mockChannel).withTimeout(timeout);
  GrpcClientCalls.newCall(descriptor, context).start(mockListener, new Metadata());
  Deadline maxExpectedDeadline = Deadline.after(timeout.getSeconds(), TimeUnit.SECONDS);
  Truth.assertThat(capturedCallOptions.getValue().getDeadline()).isAtLeast(minExpectedDeadline);
  Truth.assertThat(capturedCallOptions.getValue().getDeadline()).isAtMost(maxExpectedDeadline);
}