Search in sources :

Example 1 with ListLogMetricsPagedResponse

use of com.google.cloud.logging.v2.MetricsClient.ListLogMetricsPagedResponse in project java-logging by googleapis.

the class MetricsClientTest method listLogMetricsTest2.

@Test
public void listLogMetricsTest2() throws Exception {
    LogMetric responsesElement = LogMetric.newBuilder().build();
    ListLogMetricsResponse expectedResponse = ListLogMetricsResponse.newBuilder().setNextPageToken("").addAllMetrics(Arrays.asList(responsesElement)).build();
    mockMetricsServiceV2.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListLogMetricsPagedResponse pagedListResponse = client.listLogMetrics(parent);
    List<LogMetric> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getMetricsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockMetricsServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListLogMetricsRequest actualRequest = ((ListLogMetricsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) LogMetric(com.google.logging.v2.LogMetric) ListLogMetricsResponse(com.google.logging.v2.ListLogMetricsResponse) ListLogMetricsPagedResponse(com.google.cloud.logging.v2.MetricsClient.ListLogMetricsPagedResponse) ListLogMetricsRequest(com.google.logging.v2.ListLogMetricsRequest) Test(org.junit.Test)

Example 2 with ListLogMetricsPagedResponse

use of com.google.cloud.logging.v2.MetricsClient.ListLogMetricsPagedResponse in project java-logging by googleapis.

the class MetricsClientTest method listLogMetricsTest.

@Test
public void listLogMetricsTest() throws Exception {
    LogMetric responsesElement = LogMetric.newBuilder().build();
    ListLogMetricsResponse expectedResponse = ListLogMetricsResponse.newBuilder().setNextPageToken("").addAllMetrics(Arrays.asList(responsesElement)).build();
    mockMetricsServiceV2.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListLogMetricsPagedResponse pagedListResponse = client.listLogMetrics(parent);
    List<LogMetric> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getMetricsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockMetricsServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListLogMetricsRequest actualRequest = ((ListLogMetricsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) LogMetric(com.google.logging.v2.LogMetric) ListLogMetricsResponse(com.google.logging.v2.ListLogMetricsResponse) ProjectName(com.google.logging.v2.ProjectName) ListLogMetricsPagedResponse(com.google.cloud.logging.v2.MetricsClient.ListLogMetricsPagedResponse) ListLogMetricsRequest(com.google.logging.v2.ListLogMetricsRequest) Test(org.junit.Test)

Aggregations

ListLogMetricsPagedResponse (com.google.cloud.logging.v2.MetricsClient.ListLogMetricsPagedResponse)2 ListLogMetricsRequest (com.google.logging.v2.ListLogMetricsRequest)2 ListLogMetricsResponse (com.google.logging.v2.ListLogMetricsResponse)2 LogMetric (com.google.logging.v2.LogMetric)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 ProjectName (com.google.logging.v2.ProjectName)1