use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method annotateTextTest.
@Test
@SuppressWarnings("all")
public void annotateTextTest() {
String language = "language-1613589672";
AnnotateTextResponse expectedResponse = AnnotateTextResponse.newBuilder().setLanguage(language).build();
mockLanguageService.addResponse(expectedResponse);
Document document = Document.newBuilder().build();
AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
AnnotateTextResponse actualResponse = client.annotateText(document, features, encodingType);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockLanguageService.getRequests();
Assert.assertEquals(1, actualRequests.size());
AnnotateTextRequest actualRequest = (AnnotateTextRequest) actualRequests.get(0);
Assert.assertEquals(document, actualRequest.getDocument());
Assert.assertEquals(features, actualRequest.getFeatures());
Assert.assertEquals(encodingType, actualRequest.getEncodingType());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class ImageAnnotatorClientTest method batchAnnotateImagesTest.
@Test
@SuppressWarnings("all")
public void batchAnnotateImagesTest() {
BatchAnnotateImagesResponse expectedResponse = BatchAnnotateImagesResponse.newBuilder().build();
mockImageAnnotator.addResponse(expectedResponse);
List<AnnotateImageRequest> requests = new ArrayList<>();
BatchAnnotateImagesResponse actualResponse = client.batchAnnotateImages(requests);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockImageAnnotator.getRequests();
Assert.assertEquals(1, actualRequests.size());
BatchAnnotateImagesRequest actualRequest = (BatchAnnotateImagesRequest) actualRequests.get(0);
Assert.assertEquals(requests, actualRequest.getRequestsList());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class ErrorGroupServiceClientTest method updateGroupTest.
@Test
@SuppressWarnings("all")
public void updateGroupTest() {
GroupName name = GroupName.create("[PROJECT]", "[GROUP]");
String groupId = "groupId506361563";
ErrorGroup expectedResponse = ErrorGroup.newBuilder().setNameWithGroupName(name).setGroupId(groupId).build();
mockErrorGroupService.addResponse(expectedResponse);
ErrorGroup group = ErrorGroup.newBuilder().build();
ErrorGroup actualResponse = client.updateGroup(group);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockErrorGroupService.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateGroupRequest actualRequest = (UpdateGroupRequest) actualRequests.get(0);
Assert.assertEquals(group, actualRequest.getGroup());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class ErrorStatsServiceClientTest method listGroupStatsTest.
@Test
@SuppressWarnings("all")
public void listGroupStatsTest() {
String nextPageToken = "";
ErrorGroupStats errorGroupStatsElement = ErrorGroupStats.newBuilder().build();
List<ErrorGroupStats> errorGroupStats = Arrays.asList(errorGroupStatsElement);
ListGroupStatsResponse expectedResponse = ListGroupStatsResponse.newBuilder().setNextPageToken(nextPageToken).addAllErrorGroupStats(errorGroupStats).build();
mockErrorStatsService.addResponse(expectedResponse);
ProjectName projectName = ProjectName.create("[PROJECT]");
QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
ListGroupStatsPagedResponse pagedListResponse = client.listGroupStats(projectName, timeRange);
List<ErrorGroupStats> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getErrorGroupStatsList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockErrorStatsService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListGroupStatsRequest actualRequest = (ListGroupStatsRequest) actualRequests.get(0);
Assert.assertEquals(projectName, actualRequest.getProjectNameAsProjectName());
Assert.assertEquals(timeRange, actualRequest.getTimeRange());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class ReportErrorsServiceClientTest method reportErrorEventTest.
@Test
@SuppressWarnings("all")
public void reportErrorEventTest() {
ReportErrorEventResponse expectedResponse = ReportErrorEventResponse.newBuilder().build();
mockReportErrorsService.addResponse(expectedResponse);
ProjectName projectName = ProjectName.create("[PROJECT]");
ReportedErrorEvent event = ReportedErrorEvent.newBuilder().build();
ReportErrorEventResponse actualResponse = client.reportErrorEvent(projectName, event);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockReportErrorsService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ReportErrorEventRequest actualRequest = (ReportErrorEventRequest) actualRequests.get(0);
Assert.assertEquals(projectName, actualRequest.getProjectNameAsProjectName());
Assert.assertEquals(event, actualRequest.getEvent());
}
Aggregations