use of com.google.api.gax.grpc.ApiException in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method listSnapshotsExceptionTest.
@Test
@SuppressWarnings("all")
public void listSnapshotsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockSubscriber.addException(exception);
try {
ProjectName project = ProjectName.create("[PROJECT]");
client.listSnapshots(project);
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 SubscriptionAdminClientTest method deleteSubscriptionExceptionTest.
@Test
@SuppressWarnings("all")
public void deleteSubscriptionExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockSubscriber.addException(exception);
try {
SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
client.deleteSubscription(subscription);
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 MetricServiceClientTest method createTimeSeriesExceptionTest.
@Test
@SuppressWarnings("all")
public void createTimeSeriesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockMetricService.addException(exception);
try {
ProjectName name = ProjectName.create("[PROJECT]");
List<TimeSeries> timeSeries = new ArrayList<>();
client.createTimeSeries(name, timeSeries);
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 MetricServiceClientTest method listMonitoredResourceDescriptorsExceptionTest.
@Test
@SuppressWarnings("all")
public void listMonitoredResourceDescriptorsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockMetricService.addException(exception);
try {
ProjectName name = ProjectName.create("[PROJECT]");
client.listMonitoredResourceDescriptors(name);
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 SubscriptionAdminClientTest method testIamPermissionsExceptionTest.
@Test
@SuppressWarnings("all")
public void testIamPermissionsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockIAMPolicy.addException(exception);
try {
String formattedResource = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]").toString();
List<String> permissions = new ArrayList<>();
client.testIamPermissions(formattedResource, permissions);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations