use of com.google.logging.v2.ParentNameOneof 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.logging.v2.ParentNameOneof 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.logging.v2.ParentNameOneof 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.logging.v2.ParentNameOneof in project google-cloud-java by GoogleCloudPlatform.
the class MetricsClientTest method createLogMetricExceptionTest.
@Test
@SuppressWarnings("all")
public void createLogMetricExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockMetricsServiceV2.addException(exception);
try {
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
LogMetric metric = LogMetric.newBuilder().build();
client.createLogMetric(parent, metric);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.logging.v2.ParentNameOneof in project google-cloud-java by GoogleCloudPlatform.
the class ConfigClientTest method listSinksExceptionTest.
@Test
@SuppressWarnings("all")
public void listSinksExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
client.listSinks(parent);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations