Search in sources :

Example 1 with ListNotificationChannelsResponse

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()));
}
Also used : NotificationChannel(com.google.monitoring.v3.NotificationChannel) ListNotificationChannelsResponse(com.google.monitoring.v3.ListNotificationChannelsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.monitoring.v3.ProjectName) ListNotificationChannelsRequest(com.google.monitoring.v3.ListNotificationChannelsRequest) ListNotificationChannelsPagedResponse(com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelsPagedResponse) Test(org.junit.Test)

Example 2 with ListNotificationChannelsResponse

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()));
}
Also used : NotificationChannel(com.google.monitoring.v3.NotificationChannel) OrganizationName(com.google.monitoring.v3.OrganizationName) ListNotificationChannelsResponse(com.google.monitoring.v3.ListNotificationChannelsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListNotificationChannelsRequest(com.google.monitoring.v3.ListNotificationChannelsRequest) ListNotificationChannelsPagedResponse(com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelsPagedResponse) Test(org.junit.Test)

Example 3 with ListNotificationChannelsResponse

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;
}
Also used : NotificationChannel(com.google.monitoring.v3.NotificationChannel) ListNotificationChannelsPagedResponse(com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelsPagedResponse)

Example 4 with ListNotificationChannelsResponse

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()));
}
Also used : NotificationChannel(com.google.monitoring.v3.NotificationChannel) ListNotificationChannelsResponse(com.google.monitoring.v3.ListNotificationChannelsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListNotificationChannelsRequest(com.google.monitoring.v3.ListNotificationChannelsRequest) ListNotificationChannelsPagedResponse(com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelsPagedResponse) Test(org.junit.Test)

Example 5 with ListNotificationChannelsResponse

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()));
}
Also used : NotificationChannel(com.google.monitoring.v3.NotificationChannel) ListNotificationChannelsResponse(com.google.monitoring.v3.ListNotificationChannelsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListNotificationChannelsRequest(com.google.monitoring.v3.ListNotificationChannelsRequest) ListNotificationChannelsPagedResponse(com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelsPagedResponse) FolderName(com.google.monitoring.v3.FolderName) Test(org.junit.Test)

Aggregations

ListNotificationChannelsPagedResponse (com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelsPagedResponse)5 NotificationChannel (com.google.monitoring.v3.NotificationChannel)5 ListNotificationChannelsRequest (com.google.monitoring.v3.ListNotificationChannelsRequest)4 ListNotificationChannelsResponse (com.google.monitoring.v3.ListNotificationChannelsResponse)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 FolderName (com.google.monitoring.v3.FolderName)1 OrganizationName (com.google.monitoring.v3.OrganizationName)1 ProjectName (com.google.monitoring.v3.ProjectName)1