use of com.google.monitoring.v3.CreateMetricDescriptorRequest in project google-cloud-java by GoogleCloudPlatform.
the class MetricServiceClientTest method createMetricDescriptorTest.
@Test
@SuppressWarnings("all")
public void createMetricDescriptorTest() {
String name2 = "name2-1052831874";
String type = "type3575610";
String unit = "unit3594628";
String description = "description-1724546052";
String displayName = "displayName1615086568";
MetricDescriptor expectedResponse = MetricDescriptor.newBuilder().setName(name2).setType(type).setUnit(unit).setDescription(description).setDisplayName(displayName).build();
mockMetricService.addResponse(expectedResponse);
ProjectName name = ProjectName.create("[PROJECT]");
MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build();
MetricDescriptor actualResponse = client.createMetricDescriptor(name, metricDescriptor);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateMetricDescriptorRequest actualRequest = (CreateMetricDescriptorRequest) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsProjectName());
Assert.assertEquals(metricDescriptor, actualRequest.getMetricDescriptor());
}
Aggregations