Search in sources :

Example 26 with Timestamp

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);
}
Also used : Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 27 with Timestamp

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());
}
Also used : Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 28 with Timestamp

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);
}
Also used : Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 29 with Timestamp

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);
}
Also used : Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Interval(io.spine.time.Interval) Test(org.junit.Test)

Example 30 with Timestamp

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);
}
Also used : Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Aggregations

Timestamp (com.google.protobuf.Timestamp)89 Test (org.junit.Test)66 Duration (com.google.protobuf.Duration)19 Interval (io.spine.time.Interval)11 Command (io.spine.base.Command)8 AbstractZonedTimeTest (io.spine.time.AbstractZonedTimeTest)8 LocalTime (io.spine.time.LocalTime)8 Message (com.google.protobuf.Message)4 StringValue (com.google.protobuf.StringValue)4 EventStreamQuery (io.spine.server.event.EventStreamQuery)4 TimeTests (io.spine.test.TimeTests)4 Nullable (javax.annotation.Nullable)4 Event (io.spine.base.Event)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Predicate (com.google.common.base.Predicate)2 ByteString (com.google.protobuf.ByteString)2 PubsubMessage (com.google.pubsub.v1.PubsubMessage)2 PullRequest (com.google.pubsub.v1.PullRequest)2 PullResponse (com.google.pubsub.v1.PullResponse)2 ReceivedMessage (com.google.pubsub.v1.ReceivedMessage)2