Search in sources :

Example 6 with MetricNameOneof

use of com.google.logging.v2.MetricNameOneof in project google-cloud-java by GoogleCloudPlatform.

the class MetricsClientTest method deleteLogMetricExceptionTest.

@Test
@SuppressWarnings("all")
public void deleteLogMetricExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockMetricsServiceV2.addException(exception);
    try {
        MetricNameOneof metricName = MetricNameOneof.from(MetricName.create("[PROJECT]", "[METRIC]"));
        client.deleteLogMetric(metricName);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : MetricNameOneof(com.google.logging.v2.MetricNameOneof) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 7 with MetricNameOneof

use of com.google.logging.v2.MetricNameOneof in project google-cloud-java by GoogleCloudPlatform.

the class MetricsClientTest method getLogMetricExceptionTest.

@Test
@SuppressWarnings("all")
public void getLogMetricExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockMetricsServiceV2.addException(exception);
    try {
        MetricNameOneof metricName = MetricNameOneof.from(MetricName.create("[PROJECT]", "[METRIC]"));
        client.getLogMetric(metricName);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : MetricNameOneof(com.google.logging.v2.MetricNameOneof) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Aggregations

MetricNameOneof (com.google.logging.v2.MetricNameOneof)6 Test (org.junit.Test)6 ApiException (com.google.api.gax.grpc.ApiException)3 LogMetric (com.google.logging.v2.LogMetric)3 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)3 StatusRuntimeException (io.grpc.StatusRuntimeException)3 DeleteLogMetricRequest (com.google.logging.v2.DeleteLogMetricRequest)2 GetLogMetricRequest (com.google.logging.v2.GetLogMetricRequest)1 UpdateLogMetricRequest (com.google.logging.v2.UpdateLogMetricRequest)1 Empty (com.google.protobuf.Empty)1