FutureOperationalResultImpl implements ListenableFuture<OperationResult<R>> { @Override public OperationResult<R> get() throws InterruptedException, ExecutionException { try { future.get(); return opResult; } finally { recordTimeIfNeeded(); } } FutureOperationalResultImpl(String opName, Future<R> rFuture, long start, OperationMonitor opMonitor); @Override boolean cancel(boolean mayInterruptIfRunning); @Override boolean isCancelled(); @Override boolean isDone(); @Override OperationResult<R> get(); @Override OperationResult<R> get(long timeout, TimeUnit unit); FutureOperationalResultImpl<R> node(Host node); OperationResultImpl<R> getOpResult(); @Override void addListener(Runnable listener, Executor executor);  }
@Test public void testFutureResult() throws Exception { final FutureTask<Integer> futureTask = new FutureTask<Integer>(new Callable<Integer>() { @Override public Integer call() throws Exception { return 11; } }); LastOperationMonitor opMonitor = new LastOperationMonitor(); FutureOperationalResultImpl<Integer> futureResult = new FutureOperationalResultImpl<Integer>("test", futureTask, System.currentTimeMillis(), opMonitor); ExecutorService threadPool = Executors.newSingleThreadExecutor(); threadPool.submit(new Callable<Void>() { @Override public Void call() throws Exception { Thread.sleep(400); futureTask.run(); return null; } }); OperationResult<Integer> opResult = futureResult.get(); int integerResult = opResult.getResult(); long latency = opResult.getLatency(); Assert.assertEquals(11, integerResult); Assert.assertTrue(latency >= 400); threadPool.shutdownNow(); }