Search in sources :

Example 51 with Snapshot

use of com.google.bigtable.admin.v2.Snapshot in project gapic-generator-java by googleapis.

the class SubscriptionAdminClientTest method createSnapshotTest2.

@Test
public void createSnapshotTest2() 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);
    SnapshotName name = SnapshotName.of("[PROJECT]", "[SNAPSHOT]");
    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.toString(), 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) SnapshotName(com.google.pubsub.v1.SnapshotName) Test(org.junit.Test)

Example 52 with Snapshot

use of com.google.bigtable.admin.v2.Snapshot in project gapic-generator-java by googleapis.

the class SubscriptionAdminClientTest method updateSnapshotTest.

@Test
public void updateSnapshotTest() 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);
    UpdateSnapshotRequest request = UpdateSnapshotRequest.newBuilder().setSnapshot(Snapshot.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
    Snapshot actualResponse = client.updateSnapshot(request);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateSnapshotRequest actualRequest = ((UpdateSnapshotRequest) actualRequests.get(0));
    Assert.assertEquals(request.getSnapshot(), actualRequest.getSnapshot());
    Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
    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) UpdateSnapshotRequest(com.google.pubsub.v1.UpdateSnapshotRequest) Test(org.junit.Test)

Example 53 with Snapshot

use of com.google.bigtable.admin.v2.Snapshot in project gapic-generator-java 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)

Example 54 with Snapshot

use of com.google.bigtable.admin.v2.Snapshot in project spectator by Netflix.

the class MetricsDistributionSummary method measure.

@Override
public Iterable<Measurement> measure() {
    final long now = clock.wallTime();
    final Snapshot snapshot = impl.getSnapshot();
    return Collections.singleton(new Measurement(id, now, snapshot.getMean()));
}
Also used : Measurement(com.netflix.spectator.api.Measurement) Snapshot(io.dropwizard.metrics5.Snapshot)

Aggregations

Test (org.junit.Test)35 Snapshot (com.google.pubsub.v1.Snapshot)34 AbstractMessage (com.google.protobuf.AbstractMessage)29 ByteString (com.google.protobuf.ByteString)21 HashMap (java.util.HashMap)18 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 SnapshotName (com.google.bigtable.admin.v2.SnapshotName)8 ListSnapshotsRequest (com.google.pubsub.v1.ListSnapshotsRequest)7 SubscriptionName (com.google.pubsub.v1.SubscriptionName)7 Operation (com.google.longrunning.Operation)6 GetSnapshotRequest (com.google.pubsub.v1.GetSnapshotRequest)6 ListSnapshotsResponse (com.google.pubsub.v1.ListSnapshotsResponse)6 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)4 SnapshotTableRequest (com.google.bigtable.admin.v2.SnapshotTableRequest)4 ListSnapshotsPagedResponse (com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse)4 UpdateSnapshotRequest (com.google.pubsub.v1.UpdateSnapshotRequest)4 StatusRuntimeException (io.grpc.StatusRuntimeException)4