@Test
public void createServerStreamingCallableRetryableExceptions() throws Exception {

  GrpcCallSettings<Color, Money> grpcCallSettings =
      GrpcCallSettings.create(FakeServiceGrpc.METHOD_STREAMING_RECOGNIZE_ERROR);
  // Base case: without config, invalid argument errors are not retryable.
  ServerStreamingCallSettings<Color, Money> nonRetryableSettings =
      ServerStreamingCallSettings.<Color, Money>newBuilder()
          .setRetrySettings(
              RetrySettings.newBuilder()
                  .setTotalTimeout(Duration.ofSeconds(1))
                  .setMaxAttempts(1)
                  .build())
          .build();
  ServerStreamingCallable<Color, Money> nonRetryableCallable =
      GrpcCallableFactory.createServerStreamingCallable(
          grpcCallSettings, nonRetryableSettings, clientContext);
  Throwable actualError = null;
  try {
    nonRetryableCallable
        .first()
        .call(Color.getDefaultInstance(), clientContext.getDefaultCallContext());
  } catch (Throwable e) {
    actualError = e;
  }
  assertThat(actualError).isInstanceOf(InvalidArgumentException.class);
  assertThat(((InvalidArgumentException) actualError).isRetryable()).isFalse();
  // Actual test: with config, invalid argument errors are retryable.
  ServerStreamingCallSettings<Color, Money> retryableSettings =
      ServerStreamingCallSettings.<Color, Money>newBuilder()
          .setRetryableCodes(Code.INVALID_ARGUMENT)
          .setRetrySettings(
              RetrySettings.newBuilder()
                  .setTotalTimeout(Duration.ofSeconds(1))
                  .setMaxAttempts(1)
                  .build())
          .build();
  ServerStreamingCallable<Color, Money> retryableCallable =
      GrpcCallableFactory.createServerStreamingCallable(
          grpcCallSettings, retryableSettings, clientContext);
  Throwable actualError2 = null;
  try {
    retryableCallable
        .first()
        .call(Color.getDefaultInstance(), clientContext.getDefaultCallContext());
  } catch (Throwable e) {
    actualError2 = e;
  }
  assertThat(actualError2).isInstanceOf(InvalidArgumentException.class);
  assertThat(((InvalidArgumentException) actualError2).isRetryable()).isTrue();
}