Search in sources :

Example 6 with OrganizationName

use of com.google.privacy.dlp.v2.OrganizationName in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method listServicesTest2.

@Test
public void listServicesTest2() throws Exception {
    Service responsesElement = Service.newBuilder().build();
    ListServicesResponse expectedResponse = ListServicesResponse.newBuilder().setNextPageToken("").addAllServices(Arrays.asList(responsesElement)).build();
    mockServiceMonitoringService.addResponse(expectedResponse);
    OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
    ListServicesPagedResponse pagedListResponse = client.listServices(parent);
    List<Service> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListServicesRequest actualRequest = ((ListServicesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : OrganizationName(com.google.monitoring.v3.OrganizationName) ListServicesRequest(com.google.monitoring.v3.ListServicesRequest) AbstractMessage(com.google.protobuf.AbstractMessage) ListServicesResponse(com.google.monitoring.v3.ListServicesResponse) ListServicesPagedResponse(com.google.cloud.monitoring.v3.ServiceMonitoringServiceClient.ListServicesPagedResponse) Service(com.google.monitoring.v3.Service) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) Test(org.junit.Test)

Example 7 with OrganizationName

use of com.google.privacy.dlp.v2.OrganizationName 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 8 with OrganizationName

use of com.google.privacy.dlp.v2.OrganizationName in project java-monitoring by googleapis.

the class NotificationChannelServiceClientTest method listNotificationChannelsExceptionTest2.

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

Example 9 with OrganizationName

use of com.google.privacy.dlp.v2.OrganizationName in project java-monitoring by googleapis.

the class NotificationChannelServiceClientTest method createNotificationChannelExceptionTest2.

@Test
public void createNotificationChannelExceptionTest2() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockNotificationChannelService.addException(exception);
    try {
        OrganizationName name = OrganizationName.of("[ORGANIZATION]");
        NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
        client.createNotificationChannel(name, notificationChannel);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : OrganizationName(com.google.monitoring.v3.OrganizationName) NotificationChannel(com.google.monitoring.v3.NotificationChannel) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 10 with OrganizationName

use of com.google.privacy.dlp.v2.OrganizationName in project java-monitoring by googleapis.

the class MetricServiceClientTest method listMonitoredResourceDescriptorsTest2.

@Test
public void listMonitoredResourceDescriptorsTest2() throws Exception {
    MonitoredResourceDescriptor responsesElement = MonitoredResourceDescriptor.newBuilder().build();
    ListMonitoredResourceDescriptorsResponse expectedResponse = ListMonitoredResourceDescriptorsResponse.newBuilder().setNextPageToken("").addAllResourceDescriptors(Arrays.asList(responsesElement)).build();
    mockMetricService.addResponse(expectedResponse);
    OrganizationName name = OrganizationName.of("[ORGANIZATION]");
    ListMonitoredResourceDescriptorsPagedResponse pagedListResponse = client.listMonitoredResourceDescriptors(name);
    List<MonitoredResourceDescriptor> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getResourceDescriptorsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockMetricService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListMonitoredResourceDescriptorsRequest actualRequest = ((ListMonitoredResourceDescriptorsRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : OrganizationName(com.google.monitoring.v3.OrganizationName) ListMonitoredResourceDescriptorsResponse(com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListMonitoredResourceDescriptorsRequest(com.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest) MonitoredResourceDescriptor(com.google.api.MonitoredResourceDescriptor) ListMonitoredResourceDescriptorsPagedResponse(com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)62 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)31 AbstractMessage (com.google.protobuf.AbstractMessage)31 StatusRuntimeException (io.grpc.StatusRuntimeException)31 OrganizationName (com.google.monitoring.v3.OrganizationName)30 OrganizationName (com.google.logging.v2.OrganizationName)22 OrganizationName (com.google.privacy.dlp.v2.OrganizationName)12 LogExclusion (com.google.logging.v2.LogExclusion)7 LogSink (com.google.logging.v2.LogSink)7 ArrayList (java.util.ArrayList)7 MetricDescriptor (com.google.api.MetricDescriptor)3 MockGrpcService (com.google.api.gax.grpc.testing.MockGrpcService)3 AlertPolicy (com.google.monitoring.v3.AlertPolicy)3 UptimeCheckConfig (com.google.monitoring.v3.UptimeCheckConfig)3 InspectTemplate (com.google.privacy.dlp.v2.InspectTemplate)3 ConfigClient (com.google.cloud.logging.v2.ConfigClient)2 ListExclusionsPagedResponse (com.google.cloud.logging.v2.ConfigClient.ListExclusionsPagedResponse)2 ListSinksPagedResponse (com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse)2 ListLogsPagedResponse (com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse)2 CreateExclusionRequest (com.google.logging.v2.CreateExclusionRequest)2