use of com.google.logging.v2.ParentNameOneof in project google-cloud-java by GoogleCloudPlatform.
the class ConfigClientTest method createSinkTest.
@Test
@SuppressWarnings("all")
public void createSinkTest() {
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);
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
LogSink sink = LogSink.newBuilder().build();
LogSink actualResponse = client.createSink(parent, sink);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateSinkRequest actualRequest = (CreateSinkRequest) actualRequests.get(0);
Assert.assertEquals(parent, actualRequest.getParentAsParentNameOneof());
Assert.assertEquals(sink, actualRequest.getSink());
}
use of com.google.logging.v2.ParentNameOneof in project google-cloud-java by GoogleCloudPlatform.
the class ConfigClientTest method createSinkExceptionTest.
@Test
@SuppressWarnings("all")
public void createSinkExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
LogSink sink = LogSink.newBuilder().build();
client.createSink(parent, sink);
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 MetricsClientTest method listLogMetricsExceptionTest.
@Test
@SuppressWarnings("all")
public void listLogMetricsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockMetricsServiceV2.addException(exception);
try {
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
client.listLogMetrics(parent);
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 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.logging.v2.ParentNameOneof in project google-cloud-java by GoogleCloudPlatform.
the class LoggingClientTest method listLogsExceptionTest.
@Test
@SuppressWarnings("all")
public void listLogsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockLoggingServiceV2.addException(exception);
try {
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
client.listLogs(parent);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations