use of com.google.protobuf.Duration in project core-java by SpineEventEngine.
the class ProjectionRepositoryShould method perform_bulk_catch_up_if_required.
// Due to mockito matcher usage
@SuppressWarnings("unchecked")
@Test
public void perform_bulk_catch_up_if_required() {
final ProjectId projectId = ProjectId.newBuilder().setId("mock-project-id").build();
final Message eventMessage = ProjectCreated.newBuilder().setProjectId(projectId).build();
final Event event = createEvent(pack(projectId), eventMessage);
appendEvent(boundedContext.getEventBus().getEventStore(), event);
// Set up repository
final Duration duration = Durations2.seconds(10L);
final ProjectionRepository repository = spy(new ManualCatchupProjectionRepository(boundedContext, duration));
repository.initStorage(storageFactory());
repository.catchUp();
// Check bulk write
verify(repository).store(any(Collection.class));
verify(repository, never()).store(any(TestProjection.class));
}
use of com.google.protobuf.Duration in project core-java by SpineEventEngine.
the class BulkWriteOperationShould method complete_on_timeout.
@SuppressWarnings("MagicNumber")
@Test
public void complete_on_timeout() throws InterruptedException {
final Duration duration = Durations2.nanos(1L);
final FlushCallback callback = spy(new EmptyCallback());
// Due to `spy` usage
@SuppressWarnings("unchecked") final BulkWriteOperation operation = spy(new BulkWriteOperation(duration, callback));
assertTrue(operation.isInProgress());
Thread.sleep(10L);
operation.checkExpiration();
assertFalse(operation.isInProgress());
verify(operation).complete();
verify(callback).onFlushResults(any(Set.class), any(Timestamp.class));
}
use of com.google.protobuf.Duration in project core-java by SpineEventEngine.
the class BulkWriteOperationShould method newOperation.
private static BulkWriteOperation<Object, TestProjection> newOperation() {
final Duration duration = Durations2.seconds(100);
final BulkWriteOperation<Object, TestProjection> operation = new BulkWriteOperation<>(duration, new EmptyCallback());
return operation;
}
use of com.google.protobuf.Duration in project core-java by SpineEventEngine.
the class BulkWriteOperationShould method newOperation.
private static BulkWriteOperation<Object, TestProjection> newOperation(Set<TestProjection> projections, Timestamp lastHandldEventTime) {
final Duration duration = Durations2.seconds(100);
final BulkWriteOperation<Object, TestProjection> operation = new BulkWriteOperation<>(duration, new AssertResults(projections, lastHandldEventTime));
return operation;
}
use of com.google.protobuf.Duration in project core-java by SpineEventEngine.
the class EventStoreShould method read_events_by_time_bounds.
@Test
public void read_events_by_time_bounds() {
final Duration delta = Durations2.seconds(111);
final Timestamp present = getCurrentTime();
final Timestamp past = subtract(present, delta);
final Timestamp future = add(present, delta);
final Event eventInPast = projectCreated(past);
final Event eventInPresent = projectCreated(present);
final Event eventInFuture = projectCreated(future);
eventStore.append(eventInPast);
eventStore.append(eventInPresent);
eventStore.append(eventInFuture);
final EventStreamQuery query = EventStreamQuery.newBuilder().setAfter(past).setBefore(future).build();
final AtomicBoolean done = new AtomicBoolean(false);
final Collection<Event> resultEvents = newConcurrentHashSet();
eventStore.read(query, new ResponseObserver(resultEvents, done));
assertDone(done);
assertSize(1, resultEvents);
final Event event = resultEvents.iterator().next();
assertEquals(eventInPresent, event);
}
Aggregations