use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class Timestamps2Should method convert_timestamp_to_nanos.
@Test
public void convert_timestamp_to_nanos() {
final Timestamp expectedTime = getCurrentTime();
final long nanos = toNanos(expectedTime);
final long expectedNanos = expectedTime.getSeconds() * NANOS_PER_SECOND + expectedTime.getNanos();
assertEquals(expectedNanos, nanos);
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class Timestamps2Should method return_false_if_timestamp_is_not_between_two_timestamps.
@Test
public void return_false_if_timestamp_is_not_between_two_timestamps() {
final Timestamp start = getCurrentTime();
final Timestamp finish = add(start, TEN_SECONDS);
final Timestamp timeNotBetween = add(finish, TEN_SECONDS);
final boolean isBetween = isBetween(timeNotBetween, start, finish);
assertFalse(isBetween);
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class Timestamps2Should method compare_timestamps_return_positive_int_if_first_greater_than_second_one.
@Test
public void compare_timestamps_return_positive_int_if_first_greater_than_second_one() {
final Timestamp currentTime = getCurrentTime();
final Timestamp timeAfterCurrent = add(currentTime, TEN_SECONDS);
final int result = Timestamps.comparator().compare(timeAfterCurrent, currentTime);
assertTrue(result > 0);
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class IntervalsShould method return_true_if_interval_contains_timestamp.
@Test
public void return_true_if_interval_contains_timestamp() {
final Timestamp start = newTimestamp(5, 6);
final Timestamp end = newTimestamp(10, 10);
final Timestamp between = newTimestamp(7, 100);
final Interval interval = Interval.newBuilder().setStart(start).setEnd(end).build();
assertTrue(Intervals.contains(interval, between));
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class IntervalsShould method return_duration_zero.
@Test
public void return_duration_zero() {
final Timestamp start = newTimestamp(5, 6);
final Interval interval = Interval.newBuilder().setStart(start).setEnd(start).build();
assertEquals(0L, Intervals.toDuration(interval).getSeconds());
}
Aggregations