NullToSliceResultAdapter extends AbstractResultAdapter<Slice> { @Override public Slice adapt(Invocation invocation, Object originalValue) { return new GeoPage(new GeoResults(Collections.emptyList())); } NullToSliceResultAdapter(); @Override boolean accepts(Invocation invocation, Object originalValue); @Override Slice adapt(Invocation invocation, Object originalValue);  }
@Test public void testAdaptingToASlice() throws Exception { final ResultAdapter<Slice> adapter = new NullToSliceResultAdapter(); final Slice<?> value = adapter.adapt( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findSlice"), new Object[]{}), null); assertThat(value, is(notNullValue())); assertThat(value.getNumber(), is(0)); assertThat(value.getNumberOfElements(), is(0)); assertThat(value.getSize(), is(0)); assertThat(value.getSort(), is(Sort.unsorted())); assertThat(value.getContent(), hasSize(0)); }
@Test public void testAdaptingToAPage() throws Exception { final ResultAdapter<Slice> adapter = new NullToSliceResultAdapter(); final Slice<?> value = adapter.adapt( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findPage"), new Object[]{}), null); assertThat(value, is(notNullValue())); assertThat(value.getNumber(), is(0)); assertThat(value.getNumberOfElements(), is(0)); assertThat(value.getSize(), is(0)); assertThat(value.getSort(), is(Sort.unsorted())); assertThat(value.getContent(), hasSize(0)); }
@Test public void testAdaptingToAGeoPage() throws Exception { final ResultAdapter<Slice> adapter = new NullToSliceResultAdapter(); final Slice<?> value = adapter.adapt( new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findGeoPage"), new Object[]{}), null); assertThat(value, is(notNullValue())); assertThat(value.getNumber(), is(0)); assertThat(value.getNumberOfElements(), is(0)); assertThat(value.getSize(), is(0)); assertThat(value.getSort(), is(Sort.unsorted())); assertThat(value.getContent(), hasSize(0)); }