@Test void testCreateTokenAtWhenIsNotPresentInActiveStorage() { Instant now = Instant.now(); TrackingToken mockTrackingToken = new GlobalSequenceTrackingToken(3); when(activeStorage.createTokenAt(now)).thenReturn(null); when(historicStorage.createTokenAt(now)).thenReturn(mockTrackingToken); TrackingToken tokenAt = testSubject.createTokenAt(now); assertEquals(mockTrackingToken, tokenAt); }
@Override public TrackingToken createTokenAt(Instant dateTime) { TrackingToken tokenFromActiveStorage = activeStorage.createTokenAt(dateTime); if (tokenFromActiveStorage == null) { return historicStorage.createTokenAt(dateTime); } return tokenFromActiveStorage; }
SequenceEventStorageEngine implements EventStorageEngine { @Override public TrackingToken createTokenAt(Instant dateTime) { TrackingToken tokenFromActiveStorage = activeStorage.createTokenAt(dateTime); if (tokenFromActiveStorage == null) { return historicStorage.createTokenAt(dateTime); } return tokenFromActiveStorage; } }
SequenceEventStorageEngine implements EventStorageEngine { @Override public TrackingToken createTokenAt(Instant dateTime) { TrackingToken tokenFromActiveStorage = activeStorage.createTokenAt(dateTime); if (tokenFromActiveStorage == null) { return historicStorage.createTokenAt(dateTime); } return tokenFromActiveStorage; } SequenceEventStorageEngine(EventStorageEngine historicStorage, EventStorageEngine activeStorage); }
SequenceEventStorageEngine implements EventStorageEngine { @Override public TrackingToken createTokenAt(Instant dateTime) { TrackingToken tokenFromActiveStorage = activeStorage.createTokenAt(dateTime); if (tokenFromActiveStorage == null) { return historicStorage.createTokenAt(dateTime); } return tokenFromActiveStorage; } SequenceEventStorageEngine(EventStorageEngine historicStorage, EventStorageEngine activeStorage); @Override void appendEvents(List<? extends EventMessage<?>> events); @Override void storeSnapshot(DomainEventMessage<?> snapshot); @Override Stream<? extends TrackedEventMessage<?>> readEvents(TrackingToken trackingToken, boolean mayBlock); @Override DomainEventStream readEvents(String aggregateIdentifier, long firstSequenceNumber); @Override Optional<DomainEventMessage<?>> readSnapshot(String aggregateIdentifier); @Override Optional<Long> lastSequenceNumberFor(String aggregateIdentifier); @Override TrackingToken createTailToken(); @Override TrackingToken createHeadToken(); @Override TrackingToken createTokenAt(Instant dateTime); }
SequenceEventStorageEngine implements EventStorageEngine { @Override public TrackingToken createTokenAt(Instant dateTime) { TrackingToken tokenFromActiveStorage = activeStorage.createTokenAt(dateTime); if (tokenFromActiveStorage == null) { return historicStorage.createTokenAt(dateTime); } return tokenFromActiveStorage; } SequenceEventStorageEngine(EventStorageEngine historicStorage, EventStorageEngine activeStorage); @Override void appendEvents(List<? extends EventMessage<?>> events); @Override void storeSnapshot(DomainEventMessage<?> snapshot); @Override Stream<? extends TrackedEventMessage<?>> readEvents(TrackingToken trackingToken, boolean mayBlock); @Override DomainEventStream readEvents(String aggregateIdentifier, long firstSequenceNumber); @Override Optional<DomainEventMessage<?>> readSnapshot(String aggregateIdentifier); @Override Optional<Long> lastSequenceNumberFor(String aggregateIdentifier); @Override TrackingToken createTailToken(); @Override TrackingToken createHeadToken(); @Override TrackingToken createTokenAt(Instant dateTime);  }