Search in sources :

Example 1 with CreateWorkerPoolRequest

use of com.google.cloudbuild.v1.CreateWorkerPoolRequest in project java-cloudbuild by googleapis.

the class CloudBuildClientTest method createWorkerPoolTest.

@Test
public void createWorkerPoolTest() 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("createWorkerPoolTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
    mockCloudBuild.addResponse(resultOperation);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    WorkerPool workerPool = WorkerPool.newBuilder().build();
    String workerPoolId = "workerPoolId-46320779";
    WorkerPool actualResponse = client.createWorkerPoolAsync(parent, workerPool, workerPoolId).get();
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockCloudBuild.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateWorkerPoolRequest actualRequest = ((CreateWorkerPoolRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(workerPool, actualRequest.getWorkerPool());
    Assert.assertEquals(workerPoolId, actualRequest.getWorkerPoolId());
    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) CreateWorkerPoolRequest(com.google.cloudbuild.v1.CreateWorkerPoolRequest) LocationName(com.google.cloudbuild.v1.LocationName) Test(org.junit.Test)

Example 2 with CreateWorkerPoolRequest

use of com.google.cloudbuild.v1.CreateWorkerPoolRequest in project java-cloudbuild by googleapis.

the class CloudBuildClientTest method createWorkerPoolTest2.

@Test
public void createWorkerPoolTest2() 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("createWorkerPoolTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
    mockCloudBuild.addResponse(resultOperation);
    String parent = "parent-995424086";
    WorkerPool workerPool = WorkerPool.newBuilder().build();
    String workerPoolId = "workerPoolId-46320779";
    WorkerPool actualResponse = client.createWorkerPoolAsync(parent, workerPool, workerPoolId).get();
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockCloudBuild.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateWorkerPoolRequest actualRequest = ((CreateWorkerPoolRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertEquals(workerPool, actualRequest.getWorkerPool());
    Assert.assertEquals(workerPoolId, actualRequest.getWorkerPoolId());
    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) CreateWorkerPoolRequest(com.google.cloudbuild.v1.CreateWorkerPoolRequest) Test(org.junit.Test)

Aggregations

CreateWorkerPoolRequest (com.google.cloudbuild.v1.CreateWorkerPoolRequest)2 WorkerPool (com.google.cloudbuild.v1.WorkerPool)2 Operation (com.google.longrunning.Operation)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 LocationName (com.google.cloudbuild.v1.LocationName)1