Search in sources :

Example 11 with SubscriptionPath

use of org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath in project beam by apache.

the class PubsubJsonClientTest method listSubscriptions.

@Test
public void listSubscriptions() throws Exception {
    ListSubscriptionsResponse expectedResponse1 = new ListSubscriptionsResponse();
    expectedResponse1.setSubscriptions(Collections.singletonList(buildSubscription(1)));
    expectedResponse1.setNextPageToken("AVgJH3Z7aHxiDBs");
    ListSubscriptionsResponse expectedResponse2 = new ListSubscriptionsResponse();
    expectedResponse2.setSubscriptions(Collections.singletonList(buildSubscription(2)));
    Subscriptions.List request = mockPubsub.projects().subscriptions().list(PROJECT.getPath());
    when((Object) request.execute()).thenReturn(expectedResponse1, expectedResponse2);
    final TopicPath topic101 = PubsubClient.topicPathFromName("testProject", "Topic2");
    List<SubscriptionPath> subscriptionPaths = client.listSubscriptions(PROJECT, topic101);
    assertEquals(1, subscriptionPaths.size());
}
Also used : ListSubscriptionsResponse(com.google.api.services.pubsub.model.ListSubscriptionsResponse) TopicPath(org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.TopicPath) Subscriptions(com.google.api.services.pubsub.Pubsub.Projects.Subscriptions) SubscriptionPath(org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath) Test(org.junit.Test)

Example 12 with SubscriptionPath

use of org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath in project beam by apache.

the class FhirIOReadIT method deleteFHIRtore.

@After
public void deleteFHIRtore() throws IOException {
    HealthcareApiClient client = new HttpHealthcareApiClient();
    client.deleteFhirStore(healthcareDataset + "/fhirStores/" + fhirStoreName);
    TopicPath topicPath = PubsubClient.topicPathFromPath(pubsubTopic);
    SubscriptionPath subscriptionPath = PubsubClient.subscriptionPathFromPath(pubsubSubscription);
    pubsub.deleteSubscription(subscriptionPath);
    pubsub.deleteTopic(topicPath);
    pubsub.close();
}
Also used : TopicPath(org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.TopicPath) SubscriptionPath(org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath) After(org.junit.After)

Example 13 with SubscriptionPath

use of org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath in project beam by apache.

the class PubsubClientTest method subscriptionPathFromNameWellFormed.

@Test
public void subscriptionPathFromNameWellFormed() {
    SubscriptionPath path = PubsubClient.subscriptionPathFromName("test", "something");
    assertEquals("projects/test/subscriptions/something", path.getPath());
    assertEquals("/subscriptions/test/something", path.getFullPath());
}
Also used : SubscriptionPath(org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath) Test(org.junit.Test)

Aggregations

SubscriptionPath (org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath)13 TopicPath (org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.TopicPath)10 IOException (java.io.IOException)5 Test (org.junit.Test)3 ApiException (com.google.api.gax.rpc.ApiException)2 ByteString (com.google.protobuf.ByteString)2 PipelineOptions (org.apache.beam.sdk.options.PipelineOptions)2 GoogleJsonResponseException (com.google.api.client.googleapis.json.GoogleJsonResponseException)1 ApiFuture (com.google.api.core.ApiFuture)1 ApiFutures (com.google.api.core.ApiFutures)1 GrpcTransportChannel (com.google.api.gax.grpc.GrpcTransportChannel)1 FixedTransportChannelProvider (com.google.api.gax.rpc.FixedTransportChannelProvider)1 TransportChannelProvider (com.google.api.gax.rpc.TransportChannelProvider)1 Subscriptions (com.google.api.services.pubsub.Pubsub.Projects.Subscriptions)1 ListSubscriptionsResponse (com.google.api.services.pubsub.model.ListSubscriptionsResponse)1 AckReplyConsumer (com.google.cloud.pubsub.v1.AckReplyConsumer)1 MessageReceiver (com.google.cloud.pubsub.v1.MessageReceiver)1 Publisher (com.google.cloud.pubsub.v1.Publisher)1 Subscriber (com.google.cloud.pubsub.v1.Subscriber)1 SubscriptionAdminClient (com.google.cloud.pubsub.v1.SubscriptionAdminClient)1