/** * Reads all events for a given stream id from the beginning. * * @param streamId The id of the stream to read events for. * @return A result record describing the outcome of the read and the events themselves, or null * if no stream was found. */ default EventReadResult<T> read(final String streamId) { return read(streamId, 0); }
/** * Reads all events for a given stream id from the beginning. * * @param streamId The id of the stream to read events for. * @return A result record describing the outcome of the read and the events themselves, or null * if no stream was found. */ default EventReadResult<T> read(final String streamId) { return read(streamId, 0); }
/** * Reads all events for a given stream id from a given version and onwards, with no specified * upper bound on the number of events returned. * * @param streamId The id of the stream to read events for. * @param version The version to read events from. Versions are monotonically increasing * starting with 0, specifying a version of 0 is equivalent to reading the * events from the beginning of the stream. * @return A result record describing the outcome of the read and the events themselves, or null * if no stream was found. */ default EventReadResult<T> read(final String streamId, final int version) { return read(streamId, version, Integer.MAX_VALUE); }
/** * Reads all events for a given stream id from a given version and onwards, with no specified * upper bound on the number of events returned. * * @param streamId The id of the stream to read events for. * @param version The version to read events from. Versions are monotonically increasing * starting with 0, specifying a version of 0 is equivalent to reading the * events from the beginning of the stream. * @return A result record describing the outcome of the read and the events themselves, or null * if no stream was found. */ default EventReadResult<T> read(final String streamId, final int version) { return read(streamId, version, Integer.MAX_VALUE); }
private void returnsAggregateWithEmptyStateOn( final EventReadResult readEventsResult) { when(eventRepository.read(any(), anyInt(), anyInt())).thenReturn(readEventsResult); ImmutableAggregate<TestState, TestEvent> aggregate = repository.load(AGGREGATE_ID_1); verify(eventRepository).read(eq(AGGREGATE_ID_1), eq(0), anyInt()); verifyNoMoreInteractions(eventRepository); Assert.assertNotNull(aggregate); Assert.assertEquals(aggregate.state().getValue(), "empty"); Assert.assertEquals(-1, aggregate.sourceVersion()); }
while (true) { // Exit through return logger.debug("Reading events for {} from {}", aggregateId, currentStreamPosition); EventReadResult<TEvent> readResult = eventRepository.read( aggregateId, currentStreamPosition,
while (true) { // Exit through return logger.debug("Reading events for {} from {}", aggregateId, currentStreamPosition); EventReadResult<TEvent> readResult = eventRepository.read( aggregateId, currentStreamPosition,
TestState expectedState = new TestState("state1"); when(eventRepository.read(any(), anyInt(), anyInt())).thenReturn( repositoryResult1, repositoryResult2); verify(aggregateProjection).empty(); verify(aggregateProjection, times(2)).apply(any(), any(), (Iterable) any()); verify(eventRepository).read(eq(AGGREGATE_ID_1), eq(0), anyInt()); verify(eventRepository).read(eq(AGGREGATE_ID_1), eq(2), anyInt()); verifyNoMoreInteractions(aggregateProjection, eventRepository);
TestState expectedState = new TestState("state1"); when(eventRepository.read(any(), anyInt(), anyInt())).thenReturn(repositoryResult); when(aggregateProjection.apply(any(), any(), (Iterable) any())).thenReturn(expectedState); verify(eventRepository).read(eq(AGGREGATE_ID_1), eq(0), anyInt()); ArgumentCaptor<Iterable<TestEvent>> passedEvents = ArgumentCaptor.forClass((Class) Iterable.class);