use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class ChangesShould method create_TimestampChange_instance.
@Test
public void create_TimestampChange_instance() {
final Timestamp fiveMinutesAgo = TimeTests.Past.minutesAgo(5);
final Timestamp now = getCurrentTime();
final TimestampChange result = Changes.of(fiveMinutesAgo, now);
assertEquals(fiveMinutesAgo, result.getPreviousValue());
assertEquals(now, result.getNewValue());
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class ChangesShould method create_IntervalChange_instance.
@Test
public void create_IntervalChange_instance() {
final Timestamp fiveMinutesAgo = TimeTests.Past.minutesAgo(5);
final Timestamp fourMinutesAgo = TimeTests.Past.minutesAgo(4);
final Timestamp now = getCurrentTime();
final Interval fourMinutes = Intervals.between(fourMinutesAgo, now);
final Interval fiveMinutes = Intervals.between(fiveMinutesAgo, now);
final IntervalChange result = Changes.of(fourMinutes, fiveMinutes);
assertEquals(fourMinutes, result.getPreviousValue());
assertEquals(fiveMinutes, result.getNewValue());
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class EventStoreShould method read_events_by_time_bounds.
@Test
public void read_events_by_time_bounds() {
final Duration delta = Durations2.seconds(111);
final Timestamp present = getCurrentTime();
final Timestamp past = subtract(present, delta);
final Timestamp future = add(present, delta);
final Event eventInPast = projectCreated(past);
final Event eventInPresent = projectCreated(present);
final Event eventInFuture = projectCreated(future);
eventStore.append(eventInPast);
eventStore.append(eventInPresent);
eventStore.append(eventInFuture);
final EventStreamQuery query = EventStreamQuery.newBuilder().setAfter(past).setBefore(future).build();
final AtomicBoolean done = new AtomicBoolean(false);
final Collection<Event> resultEvents = newConcurrentHashSet();
eventStore.read(query, new ResponseObserver(resultEvents, done));
assertDone(done);
assertSize(1, resultEvents);
final Event event = resultEvents.iterator().next();
assertEquals(eventInPresent, event);
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class EventStoreShould method read_events_by_time_and_type.
@Test
public void read_events_by_time_and_type() {
final Duration delta = Durations2.seconds(111);
final Timestamp present = getCurrentTime();
final Timestamp past = subtract(present, delta);
final Timestamp future = add(present, delta);
final Event eventInPast = taskAdded(past);
final Event eventInPresent = projectCreated(present);
final Event eventInFuture = taskAdded(future);
eventStore.append(eventInPast);
eventStore.append(eventInPresent);
eventStore.append(eventInFuture);
final EventFilter taskAddedType = EventFilter.newBuilder().setEventType(of(TaskAdded.class).value()).build();
final EventStreamQuery query = EventStreamQuery.newBuilder().setAfter(past).addFilter(taskAddedType).build();
final AtomicBoolean done = new AtomicBoolean(false);
final Collection<Event> resultEvents = newConcurrentHashSet();
eventStore.read(query, new ResponseObserver(resultEvents, done));
assertDone(done);
assertSize(1, resultEvents);
final Event event = resultEvents.iterator().next();
assertEquals(eventInFuture, event);
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class CommandSchedulingShould method update_schedule_options.
@Test
public void update_schedule_options() {
final Command cmd = requestFactory.command().create(toMessage(newUuid()));
final Timestamp schedulingTime = getCurrentTime();
final Duration delay = Durations2.minutes(5);
final Command cmdUpdated = setSchedule(cmd, delay, schedulingTime);
final CommandContext.Schedule schedule = cmdUpdated.getContext().getSchedule();
assertEquals(delay, schedule.getDelay());
assertEquals(schedulingTime, cmdUpdated.getSystemProperties().getSchedulingTime());
}
Aggregations