Search in sources :

Example 1 with ListSnapshotsPagedResponse

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()));
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) ListSnapshotsRequest(com.google.pubsub.v1.ListSnapshotsRequest) ListSnapshotsResponse(com.google.pubsub.v1.ListSnapshotsResponse) ListSnapshotsPagedResponse(com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.pubsub.v1.ProjectName) Test(org.junit.Test)

Example 2 with ListSnapshotsPagedResponse

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()));
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) ListSnapshotsRequest(com.google.pubsub.v1.ListSnapshotsRequest) ListSnapshotsResponse(com.google.pubsub.v1.ListSnapshotsResponse) ListSnapshotsPagedResponse(com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 3 with ListSnapshotsPagedResponse

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()));
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) ListSnapshotsRequest(com.google.pubsub.v1.ListSnapshotsRequest) ListSnapshotsResponse(com.google.pubsub.v1.ListSnapshotsResponse) ListSnapshotsPagedResponse(com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.pubsub.v1.ProjectName) Test(org.junit.Test)

Example 4 with ListSnapshotsPagedResponse

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()));
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) ListSnapshotsRequest(com.google.pubsub.v1.ListSnapshotsRequest) ListSnapshotsResponse(com.google.pubsub.v1.ListSnapshotsResponse) ListSnapshotsPagedResponse(com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

ListSnapshotsPagedResponse (com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 ListSnapshotsRequest (com.google.pubsub.v1.ListSnapshotsRequest)4 ListSnapshotsResponse (com.google.pubsub.v1.ListSnapshotsResponse)4 Snapshot (com.google.pubsub.v1.Snapshot)4 Test (org.junit.Test)4 ByteString (com.google.protobuf.ByteString)2 ProjectName (com.google.pubsub.v1.ProjectName)2