Search in sources :

Example 11 with LogMetric

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

the class LoggingImplTest method testUpdateMetric.

@Test
public void testUpdateMetric() {
    LogMetric sinkPb = METRIC_INFO.toPb();
    ApiFuture<LogMetric> response = ApiFutures.immediateFuture(sinkPb);
    UpdateLogMetricRequest request = UpdateLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).setMetric(sinkPb).build();
    EasyMock.expect(loggingRpcMock.update(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    Metric sink = logging.update(METRIC_INFO);
    assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), sink);
}
Also used : UpdateLogMetricRequest(com.google.logging.v2.UpdateLogMetricRequest) LogMetric(com.google.logging.v2.LogMetric) LogMetric(com.google.logging.v2.LogMetric) Test(org.junit.Test)

Example 12 with LogMetric

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

the class LoggingImplTest method testUpdateMetricAsync.

@Test
public void testUpdateMetricAsync() throws ExecutionException, InterruptedException {
    LogMetric sinkPb = METRIC_INFO.toPb();
    ApiFuture<LogMetric> response = ApiFutures.immediateFuture(sinkPb);
    UpdateLogMetricRequest request = UpdateLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).setMetric(sinkPb).build();
    EasyMock.expect(loggingRpcMock.update(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    Metric sink = logging.updateAsync(METRIC_INFO).get();
    assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), sink);
}
Also used : UpdateLogMetricRequest(com.google.logging.v2.UpdateLogMetricRequest) LogMetric(com.google.logging.v2.LogMetric) LogMetric(com.google.logging.v2.LogMetric) Test(org.junit.Test)

Example 13 with LogMetric

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

the class LoggingImplTest method testCreateMetric.

@Test
public void testCreateMetric() {
    LogMetric metricPb = METRIC_INFO.toPb();
    ApiFuture<LogMetric> response = ApiFutures.immediateFuture(metricPb);
    CreateLogMetricRequest request = CreateLogMetricRequest.newBuilder().setParent(PROJECT_PB).setMetric(metricPb).build();
    EasyMock.expect(loggingRpcMock.create(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    Metric metric = logging.create(METRIC_INFO);
    assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), metric);
}
Also used : LogMetric(com.google.logging.v2.LogMetric) CreateLogMetricRequest(com.google.logging.v2.CreateLogMetricRequest) LogMetric(com.google.logging.v2.LogMetric) Test(org.junit.Test)

Example 14 with LogMetric

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

the class LoggingImplTest method testGetMetric.

@Test
public void testGetMetric() {
    LogMetric sinkPb = METRIC_INFO.toPb();
    ApiFuture<LogMetric> response = ApiFutures.immediateFuture(sinkPb);
    GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build();
    EasyMock.expect(loggingRpcMock.get(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    Metric sink = logging.getMetric(METRIC_NAME);
    assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), sink);
}
Also used : LogMetric(com.google.logging.v2.LogMetric) GetLogMetricRequest(com.google.logging.v2.GetLogMetricRequest) LogMetric(com.google.logging.v2.LogMetric) Test(org.junit.Test)

Aggregations

LogMetric (com.google.logging.v2.LogMetric)14 Test (org.junit.Test)14 GetLogMetricRequest (com.google.logging.v2.GetLogMetricRequest)5 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)4 CreateLogMetricRequest (com.google.logging.v2.CreateLogMetricRequest)3 MetricNameOneof (com.google.logging.v2.MetricNameOneof)3 ParentNameOneof (com.google.logging.v2.ParentNameOneof)3 UpdateLogMetricRequest (com.google.logging.v2.UpdateLogMetricRequest)3 ApiException (com.google.api.gax.grpc.ApiException)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 ListLogMetricsPagedResponse (com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogMetricsPagedResponse)1 ListLogMetricsRequest (com.google.logging.v2.ListLogMetricsRequest)1 ListLogMetricsResponse (com.google.logging.v2.ListLogMetricsResponse)1