use of com.google.longrunning.Operation 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());
}
use of com.google.longrunning.Operation in project google-cloud-java by GoogleCloudPlatform.
the class VideoIntelligenceServiceClientTest method annotateVideoTest.
@Test
@SuppressWarnings("all")
public void annotateVideoTest() throws Exception {
AnnotateVideoResponse expectedResponse = AnnotateVideoResponse.newBuilder().build();
Operation resultOperation = Operation.newBuilder().setName("annotateVideoTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockVideoIntelligenceService.addResponse(resultOperation);
String inputUri = "inputUri1707300727";
List<Feature> features = new ArrayList<>();
VideoContext videoContext = VideoContext.newBuilder().build();
String outputUri = "outputUri-1273518802";
String locationId = "locationId552319461";
AnnotateVideoResponse actualResponse = client.annotateVideoAsync(inputUri, features, videoContext, outputUri, locationId).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockVideoIntelligenceService.getRequests();
Assert.assertEquals(1, actualRequests.size());
AnnotateVideoRequest actualRequest = (AnnotateVideoRequest) actualRequests.get(0);
Assert.assertEquals(inputUri, actualRequest.getInputUri());
Assert.assertEquals(features, actualRequest.getFeaturesList());
Assert.assertEquals(videoContext, actualRequest.getVideoContext());
Assert.assertEquals(outputUri, actualRequest.getOutputUri());
Assert.assertEquals(locationId, actualRequest.getLocationId());
}
use of com.google.longrunning.Operation in project google-cloud-java by GoogleCloudPlatform.
the class SpeechClientTest method longRunningRecognizeTest.
@Test
@SuppressWarnings("all")
public void longRunningRecognizeTest() throws Exception {
LongRunningRecognizeResponse expectedResponse = LongRunningRecognizeResponse.newBuilder().build();
Operation resultOperation = Operation.newBuilder().setName("longRunningRecognizeTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockSpeech.addResponse(resultOperation);
RecognitionConfig.AudioEncoding encoding = RecognitionConfig.AudioEncoding.FLAC;
int sampleRateHertz = 44100;
String languageCode = "en-US";
RecognitionConfig config = RecognitionConfig.newBuilder().setEncoding(encoding).setSampleRateHertz(sampleRateHertz).setLanguageCode(languageCode).build();
String uri = "gs://bucket_name/file_name.flac";
RecognitionAudio audio = RecognitionAudio.newBuilder().setUri(uri).build();
LongRunningRecognizeResponse actualResponse = client.longRunningRecognizeAsync(config, audio).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockSpeech.getRequests();
Assert.assertEquals(1, actualRequests.size());
LongRunningRecognizeRequest actualRequest = (LongRunningRecognizeRequest) actualRequests.get(0);
Assert.assertEquals(config, actualRequest.getConfig());
Assert.assertEquals(audio, actualRequest.getAudio());
}
Aggregations