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());
}
Aggregations