@Test void testLoadEventsWithSnapshotter() { String identifier = UUID.randomUUID().toString(); when(mockEventStore.readEvents(identifier)).thenReturn(DomainEventStream.of( new GenericDomainEventMessage<>("type", identifier, (long) 1, "Mock contents", emptyInstance()), new GenericDomainEventMessage<>("type", identifier, (long) 2, "Mock contents", emptyInstance()), new GenericDomainEventMessage<>("type", identifier, (long) 3, "Mock contents", emptyInstance()) )); Aggregate<TestAggregate> aggregate = testSubject.load(identifier); aggregate.execute(r -> r.apply(new StubDomainEvent())); aggregate.execute(r -> r.apply(new StubDomainEvent())); InOrder inOrder = Mockito.inOrder(triggerDefinition, snapshotTrigger); inOrder.verify(triggerDefinition).prepareTrigger(stubAggregateFactory.getAggregateType()); inOrder.verify(snapshotTrigger, times(3)).eventHandled(any()); inOrder.verify(snapshotTrigger).initializationFinished(); inOrder.verify(snapshotTrigger, times(2)).eventHandled(any()); }
protected DomainEventStream readEvents(String aggregateIdentifier) { DomainEventStream fullStream = eventStore.readEvents(aggregateIdentifier); return eventStreamFilter != null ? fullStream.filter(eventStreamFilter) : fullStream; }
EventSourcingRepository extends LockingRepository<T, EventSourcedAggregate<T>> { protected DomainEventStream readEvents(String aggregateIdentifier) { DomainEventStream fullStream = eventStore.readEvents(aggregateIdentifier); return eventStreamFilter != null ? fullStream.filter(eventStreamFilter) : fullStream; } }
EventSourcingRepository extends LockingRepository<T, EventSourcedAggregate<T>> { protected DomainEventStream readEvents(String aggregateIdentifier) { DomainEventStream fullStream = eventStore.readEvents(aggregateIdentifier); return eventStreamFilter != null ? fullStream.filter(eventStreamFilter) : fullStream; } protected  EventSourcingRepository(Builder<T> builder); }
EventSourcingRepository extends LockingRepository<T, EventSourcedAggregate<T>> { protected DomainEventStream readEvents(String aggregateIdentifier) { DomainEventStream fullStream = eventStore.readEvents(aggregateIdentifier); return eventStreamFilter != null ? fullStream.filter(eventStreamFilter) : fullStream; } protected  EventSourcingRepository(Builder<T> builder); static Builder<T> builder(Class<T> aggregateType); AggregateFactory<T> getAggregateFactory(); }
EventSourcingRepository extends LockingRepository<T, EventSourcedAggregate<T>> { protected DomainEventStream readEvents(String aggregateIdentifier) { DomainEventStream fullStream = eventStore.readEvents(aggregateIdentifier); return eventStreamFilter != null ? fullStream.filter(eventStreamFilter) : fullStream; } protected  EventSourcingRepository(Builder<T> builder); static Builder<T> builder(Class<T> aggregateType); AggregateFactory<T> getAggregateFactory();  }