Search in sources :

Example 1 with CreateNotificationChannelRequest

use of com.google.monitoring.v3.CreateNotificationChannelRequest in project java-monitoring by googleapis.

the class NotificationChannelServiceClientTest method createNotificationChannelTest.

@Test
public void createNotificationChannelTest() 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);
    FolderName name = FolderName.of("[FOLDER]");
    NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
    NotificationChannel actualResponse = client.createNotificationChannel(name, notificationChannel);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateNotificationChannelRequest actualRequest = ((CreateNotificationChannelRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(notificationChannel, actualRequest.getNotificationChannel());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : NotificationChannel(com.google.monitoring.v3.NotificationChannel) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FolderName(com.google.monitoring.v3.FolderName) CreateNotificationChannelRequest(com.google.monitoring.v3.CreateNotificationChannelRequest) Test(org.junit.Test)

Example 2 with CreateNotificationChannelRequest

use of com.google.monitoring.v3.CreateNotificationChannelRequest in project java-monitoring by googleapis.

the class NotificationChannelServiceClientTest method createNotificationChannelTest3.

@Test
public void createNotificationChannelTest3() 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);
    ProjectName name = ProjectName.of("[PROJECT]");
    NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
    NotificationChannel actualResponse = client.createNotificationChannel(name, notificationChannel);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateNotificationChannelRequest actualRequest = ((CreateNotificationChannelRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(notificationChannel, actualRequest.getNotificationChannel());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : NotificationChannel(com.google.monitoring.v3.NotificationChannel) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) ProjectName(com.google.monitoring.v3.ProjectName) ArrayList(java.util.ArrayList) CreateNotificationChannelRequest(com.google.monitoring.v3.CreateNotificationChannelRequest) Test(org.junit.Test)

Example 3 with CreateNotificationChannelRequest

use of com.google.monitoring.v3.CreateNotificationChannelRequest in project java-monitoring by googleapis.

the class NotificationChannelServiceClientTest method createNotificationChannelTest4.

@Test
public void createNotificationChannelTest4() 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);
    String name = "name3373707";
    NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
    NotificationChannel actualResponse = client.createNotificationChannel(name, notificationChannel);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateNotificationChannelRequest actualRequest = ((CreateNotificationChannelRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertEquals(notificationChannel, actualRequest.getNotificationChannel());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : NotificationChannel(com.google.monitoring.v3.NotificationChannel) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CreateNotificationChannelRequest(com.google.monitoring.v3.CreateNotificationChannelRequest) Test(org.junit.Test)

Example 4 with CreateNotificationChannelRequest

use of com.google.monitoring.v3.CreateNotificationChannelRequest in project java-monitoring by googleapis.

the class NotificationChannelServiceClientTest method createNotificationChannelTest2.

@Test
public void createNotificationChannelTest2() 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);
    OrganizationName name = OrganizationName.of("[ORGANIZATION]");
    NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
    NotificationChannel actualResponse = client.createNotificationChannel(name, notificationChannel);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateNotificationChannelRequest actualRequest = ((CreateNotificationChannelRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(notificationChannel, actualRequest.getNotificationChannel());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : NotificationChannel(com.google.monitoring.v3.NotificationChannel) OrganizationName(com.google.monitoring.v3.OrganizationName) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CreateNotificationChannelRequest(com.google.monitoring.v3.CreateNotificationChannelRequest) Test(org.junit.Test)

Aggregations

CreateNotificationChannelRequest (com.google.monitoring.v3.CreateNotificationChannelRequest)4 NotificationChannel (com.google.monitoring.v3.NotificationChannel)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)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