OperationsClient implements BackgroundResource { public final ListOperationsPagedResponse listOperations(String name, String filter) { ListOperationsRequest request = ListOperationsRequest.newBuilder().setName(name).setFilter(filter).build(); return listOperations(request); } protected  OperationsClient(OperationsSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected  OperationsClient(OperationsStub stub); static final OperationsClient create(OperationsSettings settings); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") static final OperationsClient create(OperationsStub stub); final OperationsSettings getSettings(); @BetaApi("A restructuring of stub classes is planned, so this may break in the future") OperationsStub getStub(); final Operation getOperation(String name); final UnaryCallable<GetOperationRequest, Operation> getOperationCallable(); final ListOperationsPagedResponse listOperations(String name, String filter); final ListOperationsPagedResponse listOperations(ListOperationsRequest request); final UnaryCallable<ListOperationsRequest, ListOperationsPagedResponse> listOperationsPagedCallable(); final UnaryCallable<ListOperationsRequest, ListOperationsResponse> listOperationsCallable(); final void cancelOperation(String name); final UnaryCallable<CancelOperationRequest, Empty> cancelOperationCallable(); final void deleteOperation(String name); final UnaryCallable<DeleteOperationRequest, Empty> deleteOperationCallable(); @Override final void close(); @Override void shutdown(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override void shutdownNow(); @Override boolean awaitTermination(long duration, TimeUnit unit);  }
@Test @SuppressWarnings("all") public void listOperationsTest() { String nextPageToken = ""; Operation operationsElement = Operation.newBuilder().build(); List<Operation> operations = Arrays.asList(operationsElement); ListOperationsResponse expectedResponse = ListOperationsResponse.newBuilder() .setNextPageToken(nextPageToken) .addAllOperations(operations) .build(); mockOperations.addResponse(expectedResponse); String name = "name3373707"; 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<AbstractMessage> actualRequests = mockOperations.getRequests(); Assert.assertEquals(1, actualRequests.size()); ListOperationsRequest actualRequest = (ListOperationsRequest) actualRequests.get(0); Assert.assertEquals(name, actualRequest.getName()); Assert.assertEquals(filter, actualRequest.getFilter()); }
@Test @SuppressWarnings("all") public void listOperationsExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockOperations.addException(exception); try { String name = "name3373707"; String filter = "filter-1274492040"; client.listOperations(name, filter); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }