Search in sources :

Example 46 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, 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 47 with Timestamp

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

the class EventPredicatesShould method do_not_accept_zero_length_time_range.

@Test(expected = IllegalArgumentException.class)
public void do_not_accept_zero_length_time_range() {
    final Timestamp timestamp = minutesAgo(5);
    isBetween(timestamp, timestamp);
}
Also used : Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 48 with Timestamp

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

the class StorageRecords method sequenceFor.

/**
 * Returns several records sorted by timestamp ascending.
 *
 * @param start the timestamp of first record.
 */
public static List<AggregateEventRecord> sequenceFor(ProjectId id, Timestamp start) {
    final Duration delta = seconds(10);
    final Timestamp timestamp2 = add(start, delta);
    final Timestamp timestamp3 = add(timestamp2, delta);
    final TestEventFactory eventFactory = newInstance(Given.class);
    final Event e1 = eventFactory.createEvent(projectCreated(id, Given.projectName(id)), null, start);
    final AggregateEventRecord record1 = StorageRecord.create(start, e1);
    final Event e2 = eventFactory.createEvent(taskAdded(id), null, timestamp2);
    final AggregateEventRecord record2 = StorageRecord.create(timestamp2, e2);
    final Event e3 = eventFactory.createEvent(Given.EventMessage.projectStarted(id), null, timestamp3);
    final AggregateEventRecord record3 = StorageRecord.create(timestamp3, e3);
    return newArrayList(record1, record2, record3);
}
Also used : AggregateEventRecord(io.spine.server.aggregate.AggregateEventRecord) TestEventFactory(io.spine.server.command.TestEventFactory) Event(io.spine.core.Event) Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp)

Example 49 with Timestamp

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

the class OperatorEvaluatorShould method compare_timestamps_by_LE.

@Test
public void compare_timestamps_by_LE() {
    final Duration delta = seconds(5);
    final Timestamp small = getCurrentTime();
    final Timestamp medium = add(small, delta);
    final Timestamp big = add(medium, delta);
    assertTrue(eval(medium, LESS_OR_EQUAL, big));
    assertTrue(eval(small, LESS_OR_EQUAL, medium));
    assertTrue(eval(small, LESS_OR_EQUAL, big));
    assertTrue(eval(medium, LESS_OR_EQUAL, medium));
    assertFalse(eval(big, LESS_OR_EQUAL, small));
    assertFalse(eval(medium, LESS_OR_EQUAL, nullRef()));
}
Also used : Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 50 with Timestamp

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

the class OperatorEvaluatorShould method compare_timestamps_by_LT.

@Test
public void compare_timestamps_by_LT() {
    final Duration delta = seconds(5);
    final Timestamp small = getCurrentTime();
    final Timestamp medium = add(small, delta);
    final Timestamp big = add(medium, delta);
    assertTrue(eval(medium, LESS_THAN, big));
    assertTrue(eval(small, LESS_THAN, medium));
    assertTrue(eval(small, LESS_THAN, big));
    assertFalse(eval(big, LESS_THAN, big));
    assertFalse(eval(big, LESS_THAN, small));
    assertFalse(eval(nullRef(), LESS_THAN, nullRef()));
}
Also used : Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Aggregations

Timestamp (com.google.protobuf.Timestamp)120 Test (org.junit.Test)84 Duration (com.google.protobuf.Duration)24 Interval (io.spine.time.Interval)16 Command (io.spine.core.Command)9 AbstractZonedTimeTest (io.spine.time.AbstractZonedTimeTest)8 LocalTime (io.spine.time.LocalTime)8 Nullable (javax.annotation.Nullable)7 StringValue (com.google.protobuf.StringValue)6 Event (io.spine.core.Event)6 Message (com.google.protobuf.Message)5 Predicate (com.google.common.base.Predicate)4 TimeTests (io.spine.test.TimeTests)4 CommandContext (io.spine.core.CommandContext)3 EventContext (io.spine.core.EventContext)3 Version (io.spine.core.Version)3 Any (com.google.protobuf.Any)2 ByteString (com.google.protobuf.ByteString)2 PubsubMessage (com.google.pubsub.v1.PubsubMessage)2 PullRequest (com.google.pubsub.v1.PullRequest)2