use of com.google.api.gax.grpc.ApiException in project google-cloud-java by GoogleCloudPlatform.
the class ConfigClientTest method deleteSinkExceptionTest.
@Test
@SuppressWarnings("all")
public void deleteSinkExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
client.deleteSink(sinkName);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.api.gax.grpc.ApiException 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.api.gax.grpc.ApiException in project google-cloud-java by GoogleCloudPlatform.
the class LoggingClientTest method writeLogEntriesExceptionTest.
@Test
@SuppressWarnings("all")
public void writeLogEntriesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockLoggingServiceV2.addException(exception);
try {
LogNameOneof logName = LogNameOneof.from(LogName.create("[PROJECT]", "[LOG]"));
MonitoredResource resource = MonitoredResource.newBuilder().build();
Map<String, String> labels = new HashMap<>();
List<LogEntry> entries = new ArrayList<>();
client.writeLogEntries(logName, resource, labels, entries);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.api.gax.grpc.ApiException 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.api.gax.grpc.ApiException in project google-cloud-java by GoogleCloudPlatform.
the class TraceServiceClientTest method getTraceExceptionTest.
@Test
@SuppressWarnings("all")
public void getTraceExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockTraceService.addException(exception);
try {
String projectId = "projectId-1969970175";
String traceId = "traceId1270300245";
client.getTrace(projectId, traceId);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations