use of com.google.cloudbuild.v1.WorkerPoolName in project java-cloudbuild by googleapis.
the class CloudBuildClientTest method getWorkerPoolExceptionTest.
@Test
public void getWorkerPoolExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockCloudBuild.addException(exception);
try {
WorkerPoolName name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]");
client.getWorkerPool(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloudbuild.v1.WorkerPoolName in project java-cloudbuild by googleapis.
the class CloudBuildClientTest method deleteWorkerPoolTest.
@Test
public void deleteWorkerPoolTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
Operation resultOperation = Operation.newBuilder().setName("deleteWorkerPoolTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockCloudBuild.addResponse(resultOperation);
WorkerPoolName name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]");
client.deleteWorkerPoolAsync(name).get();
List<AbstractMessage> actualRequests = mockCloudBuild.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteWorkerPoolRequest actualRequest = ((DeleteWorkerPoolRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloudbuild.v1.WorkerPoolName in project java-cloudbuild by googleapis.
the class CloudBuildClientTest method deleteWorkerPoolExceptionTest.
@Test
public void deleteWorkerPoolExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockCloudBuild.addException(exception);
try {
WorkerPoolName name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]");
client.deleteWorkerPoolAsync(name).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.cloudbuild.v1.WorkerPoolName in project java-cloudbuild by googleapis.
the class CloudBuildClientTest method getWorkerPoolTest.
@Test
public void getWorkerPoolTest() throws Exception {
WorkerPool expectedResponse = WorkerPool.newBuilder().setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString()).setDisplayName("displayName1714148973").setUid("uid115792").putAllAnnotations(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setDeleteTime(Timestamp.newBuilder().build()).setEtag("etag3123477").build();
mockCloudBuild.addResponse(expectedResponse);
WorkerPoolName name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]");
WorkerPool actualResponse = client.getWorkerPool(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockCloudBuild.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetWorkerPoolRequest actualRequest = ((GetWorkerPoolRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations