use of com.google.api.gax.rpc.testing.FakeStreamingApi.ServerStreamingStashCallable in project gax-java by googleapis.
the class ServerStreamingCallableTest method testIteratedServerStreamingCallWithContext.
@Test
public void testIteratedServerStreamingCallWithContext() {
FakeChannel channel = new FakeChannel();
Credentials credentials = Mockito.mock(Credentials.class);
ApiCallContext context = FakeCallContext.createDefault().withChannel(channel).withCredentials(credentials);
ServerStreamingStashCallable<Integer, Integer> stashCallable = new ServerStreamingStashCallable<>();
ServerStreamingCallable<Integer, Integer> callable = stashCallable.withDefaultCallContext(FakeCallContext.createDefault());
Integer request = 1;
callable.call(request, context);
Truth.assertThat(stashCallable.getActualRequest()).isSameInstanceAs(request);
FakeCallContext actualContext = (FakeCallContext) stashCallable.getContext();
Truth.assertThat(actualContext.getChannel()).isSameInstanceAs(channel);
Truth.assertThat(actualContext.getCredentials()).isSameInstanceAs(credentials);
}
use of com.google.api.gax.rpc.testing.FakeStreamingApi.ServerStreamingStashCallable in project gax-java by googleapis.
the class ServerStreamingCallableTest method testServerStreamingCallWithContext.
@Test
public void testServerStreamingCallWithContext() {
FakeChannel channel = new FakeChannel();
Credentials credentials = Mockito.mock(Credentials.class);
ApiCallContext context = FakeCallContext.createDefault().withChannel(channel).withCredentials(credentials);
ServerStreamingStashCallable<Integer, Integer> stashCallable = new ServerStreamingStashCallable<>();
ServerStreamingCallable<Integer, Integer> callable = stashCallable.withDefaultCallContext(FakeCallContext.createDefault());
@SuppressWarnings("unchecked") ResponseObserver<Integer> observer = Mockito.mock(StateCheckingResponseObserver.class);
Integer request = 1;
callable.call(request, observer, context);
Truth.assertThat(stashCallable.getActualObserver()).isSameInstanceAs(observer);
Truth.assertThat(stashCallable.getActualRequest()).isSameInstanceAs(request);
FakeCallContext actualContext = (FakeCallContext) stashCallable.getContext();
Truth.assertThat(actualContext.getChannel()).isSameInstanceAs(channel);
Truth.assertThat(actualContext.getCredentials()).isSameInstanceAs(credentials);
}
use of com.google.api.gax.rpc.testing.FakeStreamingApi.ServerStreamingStashCallable in project gax-java by googleapis.
the class ServerStreamingCallableTest method testAllElementCallWithContext.
@Test
public void testAllElementCallWithContext() {
FakeChannel channel = new FakeChannel();
Credentials credentials = Mockito.mock(Credentials.class);
ApiCallContext context = FakeCallContext.createDefault().withChannel(channel).withCredentials(credentials);
ServerStreamingStashCallable<Integer, Integer> stashCallable = new ServerStreamingStashCallable<>();
UnaryCallable<Integer, List<Integer>> firstCallable = stashCallable.all().withDefaultCallContext(FakeCallContext.createDefault());
Integer request = 1;
firstCallable.call(request, context);
Truth.assertThat(stashCallable.getActualRequest()).isSameInstanceAs(request);
FakeCallContext actualContext = (FakeCallContext) stashCallable.getContext();
Truth.assertThat(actualContext.getChannel()).isSameInstanceAs(channel);
Truth.assertThat(actualContext.getCredentials()).isSameInstanceAs(credentials);
}
use of com.google.api.gax.rpc.testing.FakeStreamingApi.ServerStreamingStashCallable in project gax-java by googleapis.
the class ServerStreamingCallableTest method testFirstElementCallWithContext.
@Test
public void testFirstElementCallWithContext() {
FakeChannel channel = new FakeChannel();
Credentials credentials = Mockito.mock(Credentials.class);
ApiCallContext context = FakeCallContext.createDefault().withChannel(channel).withCredentials(credentials);
ServerStreamingStashCallable<Integer, Integer> stashCallable = new ServerStreamingStashCallable<>();
UnaryCallable<Integer, Integer> firstCallable = stashCallable.first().withDefaultCallContext(FakeCallContext.createDefault());
Integer request = 1;
firstCallable.call(request, context);
Truth.assertThat(stashCallable.getActualRequest()).isSameInstanceAs(request);
FakeCallContext actualContext = (FakeCallContext) stashCallable.getContext();
Truth.assertThat(actualContext.getChannel()).isSameInstanceAs(channel);
Truth.assertThat(actualContext.getCredentials()).isSameInstanceAs(credentials);
}
Aggregations