SimpleIterableResultAdapter extends AbstractIterableResultAdapter<Object> { @Override public boolean accepts(Invocation invocation, Object originalValue) { if (!(originalValue instanceof Iterable)) { return false; } final Class<?> returnType = invocation.getMethod().getReturnType(); return !Iterable.class.isAssignableFrom(returnType) && !Iterator.class.isAssignableFrom(returnType) && !Future.class.isAssignableFrom(returnType); } SimpleIterableResultAdapter(); @Override boolean accepts(Invocation invocation, Object originalValue);  }
@Test public void testAccepting() throws Exception { final SimpleIterableResultAdapter adapter = new SimpleIterableResultAdapter(); assertThat(adapter.accepts(null, null), is(false)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findFuture"), new Object[]{}), new Object()), is(false)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findIterable"), new Object[]{}), new Object()), is(false)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findIterator"), new Object[]{}), new Object()), is(false)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findOther"), new Object[]{}), new Object()), is(false)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findInteger"), new Object[]{}), new Object()), is(false)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findOther"), new Object[]{}), new ArrayList<>()), is(true)); assertThat(adapter.accepts( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findInteger"), new Object[]{}), new ArrayList<>()), is(true)); }