Search in sources :

Example 1 with Timestamp

use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.

the class TestCommandContextFactory method createCommandContext.

/** Creates a new {@link CommandContext} instance. */
public static CommandContext createCommandContext() {
    final UserId userId = newUserId(newUuid());
    final Timestamp now = getCurrentTime();
    return createCommandContext(userId, now);
}
Also used : UserId(io.spine.users.UserId) Tests.newUserId(io.spine.test.Tests.newUserId) Timestamp(com.google.protobuf.Timestamp)

Example 2 with Timestamp

use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.

the class Timestamps2Should method reset_time_provider_to_default.

@Test
public void reset_time_provider_to_default() {
    final Timestamp aMinuteAgo = subtract(systemTime(), fromMinutes(1));
    setProvider(new TimeTests.FrozenMadHatterParty(aMinuteAgo));
    resetProvider();
    assertNotEquals(aMinuteAgo, getCurrentTime());
}
Also used : TimeTests(io.spine.test.TimeTests) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 3 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 4 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 5 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)

Aggregations

Timestamp (com.google.protobuf.Timestamp)128 Test (org.junit.Test)88 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 StringValue (com.google.protobuf.StringValue)6 Event (io.spine.core.Event)6 Nullable (javax.annotation.Nullable)6 Message (com.google.protobuf.Message)5 Predicate (com.google.common.base.Predicate)4 TimeTests (io.spine.test.TimeTests)4 PubsubMessage (com.google.pubsub.v1.PubsubMessage)3 PullRequest (com.google.pubsub.v1.PullRequest)3 PullResponse (com.google.pubsub.v1.PullResponse)3 ReceivedMessage (com.google.pubsub.v1.ReceivedMessage)3 EventContext (io.spine.core.EventContext)3 Version (io.spine.core.Version)3 ArrayList (java.util.ArrayList)3