@Test void testScheduleSnapshot_SnapshotReplacesOneEvent() { String aggregateIdentifier = "aggregateIdentifier"; when(mockEventStore.readEvents(aggregateIdentifier)).thenReturn(DomainEventStream.of(createEvent(2))); testSubject.scheduleSnapshot(Object.class, aggregateIdentifier); verify(mockEventStore, never()).storeSnapshot(any(DomainEventMessage.class)); }
@Override public void scheduleSnapshot(Class<?> aggregateType, String aggregateIdentifier) { if (CurrentUnitOfWork.isStarted() && CurrentUnitOfWork.get().phase().isBefore(UnitOfWork.Phase.COMMIT)) { CurrentUnitOfWork.get().afterCommit(u -> doScheduleSnapshot(aggregateType, aggregateIdentifier)); } else { doScheduleSnapshot(aggregateType, aggregateIdentifier); } }
AbstractSnapshotter implements Snapshotter { @Override public void scheduleSnapshot(Class<?> aggregateType, String aggregateIdentifier) { if (CurrentUnitOfWork.isStarted() && CurrentUnitOfWork.get().phase().isBefore(UnitOfWork.Phase.COMMIT)) { CurrentUnitOfWork.get().afterCommit(u -> doScheduleSnapshot(aggregateType, aggregateIdentifier)); } else { doScheduleSnapshot(aggregateType, aggregateIdentifier); } } }
AbstractSnapshotter implements Snapshotter { @Override public void scheduleSnapshot(Class<?> aggregateType, String aggregateIdentifier) { if (CurrentUnitOfWork.isStarted() && CurrentUnitOfWork.get().phase().isBefore(UnitOfWork.Phase.COMMIT)) { CurrentUnitOfWork.get().afterCommit(u -> doScheduleSnapshot(aggregateType, aggregateIdentifier)); } else { doScheduleSnapshot(aggregateType, aggregateIdentifier); } } protected  AbstractSnapshotter(Builder builder); }
AbstractSnapshotter implements Snapshotter { @Override public void scheduleSnapshot(Class<?> aggregateType, String aggregateIdentifier) { if (CurrentUnitOfWork.isStarted() && CurrentUnitOfWork.get().phase().isBefore(UnitOfWork.Phase.COMMIT)) { CurrentUnitOfWork.get().afterCommit(u -> doScheduleSnapshot(aggregateType, aggregateIdentifier)); } else { doScheduleSnapshot(aggregateType, aggregateIdentifier); } } protected  AbstractSnapshotter(Builder builder); @Override void scheduleSnapshot(Class<?> aggregateType, String aggregateIdentifier); }
AbstractSnapshotter implements Snapshotter { @Override public void scheduleSnapshot(Class<?> aggregateType, String aggregateIdentifier) { if (CurrentUnitOfWork.isStarted() && CurrentUnitOfWork.get().phase().isBefore(UnitOfWork.Phase.COMMIT)) { CurrentUnitOfWork.get().afterCommit(u -> doScheduleSnapshot(aggregateType, aggregateIdentifier)); } else { doScheduleSnapshot(aggregateType, aggregateIdentifier); } } protected  AbstractSnapshotter(Builder builder); @Override void scheduleSnapshot(Class<?> aggregateType, String aggregateIdentifier);  }