Search in sources :

Example 1 with GetSubscriptionRequest

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());
}
Also used : TopicNameOneof(com.google.pubsub.v1.TopicNameOneof) GetSubscriptionRequest(com.google.pubsub.v1.GetSubscriptionRequest) SubscriptionName(com.google.pubsub.v1.SubscriptionName) Subscription(com.google.pubsub.v1.Subscription) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 2 with GetSubscriptionRequest

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();
}
Also used : GetSubscriptionRequest(com.google.pubsub.v1.GetSubscriptionRequest) Subscription(com.google.pubsub.v1.Subscription)

Aggregations

GetSubscriptionRequest (com.google.pubsub.v1.GetSubscriptionRequest)2 Subscription (com.google.pubsub.v1.Subscription)2 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 SubscriptionName (com.google.pubsub.v1.SubscriptionName)1 TopicNameOneof (com.google.pubsub.v1.TopicNameOneof)1 Test (org.junit.Test)1