### Question:
OperationsClient implements BackgroundResource { public final void cancelOperation(String name) { CancelOperationRequest request = CancelOperationRequest.newBuilder().setName(name).build(); cancelOperation(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);  }### Answer:
@Test @SuppressWarnings("all") public void cancelOperationTest() { Empty expectedResponse = Empty.newBuilder().build(); mockOperations.addResponse(expectedResponse); String name = "name3373707"; client.cancelOperation(name); List<AbstractMessage> actualRequests = mockOperations.getRequests(); Assert.assertEquals(1, actualRequests.size()); CancelOperationRequest actualRequest = (CancelOperationRequest) actualRequests.get(0); Assert.assertEquals(name, actualRequest.getName()); }
@Test @SuppressWarnings("all") public void cancelOperationExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockOperations.addException(exception); try { String name = "name3373707"; client.cancelOperation(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { } }