@Test void testSnapshotterTriggeredOnUnitOfWorkCleanup() { SnapshotTrigger trigger = testSubject.prepareTrigger(aggregate.rootType()); GenericDomainEventMessage<String> msg = new GenericDomainEventMessage<>( "type", aggregateIdentifier, 0, "Mock contents", MetaData.emptyInstance() ); trigger.eventHandled(msg); trigger.eventHandled(msg); trigger.eventHandled(msg); trigger.eventHandled(msg); verify(mockSnapshotter, never()).scheduleSnapshot(aggregate.rootType(), aggregateIdentifier); CurrentUnitOfWork.get() .onCommit(uow -> verify(mockSnapshotter, never()) .scheduleSnapshot(aggregate.rootType(), aggregateIdentifier)); CurrentUnitOfWork.commit(); verify(mockSnapshotter).scheduleSnapshot(aggregate.rootType(), aggregateIdentifier); }
@Override public SnapshotTrigger prepareTrigger(Class<?> aggregateType) { return new EventCountSnapshotTrigger(snapshotter, aggregateType, threshold); }
EventCountSnapshotTriggerDefinition implements SnapshotTriggerDefinition { @Override public SnapshotTrigger prepareTrigger(Class<?> aggregateType) { return new EventCountSnapshotTrigger(snapshotter, aggregateType, threshold); } }
EventCountSnapshotTriggerDefinition implements SnapshotTriggerDefinition { @Override public SnapshotTrigger prepareTrigger(Class<?> aggregateType) { return new EventCountSnapshotTrigger(snapshotter, aggregateType, threshold); } EventCountSnapshotTriggerDefinition(Snapshotter snapshotter, int threshold); }
EventCountSnapshotTriggerDefinition implements SnapshotTriggerDefinition { @Override public SnapshotTrigger prepareTrigger(Class<?> aggregateType) { return new EventCountSnapshotTrigger(snapshotter, aggregateType, threshold); } EventCountSnapshotTriggerDefinition(Snapshotter snapshotter, int threshold); @Override SnapshotTrigger prepareTrigger(Class<?> aggregateType); @Override SnapshotTrigger reconfigure(Class<?> aggregateType, SnapshotTrigger trigger); }
EventCountSnapshotTriggerDefinition implements SnapshotTriggerDefinition { @Override public SnapshotTrigger prepareTrigger(Class<?> aggregateType) { return new EventCountSnapshotTrigger(snapshotter, aggregateType, threshold); } EventCountSnapshotTriggerDefinition(Snapshotter snapshotter, int threshold); @Override SnapshotTrigger prepareTrigger(Class<?> aggregateType); @Override SnapshotTrigger reconfigure(Class<?> aggregateType, SnapshotTrigger trigger);  }