use of com.google.phishingprotection.v1beta1.ProjectName in project java-monitoring by googleapis.
the class AlertPolicyServiceClientTest method listAlertPoliciesExceptionTest3.
@Test
public void listAlertPoliciesExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockAlertPolicyService.addException(exception);
try {
ProjectName name = ProjectName.of("[PROJECT]");
client.listAlertPolicies(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.phishingprotection.v1beta1.ProjectName in project java-monitoring by googleapis.
the class GroupServiceClientTest method createGroupExceptionTest3.
@Test
public void createGroupExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockGroupService.addException(exception);
try {
ProjectName name = ProjectName.of("[PROJECT]");
Group group = Group.newBuilder().build();
client.createGroup(name, group);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.phishingprotection.v1beta1.ProjectName in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method listServicesExceptionTest3.
@Test
public void listServicesExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockServiceMonitoringService.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
client.listServices(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.phishingprotection.v1beta1.ProjectName in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method listServicesTest3.
@Test
public void listServicesTest3() throws Exception {
Service responsesElement = Service.newBuilder().build();
ListServicesResponse expectedResponse = ListServicesResponse.newBuilder().setNextPageToken("").addAllServices(Arrays.asList(responsesElement)).build();
mockServiceMonitoringService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
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.phishingprotection.v1beta1.ProjectName in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method createServiceTest3.
@Test
public void createServiceTest3() throws Exception {
Service expectedResponse = Service.newBuilder().setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()).setDisplayName("displayName1714148973").setTelemetry(Service.Telemetry.newBuilder().build()).putAllUserLabels(new HashMap<String, String>()).build();
mockServiceMonitoringService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
Service service = Service.newBuilder().build();
Service actualResponse = client.createService(parent, service);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateServiceRequest actualRequest = ((CreateServiceRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(service, actualRequest.getService());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations