use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class Timestamps2Should method compare_two_timestamps_return_negative_int_if_first_is_null.
@Test
public void compare_two_timestamps_return_negative_int_if_first_is_null() {
final Timestamp currentTime = getCurrentTime();
final int result = compare(null, currentTime);
assertTrue(result < 0);
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class Timestamps2Should method calculate_timestamp_of_moment_minute_ago.
@Test
public void calculate_timestamp_of_moment_minute_ago() {
final Timestamp currentTime = getCurrentTime();
final Timestamp expected = subtract(currentTime, MINUTE);
final Timestamp actual = TimeTests.Past.minutesAgo(1);
assertEquals(expected.getSeconds(), actual.getSeconds());
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class Timestamps2Should method compare_two_timestamps_using_comparator_return_zero_if_timestamps_are_equal.
@Test
public void compare_two_timestamps_using_comparator_return_zero_if_timestamps_are_equal() {
final int secs = 256;
final int nanos = 512;
final Timestamp time1 = Timestamp.newBuilder().setSeconds(secs).setNanos(nanos).build();
final Timestamp time2 = Timestamp.newBuilder().setSeconds(secs).setNanos(nanos).build();
final int result = Timestamps.comparator().compare(time1, time2);
assertEquals(0, result);
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class IntervalsShould method calculate_duration_of_interval.
@Test
public void calculate_duration_of_interval() {
final Timestamp start = newTimestamp(5, 6);
final Timestamp end = newTimestamp(10, 10);
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 Timestamps2Should method compare_two_timestamps_return_zero_if_timestamps_are_equal.
@Test
public void compare_two_timestamps_return_zero_if_timestamps_are_equal() {
final int secs = 256;
final int nanos = 512;
final Timestamp time1 = Timestamp.newBuilder().setSeconds(secs).setNanos(nanos).build();
final Timestamp time2 = Timestamp.newBuilder().setSeconds(secs).setNanos(nanos).build();
final int result = compare(time1, time2);
assertEquals(0, result);
}
Aggregations