DelegatingAsyncEventStore implements EventStoreAsync { @Override public final CompletableFuture<StreamEventsSlice> readEventsForward(final StreamId streamId, final long start, final int count) { return CompletableFuture.supplyAsync(new Supplier<StreamEventsSlice>() { @Override public StreamEventsSlice get() { return delegate.readEventsForward(streamId, start, count); } }, executor); } DelegatingAsyncEventStore(@NotNull final Executor executor, @NotNull final EventStore delegate); @Override final CompletableFuture<Void> open(); @Override final void close(); @Override final CompletableFuture<CommonEvent> readEvent(final StreamId streamId, final long eventNumber); @Override final CompletableFuture<StreamEventsSlice> readEventsForward(final StreamId streamId,
            final long start, final int count); @Override final CompletableFuture<StreamEventsSlice> readEventsBackward(final StreamId streamId,
            final long start, final int count); @Override final CompletableFuture<Void> deleteStream(final StreamId streamId, final long expected,
            final boolean hardDelete); @Override final CompletableFuture<Void> deleteStream(final StreamId streamId, final boolean hardDelete); @Override final CompletableFuture<Long> appendToStream(final StreamId streamId, final long expectedVersion,
            final List<CommonEvent> toAppend); @Override final CompletableFuture<Long> appendToStream(final StreamId streamId, final long expectedVersion,
            final CommonEvent... events); @Override final CompletableFuture<Long> appendToStream(final StreamId streamId,
            final List<CommonEvent> toAppend); @Override final CompletableFuture<Long> appendToStream(final StreamId streamId,
            final CommonEvent... events); @Override final CompletableFuture<Boolean> streamExists(final StreamId streamId); @Override final CompletableFuture<StreamState> streamState(final StreamId streamId); @Override final boolean isSupportsCreateStream(); @Override CompletableFuture<Void> createStream(final StreamId streamId);  }
@Test public void testReadEventsForward() throws Exception { final StreamId streamId = new SimpleStreamId("MyStream"); final List<CommonEvent> events = new ArrayList<>(); final StreamEventsSlice slice = new StreamEventsSlice(0, events, 1, true); when(delegate.readEventsForward(streamId, 0, 1)).thenReturn(slice); final StreamEventsSlice result = testee.readEventsForward(streamId, 0, 1).get(); assertThat(result).isSameAs(slice); verify(delegate).readEventsForward(streamId, 0, 1); }