NullToListenableFutureResultAdapter extends AbstractResultAdapter<ListenableFuture> { @Override public ListenableFuture adapt(Invocation invocation, Object originalValue) { final ListenableFutureTask task = new ListenableFutureTask(() -> null); task.run(); return task; } NullToListenableFutureResultAdapter(); @Override boolean accepts(Invocation invocation, Object originalValue); @Override ListenableFuture adapt(Invocation invocation, Object originalValue);  }
@Test public void testAdaptingTheResult() throws Exception { final ResultAdapter<ListenableFuture> adapter = new NullToListenableFutureResultAdapter(); final ListenableFuture adapted = adapter.adapt( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findListenableFuture"), new Object[]{}), null); assertThat(adapted, is(notNullValue())); assertThat(adapted.get(), is(nullValue())); }