Search in sources :

Example 16 with GeneratedMessageV3

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());
}
Also used : Empty(com.google.protobuf.Empty) DeleteSnapshotRequest(com.google.pubsub.v1.DeleteSnapshotRequest) SnapshotName(com.google.pubsub.v1.SnapshotName) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 17 with GeneratedMessageV3

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());
}
Also used : Policy(com.google.iam.v1.Policy) SetIamPolicyRequest(com.google.iam.v1.SetIamPolicyRequest) ByteString(com.google.protobuf.ByteString) ByteString(com.google.protobuf.ByteString) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 18 with GeneratedMessageV3

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());
}
Also used : Topic(com.google.pubsub.v1.Topic) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) TopicName(com.google.pubsub.v1.TopicName) Test(org.junit.Test)

Example 19 with GeneratedMessageV3

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());
}
Also used : Policy(com.google.iam.v1.Policy) ByteString(com.google.protobuf.ByteString) ByteString(com.google.protobuf.ByteString) GetIamPolicyRequest(com.google.iam.v1.GetIamPolicyRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 20 with GeneratedMessageV3

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());
}
Also used : RecognitionAudio(com.google.cloud.speech.v1beta1.RecognitionAudio) AudioEncoding(com.google.cloud.speech.v1beta1.RecognitionConfig.AudioEncoding) AsyncRecognizeRequest(com.google.cloud.speech.v1beta1.AsyncRecognizeRequest) RecognitionConfig(com.google.cloud.speech.v1beta1.RecognitionConfig) Operation(com.google.longrunning.Operation) AsyncRecognizeResponse(com.google.cloud.speech.v1beta1.AsyncRecognizeResponse) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Aggregations

GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)75 Test (org.junit.Test)75 ByteString (com.google.protobuf.ByteString)13 Empty (com.google.protobuf.Empty)13 SubscriptionName (com.google.pubsub.v1.SubscriptionName)9 ArrayList (java.util.ArrayList)8 TopicName (com.google.pubsub.v1.TopicName)7 Document (com.google.cloud.language.v1beta2.Document)5 GroupName (com.google.monitoring.v3.GroupName)5 ProjectName (com.google.monitoring.v3.ProjectName)5 Document (com.google.cloud.language.v1.Document)4 EncodingType (com.google.cloud.language.v1beta2.EncodingType)4 ProjectName (com.google.devtools.clouderrorreporting.v1beta1.ProjectName)4 LogMetric (com.google.logging.v2.LogMetric)4 LogSink (com.google.logging.v2.LogSink)4 ParentNameOneof (com.google.logging.v2.ParentNameOneof)4 MetricDescriptor (com.google.api.MetricDescriptor)3 ResourceName (com.google.api.resourcenames.ResourceName)3 EncodingType (com.google.cloud.language.v1.EncodingType)3 Policy (com.google.iam.v1.Policy)3