use of com.google.monitoring.v3.NotificationChannel in project java-monitoring by googleapis.
the class NotificationChannelServiceClientTest method getNotificationChannelTest.
@Test
public void getNotificationChannelTest() throws Exception {
NotificationChannel expectedResponse = NotificationChannel.newBuilder().setType("type3575610").setName(NotificationChannelName.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]").toString()).setDisplayName("displayName1714148973").setDescription("description-1724546052").putAllLabels(new HashMap<String, String>()).putAllUserLabels(new HashMap<String, String>()).setEnabled(BoolValue.newBuilder().build()).setCreationRecord(MutationRecord.newBuilder().build()).addAllMutationRecords(new ArrayList<MutationRecord>()).build();
mockNotificationChannelService.addResponse(expectedResponse);
NotificationChannelName name = NotificationChannelName.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]");
NotificationChannel actualResponse = client.getNotificationChannel(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetNotificationChannelRequest actualRequest = ((GetNotificationChannelRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.NotificationChannel in project java-monitoring by googleapis.
the class NotificationChannelServiceClientTest method createNotificationChannelExceptionTest.
@Test
public void createNotificationChannelExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockNotificationChannelService.addException(exception);
try {
FolderName name = FolderName.of("[FOLDER]");
NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
client.createNotificationChannel(name, notificationChannel);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.NotificationChannel 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