@Test public void updatePassesOnEventsToEventRepository() { List<TestEvent> events = Arrays.asList(new TestEvent("test1"), new TestEvent("test2")); when(eventRepository.append(any(), anyList(), any())).thenReturn(42); repository.append(AGGREGATE_ID_1, events, ExpectedVersion.any()); ArgumentCaptor<List<EventData<TestEvent>>> passedEvents = ArgumentCaptor.forClass((Class) List.class); verify(eventRepository).append(eq(AGGREGATE_ID_1), passedEvents.capture(), any()); Assert.assertThat( passedEvents .getValue() .stream() .map(EventData::getEvent) .collect(Collectors.toList()), org.hamcrest.Matchers.contains(events.toArray())); }
@Override public int append( final String aggregateId, final Iterable<? extends TEvent> events, final ExpectedVersion expectedVersion, final Map<String, String> metadata) { List<EventData<TEvent>> eventDatas = StreamSupport .stream(events.spliterator(), false) .map(e -> new EventData<TEvent>( getEventType(e), UUID.randomUUID(), metadata, e)) .collect(Collectors.toList()); return eventRepository.append(aggregateId, eventDatas, expectedVersion); }
DefaultAggregateRepository implements AggregateRepository<TState, TEvent> { @Override public int append( final String aggregateId, final Iterable<? extends TEvent> events, final ExpectedVersion expectedVersion, final Map<String, String> metadata) { List<EventData<TEvent>> eventDatas = StreamSupport .stream(events.spliterator(), false) .map(e -> new EventData<TEvent>( getEventType(e), UUID.randomUUID(), metadata, e)) .collect(Collectors.toList()); return eventRepository.append(aggregateId, eventDatas, expectedVersion); } }
DefaultAggregateRepository implements AggregateRepository<TState, TEvent> { @Override public int append( final String aggregateId, final Iterable<? extends TEvent> events, final ExpectedVersion expectedVersion, final Map<String, String> metadata) { List<EventData<TEvent>> eventDatas = StreamSupport .stream(events.spliterator(), false) .map(e -> new EventData<TEvent>( getEventType(e), UUID.randomUUID(), metadata, e)) .collect(Collectors.toList()); return eventRepository.append(aggregateId, eventDatas, expectedVersion); } DefaultAggregateRepository(
            final EventRepository<TEvent> eventRepository,
            final AggregateProjection<TState, TEvent> projection);  DefaultAggregateRepository(
            final EventRepository<TEvent> eventRepository,
            final AggregateProjection<TState, TEvent> projection,
            final int maxEventsPerRead);  DefaultAggregateRepository(
            final EventRepository<TEvent> eventRepository,
            final AggregateProjection<TState, TEvent> projection,
            final Function<? super TEvent, String> typeResolver);  DefaultAggregateRepository(
            final EventRepository<TEvent> eventRepository,
            final AggregateProjection<TState, TEvent> projection,
            final Function<? super TEvent, String> typeResolver,
            final int maxEventsPerRead); }
DefaultAggregateRepository implements AggregateRepository<TState, TEvent> { @Override public int append( final String aggregateId, final Iterable<? extends TEvent> events, final ExpectedVersion expectedVersion, final Map<String, String> metadata) { List<EventData<TEvent>> eventDatas = StreamSupport .stream(events.spliterator(), false) .map(e -> new EventData<TEvent>( getEventType(e), UUID.randomUUID(), metadata, e)) .collect(Collectors.toList()); return eventRepository.append(aggregateId, eventDatas, expectedVersion); } DefaultAggregateRepository(
            final EventRepository<TEvent> eventRepository,
            final AggregateProjection<TState, TEvent> projection);  DefaultAggregateRepository(
            final EventRepository<TEvent> eventRepository,
            final AggregateProjection<TState, TEvent> projection,
            final int maxEventsPerRead);  DefaultAggregateRepository(
            final EventRepository<TEvent> eventRepository,
            final AggregateProjection<TState, TEvent> projection,
            final Function<? super TEvent, String> typeResolver);  DefaultAggregateRepository(
            final EventRepository<TEvent> eventRepository,
            final AggregateProjection<TState, TEvent> projection,
            final Function<? super TEvent, String> typeResolver,
            final int maxEventsPerRead); @Override ImmutableAggregate<TState, TEvent> load(final String aggregateId); @Override int append(
            final String aggregateId,
            final Iterable<? extends TEvent> events,
            final ExpectedVersion expectedVersion,
            final Map<String, String> metadata); @Override ImmutableAggregate<TState, TEvent> save(
            @NotNull final Aggregate<TState, TEvent> aggregate,
            final boolean atomic,
            final Map<String, String> metadata); }
DefaultAggregateRepository implements AggregateRepository<TState, TEvent> { @Override public int append( final String aggregateId, final Iterable<? extends TEvent> events, final ExpectedVersion expectedVersion, final Map<String, String> metadata) { List<EventData<TEvent>> eventDatas = StreamSupport .stream(events.spliterator(), false) .map(e -> new EventData<TEvent>( getEventType(e), UUID.randomUUID(), metadata, e)) .collect(Collectors.toList()); return eventRepository.append(aggregateId, eventDatas, expectedVersion); } DefaultAggregateRepository(
            final EventRepository<TEvent> eventRepository,
            final AggregateProjection<TState, TEvent> projection);  DefaultAggregateRepository(
            final EventRepository<TEvent> eventRepository,
            final AggregateProjection<TState, TEvent> projection,
            final int maxEventsPerRead);  DefaultAggregateRepository(
            final EventRepository<TEvent> eventRepository,
            final AggregateProjection<TState, TEvent> projection,
            final Function<? super TEvent, String> typeResolver);  DefaultAggregateRepository(
            final EventRepository<TEvent> eventRepository,
            final AggregateProjection<TState, TEvent> projection,
            final Function<? super TEvent, String> typeResolver,
            final int maxEventsPerRead); @Override ImmutableAggregate<TState, TEvent> load(final String aggregateId); @Override int append(
            final String aggregateId,
            final Iterable<? extends TEvent> events,
            final ExpectedVersion expectedVersion,
            final Map<String, String> metadata); @Override ImmutableAggregate<TState, TEvent> save(
            @NotNull final Aggregate<TState, TEvent> aggregate,
            final boolean atomic,
            final Map<String, String> metadata);  }