Search in sources :

Example 1 with MonitoredResourceDescriptor

use of com.google.api.MonitoredResourceDescriptor in project google-cloud-java by GoogleCloudPlatform.

the class MetricServiceClientTest method listMonitoredResourceDescriptorsTest.

@Test
@SuppressWarnings("all")
public void listMonitoredResourceDescriptorsTest() {
    String nextPageToken = "";
    MonitoredResourceDescriptor resourceDescriptorsElement = MonitoredResourceDescriptor.newBuilder().build();
    List<MonitoredResourceDescriptor> resourceDescriptors = Arrays.asList(resourceDescriptorsElement);
    ListMonitoredResourceDescriptorsResponse expectedResponse = ListMonitoredResourceDescriptorsResponse.newBuilder().setNextPageToken(nextPageToken).addAllResourceDescriptors(resourceDescriptors).build();
    mockMetricService.addResponse(expectedResponse);
    ProjectName name = ProjectName.create("[PROJECT]");
    ListMonitoredResourceDescriptorsPagedResponse pagedListResponse = client.listMonitoredResourceDescriptors(name);
    List<MonitoredResourceDescriptor> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getResourceDescriptorsList().get(0), resources.get(0));
    List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListMonitoredResourceDescriptorsRequest actualRequest = (ListMonitoredResourceDescriptorsRequest) actualRequests.get(0);
    Assert.assertEquals(name, actualRequest.getNameAsProjectName());
}
Also used : ListMonitoredResourceDescriptorsResponse(com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse) ProjectName(com.google.monitoring.v3.ProjectName) ListMonitoredResourceDescriptorsRequest(com.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest) MonitoredResourceDescriptor(com.google.api.MonitoredResourceDescriptor) ListMonitoredResourceDescriptorsPagedResponse(com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListMonitoredResourceDescriptorsPagedResponse) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 2 with MonitoredResourceDescriptor

use of com.google.api.MonitoredResourceDescriptor in project google-cloud-java by GoogleCloudPlatform.

the class MetricServiceClientTest method getMonitoredResourceDescriptorTest.

@Test
@SuppressWarnings("all")
public void getMonitoredResourceDescriptorTest() {
    String name2 = "name2-1052831874";
    String type = "type3575610";
    String displayName = "displayName1615086568";
    String description = "description-1724546052";
    MonitoredResourceDescriptor expectedResponse = MonitoredResourceDescriptor.newBuilder().setName(name2).setType(type).setDisplayName(displayName).setDescription(description).build();
    mockMetricService.addResponse(expectedResponse);
    MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.create("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
    MonitoredResourceDescriptor actualResponse = client.getMonitoredResourceDescriptor(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetMonitoredResourceDescriptorRequest actualRequest = (GetMonitoredResourceDescriptorRequest) actualRequests.get(0);
    Assert.assertEquals(name, actualRequest.getNameAsMonitoredResourceDescriptorName());
}
Also used : MonitoredResourceDescriptorName(com.google.monitoring.v3.MonitoredResourceDescriptorName) MonitoredResourceDescriptor(com.google.api.MonitoredResourceDescriptor) GetMonitoredResourceDescriptorRequest(com.google.monitoring.v3.GetMonitoredResourceDescriptorRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Aggregations

MonitoredResourceDescriptor (com.google.api.MonitoredResourceDescriptor)2 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)2 Test (org.junit.Test)2 ListMonitoredResourceDescriptorsPagedResponse (com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListMonitoredResourceDescriptorsPagedResponse)1 GetMonitoredResourceDescriptorRequest (com.google.monitoring.v3.GetMonitoredResourceDescriptorRequest)1 ListMonitoredResourceDescriptorsRequest (com.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest)1 ListMonitoredResourceDescriptorsResponse (com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse)1 MonitoredResourceDescriptorName (com.google.monitoring.v3.MonitoredResourceDescriptorName)1 ProjectName (com.google.monitoring.v3.ProjectName)1