use of com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse in project gapic-generator-java by googleapis.
the class SubscriptionAdminClientTest method listSnapshotsTest.
@Test
public void listSnapshotsTest() throws Exception {
Snapshot responsesElement = Snapshot.newBuilder().build();
ListSnapshotsResponse expectedResponse = ListSnapshotsResponse.newBuilder().setNextPageToken("").addAllSnapshots(Arrays.asList(responsesElement)).build();
mockSubscriber.addResponse(expectedResponse);
ProjectName project = ProjectName.of("[PROJECT]");
ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(project);
List<Snapshot> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSnapshotsRequest actualRequest = ((ListSnapshotsRequest) actualRequests.get(0));
Assert.assertEquals(project.toString(), actualRequest.getProject());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse in project gapic-generator-java by googleapis.
the class SubscriptionAdminClientTest method listSnapshotsTest2.
@Test
public void listSnapshotsTest2() throws Exception {
Snapshot responsesElement = Snapshot.newBuilder().build();
ListSnapshotsResponse expectedResponse = ListSnapshotsResponse.newBuilder().setNextPageToken("").addAllSnapshots(Arrays.asList(responsesElement)).build();
mockSubscriber.addResponse(expectedResponse);
String project = "project-309310695";
ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(project);
List<Snapshot> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSnapshotsRequest actualRequest = ((ListSnapshotsRequest) actualRequests.get(0));
Assert.assertEquals(project, actualRequest.getProject());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse in project java-pubsub by googleapis.
the class SubscriptionAdminClientTest method listSnapshotsTest.
@Test
public void listSnapshotsTest() throws Exception {
Snapshot responsesElement = Snapshot.newBuilder().build();
ListSnapshotsResponse expectedResponse = ListSnapshotsResponse.newBuilder().setNextPageToken("").addAllSnapshots(Arrays.asList(responsesElement)).build();
mockSubscriber.addResponse(expectedResponse);
ProjectName project = ProjectName.of("[PROJECT]");
ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(project);
List<Snapshot> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSnapshotsRequest actualRequest = ((ListSnapshotsRequest) actualRequests.get(0));
Assert.assertEquals(project.toString(), actualRequest.getProject());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse in project java-pubsub by googleapis.
the class SubscriptionAdminClientTest method listSnapshotsTest2.
@Test
public void listSnapshotsTest2() throws Exception {
Snapshot responsesElement = Snapshot.newBuilder().build();
ListSnapshotsResponse expectedResponse = ListSnapshotsResponse.newBuilder().setNextPageToken("").addAllSnapshots(Arrays.asList(responsesElement)).build();
mockSubscriber.addResponse(expectedResponse);
String project = "project-309310695";
ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(project);
List<Snapshot> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSnapshotsRequest actualRequest = ((ListSnapshotsRequest) actualRequests.get(0));
Assert.assertEquals(project, actualRequest.getProject());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations