Search in sources :

Example 1 with ListOperationsPagedResponse

use of com.google.api.gax.httpjson.longrunning.OperationsClient.ListOperationsPagedResponse in project gax-java by googleapis.

the class OperationsClientTest method listOperationsTest.

@Test
public void listOperationsTest() {
    Operation responsesElement = Operation.newBuilder().build();
    ListOperationsResponse expectedResponse = ListOperationsResponse.newBuilder().setNextPageToken("").addAllOperations(Arrays.asList(responsesElement)).build();
    mockService.addResponse(expectedResponse);
    String name = "operations";
    String filter = "filter-1274492040";
    ListOperationsPagedResponse pagedListResponse = client.listOperations(name, filter);
    List<Operation> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getOperationsList().get(0), resources.get(0));
    List<String> actualRequests = mockService.getRequestPaths();
    Assert.assertEquals(1, actualRequests.size());
    String apiClientHeaderKey = mockService.getRequestHeaders().get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next();
    Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern().matcher(apiClientHeaderKey).matches());
}
Also used : ListOperationsPagedResponse(com.google.api.gax.httpjson.longrunning.OperationsClient.ListOperationsPagedResponse) ListOperationsResponse(com.google.longrunning.ListOperationsResponse) Operation(com.google.longrunning.Operation) Test(org.junit.Test)

Aggregations

ListOperationsPagedResponse (com.google.api.gax.httpjson.longrunning.OperationsClient.ListOperationsPagedResponse)1 ListOperationsResponse (com.google.longrunning.ListOperationsResponse)1 Operation (com.google.longrunning.Operation)1 Test (org.junit.Test)1