NullToListenableFutureResultAdapter extends AbstractResultAdapter<ListenableFuture> { @Override public boolean accepts(Invocation invocation, Object originalValue) { return originalValue == null && invocation.getMethod().getReturnType().equals(ListenableFuture.class); } NullToListenableFutureResultAdapter(); @Override boolean accepts(Invocation invocation, Object originalValue); @Override ListenableFuture adapt(Invocation invocation, Object originalValue);  }
@Test public void testAccepting() throws Exception { final ResultAdapter<ListenableFuture> adapter = new NullToListenableFutureResultAdapter(); assertThat(adapter.accepts(null, new Object()), is(false)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findOther"), new Object[]{}), null), is(false)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findListenableFuture"), new Object[]{}), null), is(true)); }