Search in sources :

Example 1 with NotificationChannelDescriptorName

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

the class NotificationChannelServiceClientTest method getNotificationChannelDescriptorExceptionTest.

@Test
public void getNotificationChannelDescriptorExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockNotificationChannelService.addException(exception);
    try {
        NotificationChannelDescriptorName name = NotificationChannelDescriptorName.ofProjectChannelDescriptorName("[PROJECT]", "[CHANNEL_DESCRIPTOR]");
        client.getNotificationChannelDescriptor(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : NotificationChannelDescriptorName(com.google.monitoring.v3.NotificationChannelDescriptorName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 2 with NotificationChannelDescriptorName

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

the class NotificationChannelServiceClientTest method getNotificationChannelDescriptorTest.

@Test
public void getNotificationChannelDescriptorTest() throws Exception {
    NotificationChannelDescriptor expectedResponse = NotificationChannelDescriptor.newBuilder().setName(NotificationChannelDescriptorName.ofProjectChannelDescriptorName("[PROJECT]", "[CHANNEL_DESCRIPTOR]").toString()).setType("type3575610").setDisplayName("displayName1714148973").setDescription("description-1724546052").addAllLabels(new ArrayList<LabelDescriptor>()).addAllSupportedTiers(new ArrayList<ServiceTier>()).setLaunchStage(LaunchStage.forNumber(0)).build();
    mockNotificationChannelService.addResponse(expectedResponse);
    NotificationChannelDescriptorName name = NotificationChannelDescriptorName.ofProjectChannelDescriptorName("[PROJECT]", "[CHANNEL_DESCRIPTOR]");
    NotificationChannelDescriptor actualResponse = client.getNotificationChannelDescriptor(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetNotificationChannelDescriptorRequest actualRequest = ((GetNotificationChannelDescriptorRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : NotificationChannelDescriptorName(com.google.monitoring.v3.NotificationChannelDescriptorName) AbstractMessage(com.google.protobuf.AbstractMessage) NotificationChannelDescriptor(com.google.monitoring.v3.NotificationChannelDescriptor) ArrayList(java.util.ArrayList) GetNotificationChannelDescriptorRequest(com.google.monitoring.v3.GetNotificationChannelDescriptorRequest) ServiceTier(com.google.monitoring.v3.ServiceTier) Test(org.junit.Test)

Aggregations

NotificationChannelDescriptorName (com.google.monitoring.v3.NotificationChannelDescriptorName)2 Test (org.junit.Test)2 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)1 GetNotificationChannelDescriptorRequest (com.google.monitoring.v3.GetNotificationChannelDescriptorRequest)1 NotificationChannelDescriptor (com.google.monitoring.v3.NotificationChannelDescriptor)1 ServiceTier (com.google.monitoring.v3.ServiceTier)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 ArrayList (java.util.ArrayList)1