Search in sources :

Example 1 with UpdateWorkerPoolRequest

use of com.google.cloudbuild.v1.UpdateWorkerPoolRequest 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()));
}
Also used : WorkerPool(com.google.cloudbuild.v1.WorkerPool) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) Operation(com.google.longrunning.Operation) UpdateWorkerPoolRequest(com.google.cloudbuild.v1.UpdateWorkerPoolRequest) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Aggregations

UpdateWorkerPoolRequest (com.google.cloudbuild.v1.UpdateWorkerPoolRequest)1 WorkerPool (com.google.cloudbuild.v1.WorkerPool)1 Operation (com.google.longrunning.Operation)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 FieldMask (com.google.protobuf.FieldMask)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1