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());
}
Aggregations