@Test void testScheduleSnapshot_IgnoredWhenSnapshotAlreadyScheduled() { StubExecutor executor = new StubExecutor(); testSubject = TestSnapshotter.builder().eventStore(mockEventStore).executor(executor).build(); testSubject.scheduleSnapshot(Object.class, "id1"); testSubject.scheduleSnapshot(Object.class, "id1"); assertEquals(1, executor.size()); executor.executeNext(); assertEquals(0, executor.size()); testSubject.scheduleSnapshot(Object.class, "id1"); assertEquals(1, executor.size()); }
@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);  }