use of com.google.cloud.automl.v1beta1.LocationName in project java-cloudbuild by googleapis.
the class CloudBuildClientTest method listWorkerPoolsExceptionTest.
@Test
public void listWorkerPoolsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockCloudBuild.addException(exception);
try {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
client.listWorkerPools(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloud.automl.v1beta1.LocationName in project java-cloudbuild by googleapis.
the class CloudBuildClientTest method createWorkerPoolExceptionTest.
@Test
public void createWorkerPoolExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockCloudBuild.addException(exception);
try {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
WorkerPool workerPool = WorkerPool.newBuilder().build();
String workerPoolId = "workerPoolId-46320779";
client.createWorkerPoolAsync(parent, workerPool, workerPoolId).get();
Assert.fail("No exception raised");
} catch (ExecutionException e) {
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
}
}
use of com.google.cloud.automl.v1beta1.LocationName in project java-servicedirectory by googleapis.
the class NamespacesCreate method createNamespace.
// Create a new namespace.
public static void createNamespace(String projectId, String locationId, String namespaceId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
// The project and location to create the namespace in.
LocationName parent = LocationName.of(projectId, locationId);
// The namespace object to create. Here, we use the default instance.
Namespace namespace = Namespace.newBuilder().build();
// Send the request to create the namespace.
Namespace createdNamespace = client.createNamespace(parent, namespace, namespaceId);
// Process the response.
System.out.println("Created Namespace: " + createdNamespace.getName());
}
}
Aggregations