use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class BulkWriteOperationShould method store_the_very_last_timestamp_only.
@Test
public void store_the_very_last_timestamp_only() {
final Set<TestProjection> projections = emptySet();
final Timestamp firstEvent = TimeTests.Past.secondsAgo(5L);
final Timestamp secondEvent = TimeTests.Past.secondsAgo(5L);
final Timestamp lastEvent = TimeTests.Past.secondsAgo(5L);
final BulkWriteOperation<Object, TestProjection> operation = newOperation(projections, lastEvent);
assertTrue(operation.isInProgress());
operation.storeLastHandledEventTime(firstEvent);
operation.storeLastHandledEventTime(secondEvent);
operation.storeLastHandledEventTime(lastEvent);
operation.complete();
assertFalse(operation.isInProgress());
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class CommandFactoryShould method create_new_instances_with_current_time.
@Test
public void create_new_instances_with_current_time() {
// We are creating a range of +/- second between the call to make sure the timestamp
// would fit into this range. The purpose of this test is to make sure it works with
// this precision and to add coverage.
final Timestamp beforeCall = TimeTests.Past.secondsAgo(1);
final Command command = factory().command().create(StringValue.getDefaultInstance());
final Timestamp afterCall = TimeTests.Future.secondsFromNow(1);
assertTrue(Timestamps2.isBetween(command.getContext().getActorContext().getTimestamp(), beforeCall, afterCall));
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class ChangesShould method do_not_accept_equal_Timestamp_values.
@Test(expected = IllegalArgumentException.class)
public void do_not_accept_equal_Timestamp_values() {
final Timestamp now = Time.getCurrentTime();
Changes.of(now, now);
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class EventStoreShould method read_events_by_type.
@Test
public void read_events_by_type() {
final Timestamp now = getCurrentTime();
final Event taskAdded1 = taskAdded(now);
final Event projectCreated = projectCreated(now);
final Event teasAdded2 = taskAdded(now);
eventStore.append(taskAdded1);
eventStore.append(projectCreated);
eventStore.append(teasAdded2);
final EventFilter taskAddedType = EventFilter.newBuilder().setEventType(of(TaskAdded.class).value()).build();
final EventStreamQuery query = EventStreamQuery.newBuilder().addFilter(taskAddedType).build();
final AtomicBoolean done = new AtomicBoolean(false);
final Collection<Event> resultEvents = newConcurrentHashSet();
eventStore.read(query, new ResponseObserver(resultEvents, done));
if (!done.get()) {
fail("Please use the MoreExecutors.directExecutor in EventStore for tests.");
}
assertSize(2, resultEvents);
assertContainsAll(resultEvents, taskAdded1, teasAdded2);
}
Aggregations