@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
/** * * * <pre> * The definition of the `NotificationChannel` to create. * </pre> * * <code>.google.monitoring.v3.NotificationChannel notification_channel = 2;</code> */ public Builder mergeNotificationChannel(com.google.monitoring.v3.NotificationChannel value) { if (notificationChannelBuilder_ == null) { if (notificationChannel_ != null) { notificationChannel_ = com.google.monitoring.v3.NotificationChannel.newBuilder(notificationChannel_) .mergeFrom(value) .buildPartial(); } else { notificationChannel_ = value; } onChanged(); } else { notificationChannelBuilder_.mergeFrom(value); } return this; } /**
/** * * * <pre> * A description of the changes to be applied to the specified * notification channel. The description must provide a definition for * fields to be updated; the names of these fields should also be * included in the `update_mask`. * </pre> * * <code>.google.monitoring.v3.NotificationChannel notification_channel = 3;</code> */ public Builder mergeNotificationChannel(com.google.monitoring.v3.NotificationChannel value) { if (notificationChannelBuilder_ == null) { if (notificationChannel_ != null) { notificationChannel_ = com.google.monitoring.v3.NotificationChannel.newBuilder(notificationChannel_) .mergeFrom(value) .buildPartial(); } else { notificationChannel_ = value; } onChanged(); } else { notificationChannelBuilder_.mergeFrom(value); } return this; } /**
@Test @SuppressWarnings("all") public void createNotificationChannelExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockNotificationChannelService.addException(exception); try { ProjectName name = ProjectName.of("[PROJECT]"); NotificationChannel notificationChannel = NotificationChannel.newBuilder().build(); client.createNotificationChannel(name, notificationChannel); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void listNotificationChannelsTest() { String nextPageToken = ""; NotificationChannel notificationChannelsElement = NotificationChannel.newBuilder().build(); List<NotificationChannel> notificationChannels = Arrays.asList(notificationChannelsElement); ListNotificationChannelsResponse expectedResponse = ListNotificationChannelsResponse.newBuilder() .setNextPageToken(nextPageToken) .addAllNotificationChannels(notificationChannels) .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<GeneratedMessageV3> actualRequests = mockNotificationChannelService.getRequests(); Assert.assertEquals(1, actualRequests.size()); ListNotificationChannelsRequest actualRequest = (ListNotificationChannelsRequest) actualRequests.get(0); Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void updateNotificationChannelExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockNotificationChannelService.addException(exception); try { FieldMask updateMask = FieldMask.newBuilder().build(); NotificationChannel notificationChannel = NotificationChannel.newBuilder().build(); client.updateNotificationChannel(updateMask, notificationChannel); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
String description = "description-1724546052"; NotificationChannel expectedResponse = NotificationChannel.newBuilder() .setType(type) .setName(name2) NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
String description = "description-1724546052"; NotificationChannel expectedResponse = NotificationChannel.newBuilder() .setType(type) .setName(name) NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
@Test @SuppressWarnings("all") public void getNotificationChannelTest() { String type = "type3575610"; String name2 = "name2-1052831874"; String displayName = "displayName1615086568"; String description = "description-1724546052"; NotificationChannel expectedResponse = NotificationChannel.newBuilder() .setType(type) .setName(name2) .setDisplayName(displayName) .setDescription(description) .build(); mockNotificationChannelService.addResponse(expectedResponse); NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]"); NotificationChannel actualResponse = client.getNotificationChannel(name); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockNotificationChannelService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetNotificationChannelRequest actualRequest = (GetNotificationChannelRequest) actualRequests.get(0); Assert.assertEquals(name, NotificationChannelName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }