use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method deleteSnapshotTest.
@Test
@SuppressWarnings("all")
public void deleteSnapshotTest() {
Empty expectedResponse = Empty.newBuilder().build();
mockSubscriber.addResponse(expectedResponse);
SnapshotName snapshot = SnapshotName.create("[PROJECT]", "[SNAPSHOT]");
client.deleteSnapshot(snapshot);
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteSnapshotRequest actualRequest = (DeleteSnapshotRequest) actualRequests.get(0);
Assert.assertEquals(snapshot, actualRequest.getSnapshotAsSnapshotName());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class TopicAdminClientTest method setIamPolicyTest.
@Test
@SuppressWarnings("all")
public void setIamPolicyTest() {
int version = 351608024;
ByteString etag = ByteString.copyFromUtf8("21");
Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build();
mockIAMPolicy.addResponse(expectedResponse);
String formattedResource = TopicName.create("[PROJECT]", "[TOPIC]").toString();
Policy policy = Policy.newBuilder().build();
Policy actualResponse = client.setIamPolicy(formattedResource, policy);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockIAMPolicy.getRequests();
Assert.assertEquals(1, actualRequests.size());
SetIamPolicyRequest actualRequest = (SetIamPolicyRequest) actualRequests.get(0);
Assert.assertEquals(formattedResource, actualRequest.getResource());
Assert.assertEquals(policy, actualRequest.getPolicy());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class TopicAdminClientTest method createTopicTest.
@Test
@SuppressWarnings("all")
public void createTopicTest() {
TopicName name2 = TopicName.create("[PROJECT]", "[TOPIC]");
Topic expectedResponse = Topic.newBuilder().setNameWithTopicName(name2).build();
mockPublisher.addResponse(expectedResponse);
TopicName name = TopicName.create("[PROJECT]", "[TOPIC]");
Topic actualResponse = client.createTopic(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockPublisher.getRequests();
Assert.assertEquals(1, actualRequests.size());
Topic actualRequest = (Topic) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsTopicName());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class TopicAdminClientTest method getIamPolicyTest.
@Test
@SuppressWarnings("all")
public void getIamPolicyTest() {
int version = 351608024;
ByteString etag = ByteString.copyFromUtf8("21");
Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build();
mockIAMPolicy.addResponse(expectedResponse);
String formattedResource = TopicName.create("[PROJECT]", "[TOPIC]").toString();
Policy actualResponse = client.getIamPolicy(formattedResource);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockIAMPolicy.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetIamPolicyRequest actualRequest = (GetIamPolicyRequest) actualRequests.get(0);
Assert.assertEquals(formattedResource, actualRequest.getResource());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class SpeechClientTest method asyncRecognizeTest.
@Test
@SuppressWarnings("all")
public void asyncRecognizeTest() throws Exception {
AsyncRecognizeResponse expectedResponse = AsyncRecognizeResponse.newBuilder().build();
Operation resultOperation = Operation.newBuilder().setName("asyncRecognizeTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockSpeech.addResponse(resultOperation);
RecognitionConfig.AudioEncoding encoding = RecognitionConfig.AudioEncoding.FLAC;
int sampleRate = 44100;
RecognitionConfig config = RecognitionConfig.newBuilder().setEncoding(encoding).setSampleRate(sampleRate).build();
String uri = "gs://bucket_name/file_name.flac";
RecognitionAudio audio = RecognitionAudio.newBuilder().setUri(uri).build();
AsyncRecognizeResponse actualResponse = client.asyncRecognizeAsync(config, audio).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockSpeech.getRequests();
Assert.assertEquals(1, actualRequests.size());
AsyncRecognizeRequest actualRequest = (AsyncRecognizeRequest) actualRequests.get(0);
Assert.assertEquals(config, actualRequest.getConfig());
Assert.assertEquals(audio, actualRequest.getAudio());
}
Aggregations