Search in sources :

Example 1 with TopicNameOneof

use of com.google.pubsub.v1.TopicNameOneof in project google-cloud-java by GoogleCloudPlatform.

the class SubscriptionAdminClientTest method createSubscriptionTest.

@Test
@SuppressWarnings("all")
public void createSubscriptionTest() {
    SubscriptionName name2 = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
    TopicNameOneof topic2 = TopicNameOneof.from(TopicName.create("[PROJECT]", "[TOPIC]"));
    int ackDeadlineSeconds2 = -921632575;
    boolean retainAckedMessages = false;
    Subscription expectedResponse = Subscription.newBuilder().setNameWithSubscriptionName(name2).setTopicWithTopicNameOneof(topic2).setAckDeadlineSeconds(ackDeadlineSeconds2).setRetainAckedMessages(retainAckedMessages).build();
    mockSubscriber.addResponse(expectedResponse);
    SubscriptionName name = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
    TopicName topic = TopicName.create("[PROJECT]", "[TOPIC]");
    PushConfig pushConfig = PushConfig.newBuilder().build();
    int ackDeadlineSeconds = 2135351438;
    Subscription actualResponse = client.createSubscription(name, topic, pushConfig, ackDeadlineSeconds);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    Subscription actualRequest = (Subscription) actualRequests.get(0);
    Assert.assertEquals(name, actualRequest.getNameAsSubscriptionName());
    Assert.assertEquals(TopicNameOneof.from(topic), actualRequest.getTopicAsTopicNameOneof());
    Assert.assertEquals(pushConfig, actualRequest.getPushConfig());
    Assert.assertEquals(ackDeadlineSeconds, actualRequest.getAckDeadlineSeconds());
}
Also used : PushConfig(com.google.pubsub.v1.PushConfig) TopicNameOneof(com.google.pubsub.v1.TopicNameOneof) SubscriptionName(com.google.pubsub.v1.SubscriptionName) Subscription(com.google.pubsub.v1.Subscription) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) TopicName(com.google.pubsub.v1.TopicName) Test(org.junit.Test)

Example 2 with TopicNameOneof

use of com.google.pubsub.v1.TopicNameOneof 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)

Aggregations

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