use of com.google.pubsub.v1.GetSubscriptionRequest in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method getSubscriptionTest.
@Test
@SuppressWarnings("all")
public void getSubscriptionTest() {
SubscriptionName name = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
TopicNameOneof topic = TopicNameOneof.from(TopicName.create("[PROJECT]", "[TOPIC]"));
int ackDeadlineSeconds = 2135351438;
boolean retainAckedMessages = false;
Subscription expectedResponse = Subscription.newBuilder().setNameWithSubscriptionName(name).setTopicWithTopicNameOneof(topic).setAckDeadlineSeconds(ackDeadlineSeconds).setRetainAckedMessages(retainAckedMessages).build();
mockSubscriber.addResponse(expectedResponse);
SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
Subscription actualResponse = client.getSubscription(subscription);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetSubscriptionRequest actualRequest = (GetSubscriptionRequest) actualRequests.get(0);
Assert.assertEquals(subscription, actualRequest.getSubscriptionAsSubscriptionName());
}
use of com.google.pubsub.v1.GetSubscriptionRequest in project beam by apache.
the class PubsubGrpcClient method ackDeadlineSeconds.
@Override
public int ackDeadlineSeconds(SubscriptionPath subscription) throws IOException {
GetSubscriptionRequest request = GetSubscriptionRequest.newBuilder().setSubscription(subscription.getPath()).build();
Subscription response = subscriberStub().getSubscription(request);
return response.getAckDeadlineSeconds();
}
Aggregations