Search in sources :

Example 21 with Timestamp

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

the class MessageFieldValidator method isTimestamp.

private boolean isTimestamp() {
    final ImmutableList<Message> values = getValues();
    final Message value = values.isEmpty() ? null : values.get(0);
    final boolean isTimestamp = value instanceof Timestamp;
    return isTimestamp;
}
Also used : Message(com.google.protobuf.Message) Timestamp(com.google.protobuf.Timestamp)

Example 22 with Timestamp

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

the class ChangesShould method create_TimestampChange_instance.

@Test
public void create_TimestampChange_instance() {
    final Timestamp fiveMinutesAgo = TimeTests.Past.minutesAgo(5);
    final Timestamp now = Time.getCurrentTime();
    final TimestampChange result = Changes.of(fiveMinutesAgo, now);
    assertEquals(fiveMinutesAgo, result.getPreviousValue());
    assertEquals(now, result.getNewValue());
}
Also used : TimestampChange(io.spine.change.TimestampChange) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 23 with Timestamp

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

the class BulkWriteOperation method checkExpiration.

/**
     * Verifies if the operation lasts for too long. If so, completes the operation,
     * otherwise performs no action.
     *
     * <p>Performs no action if the operation is already finished.
     *
     * @see #complete()
     */
void checkExpiration() {
    if (!isInProgress()) {
        return;
    }
    final Timestamp currentTime = getCurrentTime();
    if (Timestamps2.compare(currentTime, expirationTime) > 0) {
        log().warn("Completing bulk write operation before all the events are processed.");
        complete();
    }
}
Also used : Timestamp(com.google.protobuf.Timestamp)

Example 24 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 25 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)

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