use of com.google.pubsub.v1.ListTopicSubscriptionsResponse in project google-cloud-java by GoogleCloudPlatform.
the class TopicAdminClientTest method listTopicSubscriptionsTest.
@Test
@SuppressWarnings("all")
public void listTopicSubscriptionsTest() {
String nextPageToken = "";
SubscriptionName subscriptionsElement = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
List<SubscriptionName> subscriptions = Arrays.asList(subscriptionsElement);
ListTopicSubscriptionsResponse expectedResponse = ListTopicSubscriptionsResponse.newBuilder().setNextPageToken(nextPageToken).addAllSubscriptionsWithSubscriptionNameList(subscriptions).build();
mockPublisher.addResponse(expectedResponse);
TopicName topic = TopicName.create("[PROJECT]", "[TOPIC]");
ListTopicSubscriptionsPagedResponse pagedListResponse = client.listTopicSubscriptions(topic);
List<String> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSubscriptionsList().get(0), resources.get(0));
List<SubscriptionName> resourceNames = Lists.newArrayList(pagedListResponse.iterateAllAsSubscriptionName());
Assert.assertEquals(1, resourceNames.size());
Assert.assertEquals(expectedResponse.getSubscriptionsListAsSubscriptionNameList().get(0), resourceNames.get(0));
List<GeneratedMessageV3> actualRequests = mockPublisher.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTopicSubscriptionsRequest actualRequest = (ListTopicSubscriptionsRequest) actualRequests.get(0);
Assert.assertEquals(topic, actualRequest.getTopicAsTopicName());
}
Aggregations