use of com.google.api.gax.grpc.testing.MockStreamObserver in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method streamingPullTest.
@Test
@SuppressWarnings("all")
public void streamingPullTest() throws Exception {
StreamingPullResponse expectedResponse = StreamingPullResponse.newBuilder().build();
mockSubscriber.addResponse(expectedResponse);
SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
int streamAckDeadlineSeconds = 1875467245;
StreamingPullRequest request = StreamingPullRequest.newBuilder().setSubscriptionWithSubscriptionName(subscription).setStreamAckDeadlineSeconds(streamAckDeadlineSeconds).build();
MockStreamObserver<StreamingPullResponse> responseObserver = new MockStreamObserver<>();
StreamingCallable<StreamingPullRequest, StreamingPullResponse> callable = client.streamingPullCallable();
ApiStreamObserver<StreamingPullRequest> requestObserver = callable.bidiStreamingCall(responseObserver);
requestObserver.onNext(request);
requestObserver.onCompleted();
List<StreamingPullResponse> actualResponses = responseObserver.future().get();
Assert.assertEquals(1, actualResponses.size());
Assert.assertEquals(expectedResponse, actualResponses.get(0));
}
Aggregations