Search in sources :

Example 1 with ListMetricDescriptorsPagedResponse

use of com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListMetricDescriptorsPagedResponse in project google-cloud-java by GoogleCloudPlatform.

the class MetricServiceClientTest method listMetricDescriptorsTest.

@Test
@SuppressWarnings("all")
public void listMetricDescriptorsTest() {
    String nextPageToken = "";
    MetricDescriptor metricDescriptorsElement = MetricDescriptor.newBuilder().build();
    List<MetricDescriptor> metricDescriptors = Arrays.asList(metricDescriptorsElement);
    ListMetricDescriptorsResponse expectedResponse = ListMetricDescriptorsResponse.newBuilder().setNextPageToken(nextPageToken).addAllMetricDescriptors(metricDescriptors).build();
    mockMetricService.addResponse(expectedResponse);
    ProjectName name = ProjectName.create("[PROJECT]");
    ListMetricDescriptorsPagedResponse pagedListResponse = client.listMetricDescriptors(name);
    List<MetricDescriptor> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getMetricDescriptorsList().get(0), resources.get(0));
    List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListMetricDescriptorsRequest actualRequest = (ListMetricDescriptorsRequest) actualRequests.get(0);
    Assert.assertEquals(name, actualRequest.getNameAsProjectName());
}
Also used : MetricDescriptor(com.google.api.MetricDescriptor) ProjectName(com.google.monitoring.v3.ProjectName) ListMetricDescriptorsRequest(com.google.monitoring.v3.ListMetricDescriptorsRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) ListMetricDescriptorsResponse(com.google.monitoring.v3.ListMetricDescriptorsResponse) ListMetricDescriptorsPagedResponse(com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListMetricDescriptorsPagedResponse) Test(org.junit.Test)

Aggregations

MetricDescriptor (com.google.api.MetricDescriptor)1 ListMetricDescriptorsPagedResponse (com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListMetricDescriptorsPagedResponse)1 ListMetricDescriptorsRequest (com.google.monitoring.v3.ListMetricDescriptorsRequest)1 ListMetricDescriptorsResponse (com.google.monitoring.v3.ListMetricDescriptorsResponse)1 ProjectName (com.google.monitoring.v3.ProjectName)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 Test (org.junit.Test)1