Search in sources :

Example 46 with GeneratedMessageV3

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

the class ConfigClientTest method listSinksTest.

@Test
@SuppressWarnings("all")
public void listSinksTest() {
    String nextPageToken = "";
    LogSink sinksElement = LogSink.newBuilder().build();
    List<LogSink> sinks = Arrays.asList(sinksElement);
    ListSinksResponse expectedResponse = ListSinksResponse.newBuilder().setNextPageToken(nextPageToken).addAllSinks(sinks).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
    ListSinksPagedResponse pagedListResponse = client.listSinks(parent);
    List<LogSink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSinksList().get(0), resources.get(0));
    List<GeneratedMessageV3> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSinksRequest actualRequest = (ListSinksRequest) actualRequests.get(0);
    Assert.assertEquals(parent, actualRequest.getParentAsParentNameOneof());
}
Also used : LogSink(com.google.logging.v2.LogSink) ListSinksResponse(com.google.logging.v2.ListSinksResponse) ListSinksPagedResponse(com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListSinksPagedResponse) ParentNameOneof(com.google.logging.v2.ParentNameOneof) ListSinksRequest(com.google.logging.v2.ListSinksRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 47 with GeneratedMessageV3

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

the class LoggingClientTest method listLogsTest.

@Test
@SuppressWarnings("all")
public void listLogsTest() {
    String nextPageToken = "";
    String logNamesElement = "logNamesElement-1079688374";
    List<String> logNames = Arrays.asList(logNamesElement);
    ListLogsResponse expectedResponse = ListLogsResponse.newBuilder().setNextPageToken(nextPageToken).addAllLogNames(logNames).build();
    mockLoggingServiceV2.addResponse(expectedResponse);
    ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
    ListLogsPagedResponse pagedListResponse = client.listLogs(parent);
    List<String> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getLogNamesList().get(0), resources.get(0));
    List<GeneratedMessageV3> actualRequests = mockLoggingServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListLogsRequest actualRequest = (ListLogsRequest) actualRequests.get(0);
    Assert.assertEquals(parent, actualRequest.getParentAsParentNameOneof());
}
Also used : ListLogsResponse(com.google.logging.v2.ListLogsResponse) ParentNameOneof(com.google.logging.v2.ParentNameOneof) ListLogsRequest(com.google.logging.v2.ListLogsRequest) ListLogsPagedResponse(com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogsPagedResponse) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 48 with GeneratedMessageV3

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

the class MetricsClientTest method listLogMetricsTest.

@Test
@SuppressWarnings("all")
public void listLogMetricsTest() {
    String nextPageToken = "";
    LogMetric metricsElement = LogMetric.newBuilder().build();
    List<LogMetric> metrics = Arrays.asList(metricsElement);
    ListLogMetricsResponse expectedResponse = ListLogMetricsResponse.newBuilder().setNextPageToken(nextPageToken).addAllMetrics(metrics).build();
    mockMetricsServiceV2.addResponse(expectedResponse);
    ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
    ListLogMetricsPagedResponse pagedListResponse = client.listLogMetrics(parent);
    List<LogMetric> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getMetricsList().get(0), resources.get(0));
    List<GeneratedMessageV3> actualRequests = mockMetricsServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListLogMetricsRequest actualRequest = (ListLogMetricsRequest) actualRequests.get(0);
    Assert.assertEquals(parent, actualRequest.getParentAsParentNameOneof());
}
Also used : LogMetric(com.google.logging.v2.LogMetric) ListLogMetricsResponse(com.google.logging.v2.ListLogMetricsResponse) ListLogMetricsPagedResponse(com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogMetricsPagedResponse) ParentNameOneof(com.google.logging.v2.ParentNameOneof) ListLogMetricsRequest(com.google.logging.v2.ListLogMetricsRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 49 with GeneratedMessageV3

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

the class MetricsClientTest method createLogMetricTest.

@Test
@SuppressWarnings("all")
public void createLogMetricTest() {
    String name = "name3373707";
    String description = "description-1724546052";
    String filter = "filter-1274492040";
    LogMetric expectedResponse = LogMetric.newBuilder().setName(name).setDescription(description).setFilter(filter).build();
    mockMetricsServiceV2.addResponse(expectedResponse);
    ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
    LogMetric metric = LogMetric.newBuilder().build();
    LogMetric actualResponse = client.createLogMetric(parent, metric);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockMetricsServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateLogMetricRequest actualRequest = (CreateLogMetricRequest) actualRequests.get(0);
    Assert.assertEquals(parent, actualRequest.getParentAsParentNameOneof());
    Assert.assertEquals(metric, actualRequest.getMetric());
}
Also used : LogMetric(com.google.logging.v2.LogMetric) CreateLogMetricRequest(com.google.logging.v2.CreateLogMetricRequest) ParentNameOneof(com.google.logging.v2.ParentNameOneof) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 50 with GeneratedMessageV3

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

the class GroupServiceClientTest method listGroupMembersTest.

@Test
@SuppressWarnings("all")
public void listGroupMembersTest() {
    String nextPageToken = "";
    int totalSize = -705419236;
    MonitoredResource membersElement = MonitoredResource.newBuilder().build();
    List<MonitoredResource> members = Arrays.asList(membersElement);
    ListGroupMembersResponse expectedResponse = ListGroupMembersResponse.newBuilder().setNextPageToken(nextPageToken).setTotalSize(totalSize).addAllMembers(members).build();
    mockGroupService.addResponse(expectedResponse);
    GroupName name = GroupName.create("[PROJECT]", "[GROUP]");
    ListGroupMembersPagedResponse pagedListResponse = client.listGroupMembers(name);
    List<MonitoredResource> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getMembersList().get(0), resources.get(0));
    List<GeneratedMessageV3> actualRequests = mockGroupService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListGroupMembersRequest actualRequest = (ListGroupMembersRequest) actualRequests.get(0);
    Assert.assertEquals(name, actualRequest.getNameAsGroupName());
}
Also used : GroupName(com.google.monitoring.v3.GroupName) ListGroupMembersResponse(com.google.monitoring.v3.ListGroupMembersResponse) ListGroupMembersRequest(com.google.monitoring.v3.ListGroupMembersRequest) MonitoredResource(com.google.api.MonitoredResource) ListGroupMembersPagedResponse(com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListGroupMembersPagedResponse) 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