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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations