Search in sources :

Example 86 with Timestamp

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());
}
Also used : Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 87 with Timestamp

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));
}
Also used : Command(io.spine.base.Command) RequiredFieldCommand(io.spine.test.commands.RequiredFieldCommand) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 88 with Timestamp

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);
}
Also used : Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 89 with Timestamp

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);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TaskAdded(io.spine.test.event.TaskAdded) EventStreamQuery(io.spine.server.event.EventStreamQuery) Event(io.spine.base.Event) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Aggregations

Timestamp (com.google.protobuf.Timestamp)89 Test (org.junit.Test)66 Duration (com.google.protobuf.Duration)19 Interval (io.spine.time.Interval)11 Command (io.spine.base.Command)8 AbstractZonedTimeTest (io.spine.time.AbstractZonedTimeTest)8 LocalTime (io.spine.time.LocalTime)8 Message (com.google.protobuf.Message)4 StringValue (com.google.protobuf.StringValue)4 EventStreamQuery (io.spine.server.event.EventStreamQuery)4 TimeTests (io.spine.test.TimeTests)4 Nullable (javax.annotation.Nullable)4 Event (io.spine.base.Event)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Predicate (com.google.common.base.Predicate)2 ByteString (com.google.protobuf.ByteString)2 PubsubMessage (com.google.pubsub.v1.PubsubMessage)2 PullRequest (com.google.pubsub.v1.PullRequest)2 PullResponse (com.google.pubsub.v1.PullResponse)2 ReceivedMessage (com.google.pubsub.v1.ReceivedMessage)2