use of com.google.cloudbuild.v1.WorkerPool in project java-cloudbuild by googleapis.
the class CloudBuildClientTest method getWorkerPoolTest2.
@Test
public void getWorkerPoolTest2() 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);
String name = "name3373707";
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, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloudbuild.v1.WorkerPool in project java-cloudbuild by googleapis.
the class CloudBuildClientTest method listWorkerPoolsTest.
@Test
public void listWorkerPoolsTest() throws Exception {
WorkerPool responsesElement = WorkerPool.newBuilder().build();
ListWorkerPoolsResponse expectedResponse = ListWorkerPoolsResponse.newBuilder().setNextPageToken("").addAllWorkerPools(Arrays.asList(responsesElement)).build();
mockCloudBuild.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListWorkerPoolsPagedResponse pagedListResponse = client.listWorkerPools(parent);
List<WorkerPool> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getWorkerPoolsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockCloudBuild.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListWorkerPoolsRequest actualRequest = ((ListWorkerPoolsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloudbuild.v1.WorkerPool 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.cloudbuild.v1.WorkerPool in project java-cloudbuild by googleapis.
the class CloudBuildClientTest method updateWorkerPoolTest.
@Test
public void updateWorkerPoolTest() 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();
Operation resultOperation = Operation.newBuilder().setName("updateWorkerPoolTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockCloudBuild.addResponse(resultOperation);
WorkerPool workerPool = WorkerPool.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
WorkerPool actualResponse = client.updateWorkerPoolAsync(workerPool, updateMask).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockCloudBuild.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateWorkerPoolRequest actualRequest = ((UpdateWorkerPoolRequest) actualRequests.get(0));
Assert.assertEquals(workerPool, actualRequest.getWorkerPool());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloudbuild.v1.WorkerPool 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