Search in sources :

Example 36 with ProjectName

use of com.google.cloud.secretmanager.v1.ProjectName in project java-logging by googleapis.

the class ConfigClientTest method createSinkExceptionTest4.

@Test
public void createSinkExceptionTest4() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        LogSink sink = LogSink.newBuilder().build();
        client.createSink(parent, sink);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : LogSink(com.google.logging.v2.LogSink) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.logging.v2.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 37 with ProjectName

use of com.google.cloud.secretmanager.v1.ProjectName in project java-logging by googleapis.

the class ConfigClientTest method createExclusionExceptionTest4.

@Test
public void createExclusionExceptionTest4() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        LogExclusion exclusion = LogExclusion.newBuilder().build();
        client.createExclusion(parent, exclusion);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.logging.v2.ProjectName) LogExclusion(com.google.logging.v2.LogExclusion) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 38 with ProjectName

use of com.google.cloud.secretmanager.v1.ProjectName in project java-logging by googleapis.

the class LoggingClientTest method listLogsExceptionTest4.

@Test
public void listLogsExceptionTest4() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockLoggingServiceV2.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        client.listLogs(parent);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.logging.v2.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 39 with ProjectName

use of com.google.cloud.secretmanager.v1.ProjectName in project java-logging by googleapis.

the class ConfigClientTest method listSinksExceptionTest4.

@Test
public void listSinksExceptionTest4() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        client.listSinks(parent);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.logging.v2.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 40 with ProjectName

use of com.google.cloud.secretmanager.v1.ProjectName in project java-logging by googleapis.

the class MetricsClientTest method listLogMetricsExceptionTest.

@Test
public void listLogMetricsExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockMetricsServiceV2.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        client.listLogMetrics(parent);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.logging.v2.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)147 StatusRuntimeException (io.grpc.StatusRuntimeException)73 ProjectName (com.google.monitoring.v3.ProjectName)62 AbstractMessage (com.google.protobuf.AbstractMessage)61 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)58 ProjectName (com.google.pubsub.v1.ProjectName)30 ArrayList (java.util.ArrayList)29 ProjectName (com.google.privacy.dlp.v2.ProjectName)22 ByteString (com.google.protobuf.ByteString)18 DataTransferServiceClient (com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient)17 ProjectName (com.google.cloud.bigquery.datatransfer.v1.ProjectName)17 IOException (java.io.IOException)17 CreateTransferConfigRequest (com.google.cloud.bigquery.datatransfer.v1.CreateTransferConfigRequest)16 TransferConfig (com.google.cloud.bigquery.datatransfer.v1.TransferConfig)16 ProjectName (com.google.cloud.secretmanager.v1.ProjectName)16 ProjectName (com.google.containeranalysis.v1beta1.ProjectName)16 ApiException (com.google.api.gax.rpc.ApiException)15 MetricServiceClient (com.google.cloud.monitoring.v3.MetricServiceClient)15 TimeSeries (com.google.monitoring.v3.TimeSeries)15 ProjectName (com.google.logging.v2.ProjectName)14