NullToIterableResultAdapter extends AbstractResultAdapter<Iterable> { @Override public Iterable adapt(Invocation invocation, Object originalValue) { return Collections.emptyList(); } NullToIterableResultAdapter(); @Override boolean accepts(Invocation invocation, Object originalValue); @Override Iterable adapt(Invocation invocation, Object originalValue);  }
@Test public void testAdaptingToIterable() throws Exception { final ResultAdapter<Iterable> adapter = new NullToIterableResultAdapter(); final Iterable value = adapter.adapt( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findIterable"), new Object[]{}), null); assertThat(value, is(notNullValue())); assertThat(value.iterator(), is(notNullValue())); final Iterator iterator = value.iterator(); assertThat(iterator.hasNext(), is(false)); }