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());
}
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());
}
Aggregations