Search in sources :

Example 1 with ListSnapshotsRequest

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

the class SubscriptionAdminClientTest method listSnapshotsTest.

@Test
@SuppressWarnings("all")
public void listSnapshotsTest() {
    String nextPageToken = "";
    Snapshot snapshotsElement = Snapshot.newBuilder().build();
    List<Snapshot> snapshots = Arrays.asList(snapshotsElement);
    ListSnapshotsResponse expectedResponse = ListSnapshotsResponse.newBuilder().setNextPageToken(nextPageToken).addAllSnapshots(snapshots).build();
    mockSubscriber.addResponse(expectedResponse);
    ProjectName project = ProjectName.create("[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<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSnapshotsRequest actualRequest = (ListSnapshotsRequest) actualRequests.get(0);
    Assert.assertEquals(project, actualRequest.getProjectAsProjectName());
}
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.spi.v1.PagedResponseWrappers.ListSnapshotsPagedResponse) ProjectName(com.google.pubsub.v1.ProjectName) ByteString(com.google.protobuf.ByteString) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Aggregations

ListSnapshotsPagedResponse (com.google.cloud.pubsub.spi.v1.PagedResponseWrappers.ListSnapshotsPagedResponse)1 ByteString (com.google.protobuf.ByteString)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 ListSnapshotsRequest (com.google.pubsub.v1.ListSnapshotsRequest)1 ListSnapshotsResponse (com.google.pubsub.v1.ListSnapshotsResponse)1 ProjectName (com.google.pubsub.v1.ProjectName)1 Snapshot (com.google.pubsub.v1.Snapshot)1 Test (org.junit.Test)1