use of com.google.pubsub.v1.UpdateSnapshotRequest in project gapic-generator-java by googleapis.
the class SyncUpdateSnapshot method syncUpdateSnapshot.
public static void syncUpdateSnapshot() throws Exception {
// It may require modifications to work in your environment.
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
UpdateSnapshotRequest request = UpdateSnapshotRequest.newBuilder().setSnapshot(Snapshot.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
Snapshot response = subscriptionAdminClient.updateSnapshot(request);
}
}
use of com.google.pubsub.v1.UpdateSnapshotRequest in project java-pubsub 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()));
}
use of com.google.pubsub.v1.UpdateSnapshotRequest in project java-pubsub by googleapis.
the class SubscriptionAdminClientTest method updateSnapshotExceptionTest.
@Test
public void updateSnapshotExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockSubscriber.addException(exception);
try {
UpdateSnapshotRequest request = UpdateSnapshotRequest.newBuilder().setSnapshot(Snapshot.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
client.updateSnapshot(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.pubsub.v1.UpdateSnapshotRequest in project gapic-generator-java by googleapis.
the class AsyncUpdateSnapshot method asyncUpdateSnapshot.
public static void asyncUpdateSnapshot() throws Exception {
// It may require modifications to work in your environment.
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
UpdateSnapshotRequest request = UpdateSnapshotRequest.newBuilder().setSnapshot(Snapshot.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
ApiFuture<Snapshot> future = subscriptionAdminClient.updateSnapshotCallable().futureCall(request);
// Do something.
Snapshot response = future.get();
}
}
use of com.google.pubsub.v1.UpdateSnapshotRequest in project gapic-generator-java by googleapis.
the class SubscriptionAdminClientTest method updateSnapshotExceptionTest.
@Test
public void updateSnapshotExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockSubscriber.addException(exception);
try {
UpdateSnapshotRequest request = UpdateSnapshotRequest.newBuilder().setSnapshot(Snapshot.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
client.updateSnapshot(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations