use of com.google.longrunning.ListOperationsResponse in project java-spanner by googleapis.
the class MockOperationsServiceImpl method listOperations.
@Override
public void listOperations(ListOperationsRequest request, StreamObserver<ListOperationsResponse> responseObserver) {
ListOperationsResponse.Builder builder = ListOperationsResponse.newBuilder();
for (Operation op : iterable()) {
if (op.getName().startsWith(request.getName())) {
builder.addOperations(op);
}
}
responseObserver.onNext(builder.build());
responseObserver.onCompleted();
}
use of com.google.longrunning.ListOperationsResponse in project bazel-buildfarm by bazelbuild.
the class BuildFarmServerTest method listOperations.
@Test
public void listOperations() {
ListOperationsRequest request = ListOperationsRequest.newBuilder().setName(INSTANCE_NAME + "/operations").setPageSize(1024).build();
OperationsGrpc.OperationsBlockingStub stub = OperationsGrpc.newBlockingStub(inProcessChannel);
ListOperationsResponse response = stub.listOperations(request);
assertThat(response.getOperationsList()).isEmpty();
}
use of com.google.longrunning.ListOperationsResponse 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());
}
use of com.google.longrunning.ListOperationsResponse in project bazel-buildfarm by bazelbuild.
the class BuildFarmServerTest method canceledOperationIsNoLongerOutstanding.
@Test
public void canceledOperationIsNoLongerOutstanding() throws IOException, InterruptedException {
Operation operation = executeAction(createSimpleAction());
// should appear in outstanding list
ListOperationsRequest listRequest = ListOperationsRequest.newBuilder().setName(INSTANCE_NAME + "/operations").setPageSize(1024).build();
OperationsGrpc.OperationsBlockingStub operationsStub = OperationsGrpc.newBlockingStub(inProcessChannel);
ListOperationsResponse listResponse = operationsStub.listOperations(listRequest);
assertThat(Iterables.transform(listResponse.getOperationsList(), Operation::getName)).containsExactly(operation.getName());
CancelOperationRequest cancelRequest = CancelOperationRequest.newBuilder().setName(operation.getName()).build();
operationsStub.cancelOperation(cancelRequest);
// should now be gone
listResponse = operationsStub.listOperations(listRequest);
assertThat(listResponse.getOperationsList()).isEmpty();
}
use of com.google.longrunning.ListOperationsResponse in project bazel-buildfarm by bazelbuild.
the class StubInstance method listOperations.
@Override
public String listOperations(int pageSize, String pageToken, String filter, ImmutableList.Builder<Operation> operations) {
throwIfStopped();
ListOperationsResponse response = deadlined(operationsBlockingStub).listOperations(ListOperationsRequest.newBuilder().setName(getName() + "/operations").setPageSize(pageSize).setPageToken(pageToken).setFilter(filter).build());
operations.addAll(response.getOperationsList());
return response.getNextPageToken();
}
Aggregations