use of com.google.monitoring.v3.FolderName in project java-monitoring by googleapis.
the class MetricServiceClientTest method listMonitoredResourceDescriptorsTest.
@Test
public void listMonitoredResourceDescriptorsTest() throws Exception {
MonitoredResourceDescriptor responsesElement = MonitoredResourceDescriptor.newBuilder().build();
ListMonitoredResourceDescriptorsResponse expectedResponse = ListMonitoredResourceDescriptorsResponse.newBuilder().setNextPageToken("").addAllResourceDescriptors(Arrays.asList(responsesElement)).build();
mockMetricService.addResponse(expectedResponse);
FolderName name = FolderName.of("[FOLDER]");
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<AbstractMessage> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListMonitoredResourceDescriptorsRequest actualRequest = ((ListMonitoredResourceDescriptorsRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.FolderName in project java-monitoring by googleapis.
the class AlertPolicyServiceClientTest method listAlertPoliciesTest.
@Test
public void listAlertPoliciesTest() throws Exception {
AlertPolicy responsesElement = AlertPolicy.newBuilder().build();
ListAlertPoliciesResponse expectedResponse = ListAlertPoliciesResponse.newBuilder().setNextPageToken("").addAllAlertPolicies(Arrays.asList(responsesElement)).build();
mockAlertPolicyService.addResponse(expectedResponse);
FolderName name = FolderName.of("[FOLDER]");
ListAlertPoliciesPagedResponse pagedListResponse = client.listAlertPolicies(name);
List<AlertPolicy> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getAlertPoliciesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockAlertPolicyService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListAlertPoliciesRequest actualRequest = ((ListAlertPoliciesRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.FolderName in project java-monitoring by googleapis.
the class GroupServiceClientTest method createGroupTest.
@Test
public void createGroupTest() throws Exception {
Group expectedResponse = Group.newBuilder().setName(GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]").toString()).setDisplayName("displayName1714148973").setParentName("parentName-244870571").setFilter("filter-1274492040").setIsCluster(true).build();
mockGroupService.addResponse(expectedResponse);
FolderName name = FolderName.of("[FOLDER]");
Group group = Group.newBuilder().build();
Group actualResponse = client.createGroup(name, group);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockGroupService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateGroupRequest actualRequest = ((CreateGroupRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(group, actualRequest.getGroup());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.FolderName in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method listServicesTest.
@Test
public void listServicesTest() throws Exception {
Service responsesElement = Service.newBuilder().build();
ListServicesResponse expectedResponse = ListServicesResponse.newBuilder().setNextPageToken("").addAllServices(Arrays.asList(responsesElement)).build();
mockServiceMonitoringService.addResponse(expectedResponse);
FolderName parent = FolderName.of("[FOLDER]");
ListServicesPagedResponse pagedListResponse = client.listServices(parent);
List<Service> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListServicesRequest actualRequest = ((ListServicesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.FolderName in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method createServiceExceptionTest.
@Test
public void createServiceExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockServiceMonitoringService.addException(exception);
try {
FolderName parent = FolderName.of("[FOLDER]");
Service service = Service.newBuilder().build();
client.createService(parent, service);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations