NullToFutureResultAdapter extends AbstractResultAdapter<Future> { @Override public Future adapt(Invocation invocation, Object originalValue) { final FutureTask task = new FutureTask(() -> null); task.run(); return task; } NullToFutureResultAdapter(); @Override boolean accepts(Invocation invocation, Object originalValue); @Override Future adapt(Invocation invocation, Object originalValue);  }
@Test public void testAdaptingFuture() throws Exception { final ResultAdapter<Future> adapter = new NullToFutureResultAdapter(); final Future value = adapter.adapt( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findFuture"), new Object[]{}), null); assertThat(value, is(notNullValue())); assertThat(value.get(), is(nullValue())); }