use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class ErrorGroupServiceClientTest method getGroupTest.
@Test
@SuppressWarnings("all")
public void getGroupTest() {
GroupName name = GroupName.create("[PROJECT]", "[GROUP]");
String groupId = "groupId506361563";
ErrorGroup expectedResponse = ErrorGroup.newBuilder().setNameWithGroupName(name).setGroupId(groupId).build();
mockErrorGroupService.addResponse(expectedResponse);
GroupName groupName = GroupName.create("[PROJECT]", "[GROUP]");
ErrorGroup actualResponse = client.getGroup(groupName);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockErrorGroupService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetGroupRequest actualRequest = (GetGroupRequest) actualRequests.get(0);
Assert.assertEquals(groupName, actualRequest.getGroupNameAsGroupName());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class ErrorStatsServiceClientTest method deleteEventsTest.
@Test
@SuppressWarnings("all")
public void deleteEventsTest() {
DeleteEventsResponse expectedResponse = DeleteEventsResponse.newBuilder().build();
mockErrorStatsService.addResponse(expectedResponse);
ProjectName projectName = ProjectName.create("[PROJECT]");
DeleteEventsResponse actualResponse = client.deleteEvents(projectName);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockErrorStatsService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteEventsRequest actualRequest = (DeleteEventsRequest) actualRequests.get(0);
Assert.assertEquals(projectName, actualRequest.getProjectNameAsProjectName());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class ErrorStatsServiceClientTest method listEventsTest.
@Test
@SuppressWarnings("all")
public void listEventsTest() {
String nextPageToken = "";
ErrorEvent errorEventsElement = ErrorEvent.newBuilder().build();
List<ErrorEvent> errorEvents = Arrays.asList(errorEventsElement);
ListEventsResponse expectedResponse = ListEventsResponse.newBuilder().setNextPageToken(nextPageToken).addAllErrorEvents(errorEvents).build();
mockErrorStatsService.addResponse(expectedResponse);
ProjectName projectName = ProjectName.create("[PROJECT]");
String groupId = "groupId506361563";
ListEventsPagedResponse pagedListResponse = client.listEvents(projectName, groupId);
List<ErrorEvent> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getErrorEventsList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockErrorStatsService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListEventsRequest actualRequest = (ListEventsRequest) actualRequests.get(0);
Assert.assertEquals(projectName, actualRequest.getProjectNameAsProjectName());
Assert.assertEquals(groupId, actualRequest.getGroupId());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class SpeechClientTest method syncRecognizeTest.
@Test
@SuppressWarnings("all")
public void syncRecognizeTest() {
SyncRecognizeResponse expectedResponse = SyncRecognizeResponse.newBuilder().build();
mockSpeech.addResponse(expectedResponse);
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();
SyncRecognizeResponse actualResponse = client.syncRecognize(config, audio);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockSpeech.getRequests();
Assert.assertEquals(1, actualRequests.size());
SyncRecognizeRequest actualRequest = (SyncRecognizeRequest) actualRequests.get(0);
Assert.assertEquals(config, actualRequest.getConfig());
Assert.assertEquals(audio, actualRequest.getAudio());
}
use of com.google.protobuf.GeneratedMessageV3 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