Search in sources :

Example 1 with ClientStreamingStashCallable

use of com.google.api.gax.rpc.testing.FakeStreamingApi.ClientStreamingStashCallable in project gax-java by googleapis.

the class StreamingCallableTest method testClientStreamingCallWithContext.

@Test
@SuppressWarnings("unchecked")
public void testClientStreamingCallWithContext() {
    FakeChannel channel = new FakeChannel();
    Credentials credentials = Mockito.mock(Credentials.class);
    RetrySettings retrySettings = Mockito.mock(RetrySettings.class);
    Set<StatusCode.Code> retryableCodes = ImmutableSet.of(StatusCode.Code.INTERNAL, StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED);
    ApiCallContext context = FakeCallContext.createDefault().withChannel(channel).withCredentials(credentials).withRetrySettings(retrySettings).withRetryableCodes(retryableCodes);
    ClientStreamingStashCallable<Integer, Integer> stashCallable = new ClientStreamingStashCallable<>();
    ApiStreamObserver<Integer> observer = Mockito.mock(ApiStreamObserver.class);
    ClientStreamingCallable<Integer, Integer> callable = stashCallable.withDefaultCallContext(FakeCallContext.createDefault());
    callable.clientStreamingCall(observer, context);
    assertSame(observer, stashCallable.getActualObserver());
    FakeCallContext actualContext = (FakeCallContext) stashCallable.getContext();
    assertSame(channel, actualContext.getChannel());
    assertSame(credentials, actualContext.getCredentials());
    assertSame(retrySettings, actualContext.getRetrySettings());
    assertSame(retryableCodes, actualContext.getRetryableCodes());
}
Also used : ClientStreamingStashCallable(com.google.api.gax.rpc.testing.FakeStreamingApi.ClientStreamingStashCallable) RetrySettings(com.google.api.gax.retrying.RetrySettings) FakeCallContext(com.google.api.gax.rpc.testing.FakeCallContext) FakeStatusCode(com.google.api.gax.rpc.testing.FakeStatusCode) Code(com.google.api.gax.rpc.StatusCode.Code) Credentials(com.google.auth.Credentials) FakeChannel(com.google.api.gax.rpc.testing.FakeChannel) Test(org.junit.Test)

Aggregations

RetrySettings (com.google.api.gax.retrying.RetrySettings)1 Code (com.google.api.gax.rpc.StatusCode.Code)1 FakeCallContext (com.google.api.gax.rpc.testing.FakeCallContext)1 FakeChannel (com.google.api.gax.rpc.testing.FakeChannel)1 FakeStatusCode (com.google.api.gax.rpc.testing.FakeStatusCode)1 ClientStreamingStashCallable (com.google.api.gax.rpc.testing.FakeStreamingApi.ClientStreamingStashCallable)1 Credentials (com.google.auth.Credentials)1 Test (org.junit.Test)1