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()));
}
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()));
}
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.
}
}
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.
}
}
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()));
}
Aggregations