use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class IntervalsShould method calculate_duration_of_zero_interval.
@Test(expected = IllegalArgumentException.class)
public void calculate_duration_of_zero_interval() {
final Timestamp start = newTimestamp(5, 6);
final Timestamp end = newTimestamp(5, 6);
final Duration expectedDuration = Duration.newBuilder().setSeconds(end.getSeconds() - start.getSeconds()).setNanos(end.getNanos() - start.getNanos()).build();
final Interval interval = Intervals.between(start, end);
final Duration actualDuration = Intervals.toDuration(interval);
assertEquals(expectedDuration, actualDuration);
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class IntervalsShould method return_interval_between_two_timestamps.
@Test
public void return_interval_between_two_timestamps() {
final Timestamp start = newTimestamp(5, 6);
final Timestamp end = newTimestamp(10, 10);
final Interval interval = Interval.newBuilder().setStart(start).setEnd(end).build();
assertEquals(interval, Intervals.between(start, end));
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class CommandTestShould method create_command_with_custom_Timestamp.
@Test
public void create_command_with_custom_Timestamp() {
final StringValue commandMessage = newUuidValue();
final Timestamp timestamp = TimeTests.Past.minutesAgo(5);
final Command command = commandTest.createCommand(commandMessage, timestamp);
assertEquals(timestamp, command.getContext().getActorContext().getTimestamp());
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class TimeTestsShould method have_frozen_time_provider.
@Test
public void have_frozen_time_provider() {
final Timestamp fiveMinutesAgo = subtract(getCurrentTime(), fromMinutes(5));
final Time.Provider provider = new TimeTests.FrozenMadHatterParty(fiveMinutesAgo);
assertEquals(fiveMinutesAgo, provider.getCurrentTime());
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class TimeChangesShould method do_not_accept_null_Interval_newValue.
@Test(expected = NullPointerException.class)
public void do_not_accept_null_Interval_newValue() {
final Timestamp fourMinutesAgo = TimeTests.Past.minutesAgo(4);
final Timestamp now = getCurrentTime();
final Interval fourMinutes = Intervals.between(fourMinutesAgo, now);
TimeChanges.of(fourMinutes, null);
}
Aggregations