Search in sources :

Example 51 with GeneratedMessageV3

use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.

the class GroupServiceClientTest method deleteGroupTest.

@Test
@SuppressWarnings("all")
public void deleteGroupTest() {
    Empty expectedResponse = Empty.newBuilder().build();
    mockGroupService.addResponse(expectedResponse);
    GroupName name = GroupName.create("[PROJECT]", "[GROUP]");
    client.deleteGroup(name);
    List<GeneratedMessageV3> actualRequests = mockGroupService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteGroupRequest actualRequest = (DeleteGroupRequest) actualRequests.get(0);
    Assert.assertEquals(name, actualRequest.getNameAsGroupName());
}
Also used : GroupName(com.google.monitoring.v3.GroupName) Empty(com.google.protobuf.Empty) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) DeleteGroupRequest(com.google.monitoring.v3.DeleteGroupRequest) Test(org.junit.Test)

Example 52 with GeneratedMessageV3

use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.

the class MetricServiceClientTest method listTimeSeriesTest.

@Test
@SuppressWarnings("all")
public void listTimeSeriesTest() {
    String nextPageToken = "";
    TimeSeries timeSeriesElement = TimeSeries.newBuilder().build();
    List<TimeSeries> timeSeries = Arrays.asList(timeSeriesElement);
    ListTimeSeriesResponse expectedResponse = ListTimeSeriesResponse.newBuilder().setNextPageToken(nextPageToken).addAllTimeSeries(timeSeries).build();
    mockMetricService.addResponse(expectedResponse);
    ProjectName name = ProjectName.create("[PROJECT]");
    String filter = "filter-1274492040";
    TimeInterval interval = TimeInterval.newBuilder().build();
    ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL;
    ListTimeSeriesPagedResponse pagedListResponse = client.listTimeSeries(name, filter, interval, view);
    List<TimeSeries> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTimeSeriesList().get(0), resources.get(0));
    List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTimeSeriesRequest actualRequest = (ListTimeSeriesRequest) actualRequests.get(0);
    Assert.assertEquals(name, actualRequest.getNameAsProjectName());
    Assert.assertEquals(filter, actualRequest.getFilter());
    Assert.assertEquals(interval, actualRequest.getInterval());
    Assert.assertEquals(view, actualRequest.getView());
}
Also used : TimeSeries(com.google.monitoring.v3.TimeSeries) TimeInterval(com.google.monitoring.v3.TimeInterval) ProjectName(com.google.monitoring.v3.ProjectName) ListTimeSeriesResponse(com.google.monitoring.v3.ListTimeSeriesResponse) TimeSeriesView(com.google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView) ListTimeSeriesPagedResponse(com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListTimeSeriesPagedResponse) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) ListTimeSeriesRequest(com.google.monitoring.v3.ListTimeSeriesRequest) Test(org.junit.Test)

Example 53 with GeneratedMessageV3

use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.

the class MetricServiceClientTest method getMonitoredResourceDescriptorTest.

@Test
@SuppressWarnings("all")
public void getMonitoredResourceDescriptorTest() {
    String name2 = "name2-1052831874";
    String type = "type3575610";
    String displayName = "displayName1615086568";
    String description = "description-1724546052";
    MonitoredResourceDescriptor expectedResponse = MonitoredResourceDescriptor.newBuilder().setName(name2).setType(type).setDisplayName(displayName).setDescription(description).build();
    mockMetricService.addResponse(expectedResponse);
    MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.create("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
    MonitoredResourceDescriptor actualResponse = client.getMonitoredResourceDescriptor(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetMonitoredResourceDescriptorRequest actualRequest = (GetMonitoredResourceDescriptorRequest) actualRequests.get(0);
    Assert.assertEquals(name, actualRequest.getNameAsMonitoredResourceDescriptorName());
}
Also used : MonitoredResourceDescriptorName(com.google.monitoring.v3.MonitoredResourceDescriptorName) MonitoredResourceDescriptor(com.google.api.MonitoredResourceDescriptor) GetMonitoredResourceDescriptorRequest(com.google.monitoring.v3.GetMonitoredResourceDescriptorRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 54 with GeneratedMessageV3

use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.

the class ConfigClientTest method getSinkTest.

@Test
@SuppressWarnings("all")
public void getSinkTest() {
    String name = "name3373707";
    ResourceName destination = ProjectName.create("[PROJECT]");
    String filter = "filter-1274492040";
    String writerIdentity = "writerIdentity775638794";
    LogSink expectedResponse = LogSink.newBuilder().setName(name).setDestinationWithResourceName(destination).setFilter(filter).setWriterIdentity(writerIdentity).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
    LogSink actualResponse = client.getSink(sinkName);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetSinkRequest actualRequest = (GetSinkRequest) actualRequests.get(0);
    Assert.assertEquals(sinkName, actualRequest.getSinkNameAsSinkNameOneof());
}
Also used : LogSink(com.google.logging.v2.LogSink) GetSinkRequest(com.google.logging.v2.GetSinkRequest) ResourceName(com.google.api.resourcenames.ResourceName) SinkNameOneof(com.google.logging.v2.SinkNameOneof) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 55 with GeneratedMessageV3

use of com.google.protobuf.GeneratedMessageV3 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());
}
Also used : AnnotateVideoRequest(com.google.cloud.videointelligence.v1beta1.AnnotateVideoRequest) ArrayList(java.util.ArrayList) VideoContext(com.google.cloud.videointelligence.v1beta1.VideoContext) Operation(com.google.longrunning.Operation) Feature(com.google.cloud.videointelligence.v1beta1.Feature) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) AnnotateVideoResponse(com.google.cloud.videointelligence.v1beta1.AnnotateVideoResponse) 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