Search in sources :

Example 11 with Timestamp

use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.

the class AggregateStorageShould method write_records_and_load_history_till_last_snapshot.

@Test
public void write_records_and_load_history_till_last_snapshot() {
    final Duration delta = seconds(10);
    final Timestamp time1 = getCurrentTime();
    final Timestamp time2 = add(time1, delta);
    final Timestamp time3 = add(time2, delta);
    storage.writeRecord(id, Given.StorageRecord.create(time1));
    storage.writeSnapshot(id, newSnapshot(time2));
    testWriteRecordsAndLoadHistory(time3);
}
Also used : Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 12 with Timestamp

use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.

the class AggregateShould method return_non_null_time_when_was_last_modified.

@Test
public void return_non_null_time_when_was_last_modified() {
    final Timestamp creationTime = new TestAggregate(ID).whenModified();
    assertNotNull(creationTime);
}
Also used : Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 13 with Timestamp

use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.

the class AggregateShould method record_modification_time_when_command_handled.

@Test
public void record_modification_time_when_command_handled() {
    try {
        final Timestamp frozenTime = Time.getCurrentTime();
        Time.setProvider(new TimeTests.FrozenMadHatterParty(frozenTime));
        dispatch(aggregate, env(createProject));
        assertEquals(frozenTime, aggregate.whenModified());
    } finally {
        Time.resetProvider();
    }
}
Also used : TimeTests(io.spine.test.TimeTests) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 14 with Timestamp

use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.

the class ProjectionStorageShould method write_and_read_last_event_time_several_times.

@Test
public void write_and_read_last_event_time_several_times() {
    final Timestamp time1 = getCurrentTime();
    final Timestamp time2 = add(time1, fromSeconds(10L));
    writeAndReadLastEventTimeTest(time1);
    writeAndReadLastEventTimeTest(time2);
}
Also used : Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 15 with Timestamp

use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.

the class Commands method wereAfter.

/**
     * Creates a predicate for filtering commands created after the passed timestamp.
     */
public static Predicate<Command> wereAfter(final Timestamp from) {
    checkNotNull(from);
    return new Predicate<Command>() {

        @Override
        public boolean apply(@Nullable Command request) {
            checkNotNull(request);
            final Timestamp timestamp = getTimestamp(request);
            return Timestamps2.isLaterThan(timestamp, from);
        }
    };
}
Also used : Timestamp(com.google.protobuf.Timestamp) Nullable(javax.annotation.Nullable) Predicate(com.google.common.base.Predicate)

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