Search in sources :

Example 1 with ListOperationsResponse

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();
}
Also used : ListOperationsResponse(com.google.longrunning.ListOperationsResponse) Operation(com.google.longrunning.Operation)

Example 2 with ListOperationsResponse

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();
}
Also used : ListOperationsResponse(com.google.longrunning.ListOperationsResponse) OperationsGrpc(com.google.longrunning.OperationsGrpc) ListOperationsRequest(com.google.longrunning.ListOperationsRequest) Test(org.junit.Test)

Example 3 with ListOperationsResponse

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

Example 4 with ListOperationsResponse

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();
}
Also used : ListOperationsResponse(com.google.longrunning.ListOperationsResponse) OperationsGrpc(com.google.longrunning.OperationsGrpc) CancelOperationRequest(com.google.longrunning.CancelOperationRequest) ListOperationsRequest(com.google.longrunning.ListOperationsRequest) Operation(com.google.longrunning.Operation) Test(org.junit.Test)

Example 5 with ListOperationsResponse

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();
}
Also used : ListOperationsResponse(com.google.longrunning.ListOperationsResponse)

Aggregations

ListOperationsResponse (com.google.longrunning.ListOperationsResponse)5 Operation (com.google.longrunning.Operation)3 Test (org.junit.Test)3 ListOperationsRequest (com.google.longrunning.ListOperationsRequest)2 OperationsGrpc (com.google.longrunning.OperationsGrpc)2 ListOperationsPagedResponse (com.google.api.gax.httpjson.longrunning.OperationsClient.ListOperationsPagedResponse)1 CancelOperationRequest (com.google.longrunning.CancelOperationRequest)1