Search in sources :

Example 61 with Timestamp

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

the class EventPredicatesShould method do_not_accept_zero_length_time_range.

@Test(expected = IllegalArgumentException.class)
public void do_not_accept_zero_length_time_range() {
    final Timestamp timestamp = minutesAgo(5);
    isBetween(timestamp, timestamp);
}
Also used : Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 62 with Timestamp

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

the class EventFactory method toEventContext.

private static EventContext toEventContext(IntegrationEventContext value) {
    final StringValue producerId = Wrapper.forString(value.getBoundedContextName());
    final Timestamp timestamp = value.getTimestamp();
    final Any producerAny = pack(producerId);
    return EventContext.newBuilder().setTimestamp(timestamp).setProducerId(producerAny).build();
}
Also used : StringValue(com.google.protobuf.StringValue) Timestamp(com.google.protobuf.Timestamp) Any(com.google.protobuf.Any) Messages.toAny(io.spine.protobuf.Messages.toAny)

Example 63 with Timestamp

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

the class EventFactory method createContext.

private static EventContext createContext(Any producerId, CommandContext commandContext, @Nullable Version version) {
    final Timestamp timestamp = getCurrentTime();
    final EventContext.Builder builder = EventContext.newBuilder().setTimestamp(timestamp).setCommandContext(commandContext).setProducerId(producerId);
    if (version != null) {
        builder.setVersion(version);
    }
    return builder.build();
}
Also used : IntegrationEventContext(io.spine.server.integration.IntegrationEventContext) EventContext(io.spine.base.EventContext) Timestamp(com.google.protobuf.Timestamp)

Example 64 with Timestamp

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

the class Events method getTimestamp.

/**
     * Obtains the timestamp of the event.
     */
public static Timestamp getTimestamp(Event event) {
    checkNotNull(event);
    final Timestamp result = event.getContext().getTimestamp();
    return result;
}
Also used : Timestamp(com.google.protobuf.Timestamp)

Example 65 with Timestamp

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

the class Commands method getTimestamp.

private static Timestamp getTimestamp(Command request) {
    checkNotNull(request);
    final Timestamp result = request.getContext().getActorContext().getTimestamp();
    return result;
}
Also used : Timestamp(com.google.protobuf.Timestamp)

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