use of com.google.monitoring.v3.ListNotificationChannelsResponse in project java-monitoring by googleapis.
the class NotificationChannelServiceClientTest method listNotificationChannelsTest3.
@Test
public void listNotificationChannelsTest3() throws Exception {
NotificationChannel responsesElement = NotificationChannel.newBuilder().build();
ListNotificationChannelsResponse expectedResponse = ListNotificationChannelsResponse.newBuilder().setNextPageToken("").addAllNotificationChannels(Arrays.asList(responsesElement)).build();
mockNotificationChannelService.addResponse(expectedResponse);
ProjectName name = ProjectName.of("[PROJECT]");
ListNotificationChannelsPagedResponse pagedListResponse = client.listNotificationChannels(name);
List<NotificationChannel> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getNotificationChannelsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListNotificationChannelsRequest actualRequest = ((ListNotificationChannelsRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.ListNotificationChannelsResponse in project java-monitoring by googleapis.
the class NotificationChannelServiceClientTest method listNotificationChannelsTest2.
@Test
public void listNotificationChannelsTest2() throws Exception {
NotificationChannel responsesElement = NotificationChannel.newBuilder().build();
ListNotificationChannelsResponse expectedResponse = ListNotificationChannelsResponse.newBuilder().setNextPageToken("").addAllNotificationChannels(Arrays.asList(responsesElement)).build();
mockNotificationChannelService.addResponse(expectedResponse);
OrganizationName name = OrganizationName.of("[ORGANIZATION]");
ListNotificationChannelsPagedResponse pagedListResponse = client.listNotificationChannels(name);
List<NotificationChannel> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getNotificationChannelsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListNotificationChannelsRequest actualRequest = ((ListNotificationChannelsRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.ListNotificationChannelsResponse in project java-docs-samples by GoogleCloudPlatform.
the class AlertSample method getNotificationChannels.
private List<NotificationChannel> getNotificationChannels(String projectId) {
List<NotificationChannel> notificationChannels = Lists.newArrayList();
ListNotificationChannelsPagedResponse listNotificationChannelsResponse = notificationChannelClient.listNotificationChannels(ProjectName.of(projectId));
for (NotificationChannel channel : listNotificationChannelsResponse.iterateAll()) {
notificationChannels.add(channel);
}
return notificationChannels;
}
use of com.google.monitoring.v3.ListNotificationChannelsResponse in project java-monitoring by googleapis.
the class NotificationChannelServiceClientTest method listNotificationChannelsTest4.
@Test
public void listNotificationChannelsTest4() throws Exception {
NotificationChannel responsesElement = NotificationChannel.newBuilder().build();
ListNotificationChannelsResponse expectedResponse = ListNotificationChannelsResponse.newBuilder().setNextPageToken("").addAllNotificationChannels(Arrays.asList(responsesElement)).build();
mockNotificationChannelService.addResponse(expectedResponse);
String name = "name3373707";
ListNotificationChannelsPagedResponse pagedListResponse = client.listNotificationChannels(name);
List<NotificationChannel> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getNotificationChannelsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListNotificationChannelsRequest actualRequest = ((ListNotificationChannelsRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.ListNotificationChannelsResponse in project java-monitoring by googleapis.
the class NotificationChannelServiceClientTest method listNotificationChannelsTest.
@Test
public void listNotificationChannelsTest() throws Exception {
NotificationChannel responsesElement = NotificationChannel.newBuilder().build();
ListNotificationChannelsResponse expectedResponse = ListNotificationChannelsResponse.newBuilder().setNextPageToken("").addAllNotificationChannels(Arrays.asList(responsesElement)).build();
mockNotificationChannelService.addResponse(expectedResponse);
FolderName name = FolderName.of("[FOLDER]");
ListNotificationChannelsPagedResponse pagedListResponse = client.listNotificationChannels(name);
List<NotificationChannel> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getNotificationChannelsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListNotificationChannelsRequest actualRequest = ((ListNotificationChannelsRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations