Search in sources :

Example 26 with ProjectName

use of com.google.monitoring.v3.ProjectName in project google-cloud-java by GoogleCloudPlatform.

the class TopicAdminClientTest method listTopicsExceptionTest.

@Test
@SuppressWarnings("all")
public void listTopicsExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockPublisher.addException(exception);
    try {
        ProjectName project = ProjectName.create("[PROJECT]");
        client.listTopics(project);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : ProjectName(com.google.pubsub.v1.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 27 with ProjectName

use of com.google.monitoring.v3.ProjectName in project google-cloud-java by GoogleCloudPlatform.

the class SubscriptionAdminClientTest method listSubscriptionsExceptionTest.

@Test
@SuppressWarnings("all")
public void listSubscriptionsExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockSubscriber.addException(exception);
    try {
        ProjectName project = ProjectName.create("[PROJECT]");
        client.listSubscriptions(project);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : ProjectName(com.google.pubsub.v1.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)26 ApiException (com.google.api.gax.grpc.ApiException)13 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)13 StatusRuntimeException (io.grpc.StatusRuntimeException)13 ProjectName (com.google.monitoring.v3.ProjectName)12 ProjectName (com.google.devtools.clouderrorreporting.v1beta1.ProjectName)8 ProjectName (com.google.pubsub.v1.ProjectName)6 MetricDescriptor (com.google.api.MetricDescriptor)3 TimeSeries (com.google.monitoring.v3.TimeSeries)3 ByteString (com.google.protobuf.ByteString)3 QueryTimeRange (com.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange)2 ReportedErrorEvent (com.google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent)2 CreateTimeSeriesRequest (com.google.monitoring.v3.CreateTimeSeriesRequest)2 Group (com.google.monitoring.v3.Group)2 ListTimeSeriesRequest (com.google.monitoring.v3.ListTimeSeriesRequest)2 TimeSeriesView (com.google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView)2 TimeInterval (com.google.monitoring.v3.TimeInterval)2 ArrayList (java.util.ArrayList)2 MonitoredResourceDescriptor (com.google.api.MonitoredResourceDescriptor)1 ListEventsPagedResponse (com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListEventsPagedResponse)1