Search in sources :

Example 6 with UpdateSnapshotRequest

use of com.google.pubsub.v1.UpdateSnapshotRequest 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)

Aggregations

UpdateSnapshotRequest (com.google.pubsub.v1.UpdateSnapshotRequest)6 Snapshot (com.google.pubsub.v1.Snapshot)4 Test (org.junit.Test)4 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)2 SubscriptionAdminClient (com.google.cloud.pubsub.v1.SubscriptionAdminClient)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 HashMap (java.util.HashMap)2