Search in sources :

Example 26 with Snapshot

use of io.dropwizard.metrics5.Snapshot in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method getSnapshotTest2.

@Test
public void getSnapshotTest2() throws Exception {
    Snapshot expectedResponse = Snapshot.newBuilder().setName(SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]").toString()).setSourceTable(Table.newBuilder().build()).setDataSizeBytes(-2110122398).setCreateTime(Timestamp.newBuilder().build()).setDeleteTime(Timestamp.newBuilder().build()).setDescription("description-1724546052").build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    String name = "name3373707";
    Snapshot actualResponse = client.getSnapshot(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetSnapshotRequest actualRequest = ((GetSnapshotRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Snapshot(com.google.bigtable.admin.v2.Snapshot) AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) GetSnapshotRequest(com.google.bigtable.admin.v2.GetSnapshotRequest) Test(org.junit.Test)

Example 27 with Snapshot

use of io.dropwizard.metrics5.Snapshot in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method snapshotTableTest3.

@Test
public void snapshotTableTest3() throws Exception {
    Snapshot expectedResponse = Snapshot.newBuilder().setName(SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]").toString()).setSourceTable(Table.newBuilder().build()).setDataSizeBytes(-2110122398).setCreateTime(Timestamp.newBuilder().build()).setDeleteTime(Timestamp.newBuilder().build()).setDescription("description-1724546052").build();
    Operation resultOperation = Operation.newBuilder().setName("snapshotTableTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
    mockBigtableTableAdmin.addResponse(resultOperation);
    String name = "name3373707";
    ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
    String snapshotId = "snapshotId-1113817601";
    String description = "description-1724546052";
    Snapshot actualResponse = client.snapshotTableAsync(name, cluster, snapshotId, description).get();
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    SnapshotTableRequest actualRequest = ((SnapshotTableRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertEquals(cluster.toString(), actualRequest.getCluster());
    Assert.assertEquals(snapshotId, actualRequest.getSnapshotId());
    Assert.assertEquals(description, actualRequest.getDescription());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : SnapshotTableRequest(com.google.bigtable.admin.v2.SnapshotTableRequest) Snapshot(com.google.bigtable.admin.v2.Snapshot) AbstractMessage(com.google.protobuf.AbstractMessage) ClusterName(com.google.bigtable.admin.v2.ClusterName) Operation(com.google.longrunning.Operation) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 28 with Snapshot

use of io.dropwizard.metrics5.Snapshot in project java-pubsub by googleapis.

the class SubscriptionAdminClientTest method createSnapshotTest4.

@Test
public void createSnapshotTest4() throws Exception {
    Snapshot expectedResponse = Snapshot.newBuilder().setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()).setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()).setExpireTime(Timestamp.newBuilder().build()).putAllLabels(new HashMap<String, String>()).build();
    mockSubscriber.addResponse(expectedResponse);
    String name = "name3373707";
    String subscription = "subscription341203229";
    Snapshot actualResponse = client.createSnapshot(name, subscription);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateSnapshotRequest actualRequest = ((CreateSnapshotRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertEquals(subscription, actualRequest.getSubscription());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) CreateSnapshotRequest(com.google.pubsub.v1.CreateSnapshotRequest) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 29 with Snapshot

use of io.dropwizard.metrics5.Snapshot 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)

Example 30 with Snapshot

use of io.dropwizard.metrics5.Snapshot in project java-pubsub by googleapis.

the class SubscriptionAdminClientTest method getSnapshotTest2.

@Test
public void getSnapshotTest2() throws Exception {
    Snapshot expectedResponse = Snapshot.newBuilder().setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()).setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()).setExpireTime(Timestamp.newBuilder().build()).putAllLabels(new HashMap<String, String>()).build();
    mockSubscriber.addResponse(expectedResponse);
    String snapshot = "snapshot284874180";
    Snapshot actualResponse = client.getSnapshot(snapshot);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetSnapshotRequest actualRequest = ((GetSnapshotRequest) actualRequests.get(0));
    Assert.assertEquals(snapshot, actualRequest.getSnapshot());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) ByteString(com.google.protobuf.ByteString) GetSnapshotRequest(com.google.pubsub.v1.GetSnapshotRequest) Test(org.junit.Test)

Aggregations

Snapshot (com.google.pubsub.v1.Snapshot)34 Test (org.junit.Test)28 AbstractMessage (com.google.protobuf.AbstractMessage)26 ByteString (com.google.protobuf.ByteString)17 HashMap (java.util.HashMap)16 SubscriptionAdminClient (com.google.cloud.pubsub.v1.SubscriptionAdminClient)14 CreateSnapshotRequest (com.google.pubsub.v1.CreateSnapshotRequest)11 SnapshotName (com.google.pubsub.v1.SnapshotName)10 Snapshot (com.google.bigtable.admin.v2.Snapshot)8 ListSnapshotsRequest (com.google.pubsub.v1.ListSnapshotsRequest)7 SubscriptionName (com.google.pubsub.v1.SubscriptionName)7 GetSnapshotRequest (com.google.pubsub.v1.GetSnapshotRequest)6 ListSnapshotsResponse (com.google.pubsub.v1.ListSnapshotsResponse)6 SnapshotTableRequest (com.google.bigtable.admin.v2.SnapshotTableRequest)4 ListSnapshotsPagedResponse (com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse)4 Operation (com.google.longrunning.Operation)4 UpdateSnapshotRequest (com.google.pubsub.v1.UpdateSnapshotRequest)4 ClusterName (com.google.bigtable.admin.v2.ClusterName)3 ProjectName (com.google.pubsub.v1.ProjectName)3 GetSnapshotRequest (com.google.bigtable.admin.v2.GetSnapshotRequest)2