Search in sources :

Example 1 with NotificationChannel

use of com.google.monitoring.v3.NotificationChannel 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 NotificationChannel

use of com.google.monitoring.v3.NotificationChannel 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 NotificationChannel

use of com.google.monitoring.v3.NotificationChannel 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 4 with NotificationChannel

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

the class NotificationChannelServiceClientTest method verifyNotificationChannelTest.

@Test
public void verifyNotificationChannelTest() 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]");
    String code = "code3059181";
    NotificationChannel actualResponse = client.verifyNotificationChannel(name, code);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    VerifyNotificationChannelRequest actualRequest = ((VerifyNotificationChannelRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(code, actualRequest.getCode());
    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) VerifyNotificationChannelRequest(com.google.monitoring.v3.VerifyNotificationChannelRequest) NotificationChannelName(com.google.monitoring.v3.NotificationChannelName) Test(org.junit.Test)

Example 5 with NotificationChannel

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

the class NotificationChannelServiceClientTest method verifyNotificationChannelTest2.

@Test
public void verifyNotificationChannelTest2() 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";
    String code = "code3059181";
    NotificationChannel actualResponse = client.verifyNotificationChannel(name, code);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    VerifyNotificationChannelRequest actualRequest = ((VerifyNotificationChannelRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertEquals(code, actualRequest.getCode());
    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) VerifyNotificationChannelRequest(com.google.monitoring.v3.VerifyNotificationChannelRequest) Test(org.junit.Test)

Aggregations

NotificationChannel (com.google.monitoring.v3.NotificationChannel)28 Test (org.junit.Test)18 AbstractMessage (com.google.protobuf.AbstractMessage)13 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)5 ListNotificationChannelsPagedResponse (com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelsPagedResponse)5 AlertPolicy (com.google.monitoring.v3.AlertPolicy)5 StatusRuntimeException (io.grpc.StatusRuntimeException)5 NotificationChannelServiceClient (com.google.cloud.monitoring.v3.NotificationChannelServiceClient)4 JsonObject (com.google.gson.JsonObject)4 CreateNotificationChannelRequest (com.google.monitoring.v3.CreateNotificationChannelRequest)4 ListNotificationChannelsRequest (com.google.monitoring.v3.ListNotificationChannelsRequest)4 ListNotificationChannelsResponse (com.google.monitoring.v3.ListNotificationChannelsResponse)4 FolderName (com.google.monitoring.v3.FolderName)3 OrganizationName (com.google.monitoring.v3.OrganizationName)3 ProjectName (com.google.monitoring.v3.ProjectName)3 JsonArray (com.google.gson.JsonArray)2 JsonPrimitive (com.google.gson.JsonPrimitive)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)2