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);
}
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);
}
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);
}
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()));
}
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()));
}
Aggregations