Search in sources :

Example 1 with ListWorkerPoolsRequest

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

the class CloudBuildClientTest method listWorkerPoolsTest2.

@Test
public void listWorkerPoolsTest2() throws Exception {
    WorkerPool responsesElement = WorkerPool.newBuilder().build();
    ListWorkerPoolsResponse expectedResponse = ListWorkerPoolsResponse.newBuilder().setNextPageToken("").addAllWorkerPools(Arrays.asList(responsesElement)).build();
    mockCloudBuild.addResponse(expectedResponse);
    String parent = "parent-995424086";
    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, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListWorkerPoolsPagedResponse(com.google.cloud.devtools.cloudbuild.v1.CloudBuildClient.ListWorkerPoolsPagedResponse) WorkerPool(com.google.cloudbuild.v1.WorkerPool) AbstractMessage(com.google.protobuf.AbstractMessage) ListWorkerPoolsResponse(com.google.cloudbuild.v1.ListWorkerPoolsResponse) ListWorkerPoolsRequest(com.google.cloudbuild.v1.ListWorkerPoolsRequest) Test(org.junit.Test)

Example 2 with ListWorkerPoolsRequest

use of com.google.cloudbuild.v1.ListWorkerPoolsRequest 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()));
}
Also used : ListWorkerPoolsPagedResponse(com.google.cloud.devtools.cloudbuild.v1.CloudBuildClient.ListWorkerPoolsPagedResponse) WorkerPool(com.google.cloudbuild.v1.WorkerPool) AbstractMessage(com.google.protobuf.AbstractMessage) ListWorkerPoolsResponse(com.google.cloudbuild.v1.ListWorkerPoolsResponse) ListWorkerPoolsRequest(com.google.cloudbuild.v1.ListWorkerPoolsRequest) LocationName(com.google.cloudbuild.v1.LocationName) Test(org.junit.Test)

Aggregations

ListWorkerPoolsPagedResponse (com.google.cloud.devtools.cloudbuild.v1.CloudBuildClient.ListWorkerPoolsPagedResponse)2 ListWorkerPoolsRequest (com.google.cloudbuild.v1.ListWorkerPoolsRequest)2 ListWorkerPoolsResponse (com.google.cloudbuild.v1.ListWorkerPoolsResponse)2 WorkerPool (com.google.cloudbuild.v1.WorkerPool)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 LocationName (com.google.cloudbuild.v1.LocationName)1