Search in sources :

Example 76 with Timestamp

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

Example 77 with Timestamp

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

Example 78 with Timestamp

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

Example 79 with Timestamp

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

Example 80 with Timestamp

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

Aggregations

Timestamp (com.google.protobuf.Timestamp)120 Test (org.junit.Test)84 Duration (com.google.protobuf.Duration)24 Interval (io.spine.time.Interval)16 Command (io.spine.core.Command)9 AbstractZonedTimeTest (io.spine.time.AbstractZonedTimeTest)8 LocalTime (io.spine.time.LocalTime)8 Nullable (javax.annotation.Nullable)7 StringValue (com.google.protobuf.StringValue)6 Event (io.spine.core.Event)6 Message (com.google.protobuf.Message)5 Predicate (com.google.common.base.Predicate)4 TimeTests (io.spine.test.TimeTests)4 CommandContext (io.spine.core.CommandContext)3 EventContext (io.spine.core.EventContext)3 Version (io.spine.core.Version)3 Any (com.google.protobuf.Any)2 ByteString (com.google.protobuf.ByteString)2 PubsubMessage (com.google.pubsub.v1.PubsubMessage)2 PullRequest (com.google.pubsub.v1.PullRequest)2