use of com.google.monitoring.v3.ListAlertPoliciesResponse in project java-monitoring by googleapis.
the class AlertPolicyServiceClientTest method listAlertPoliciesTest2.
@Test
public void listAlertPoliciesTest2() throws Exception {
AlertPolicy responsesElement = AlertPolicy.newBuilder().build();
ListAlertPoliciesResponse expectedResponse = ListAlertPoliciesResponse.newBuilder().setNextPageToken("").addAllAlertPolicies(Arrays.asList(responsesElement)).build();
mockAlertPolicyService.addResponse(expectedResponse);
OrganizationName name = OrganizationName.of("[ORGANIZATION]");
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.ListAlertPoliciesResponse in project java-monitoring by googleapis.
the class AlertPolicyServiceClientTest method listAlertPoliciesTest3.
@Test
public void listAlertPoliciesTest3() throws Exception {
AlertPolicy responsesElement = AlertPolicy.newBuilder().build();
ListAlertPoliciesResponse expectedResponse = ListAlertPoliciesResponse.newBuilder().setNextPageToken("").addAllAlertPolicies(Arrays.asList(responsesElement)).build();
mockAlertPolicyService.addResponse(expectedResponse);
ProjectName name = ProjectName.of("[PROJECT]");
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.ListAlertPoliciesResponse 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.ListAlertPoliciesResponse in project java-monitoring by googleapis.
the class AlertPolicyServiceClientTest method listAlertPoliciesTest4.
@Test
public void listAlertPoliciesTest4() throws Exception {
AlertPolicy responsesElement = AlertPolicy.newBuilder().build();
ListAlertPoliciesResponse expectedResponse = ListAlertPoliciesResponse.newBuilder().setNextPageToken("").addAllAlertPolicies(Arrays.asList(responsesElement)).build();
mockAlertPolicyService.addResponse(expectedResponse);
String name = "name3373707";
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, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations