Search in sources :

Example 71 with Timestamp

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

the class AggregateBuilderShould method create_aggregate.

@Test
public void create_aggregate() {
    final int id = 2048;
    final int version = 2017;
    final Timestamp whenModified = Time.getCurrentTime();
    final Timestamp state = TimeTests.Past.minutesAgo(60);
    final Aggregate aggregate = givenAggregate().withId(id).withVersion(version).withState(state).modifiedOn(whenModified).build();
    assertEquals(TestAggregate.class, aggregate.getClass());
    assertEquals(id, aggregate.getId());
    assertEquals(state, aggregate.getState());
    assertEquals(version, aggregate.getVersion().getNumber());
    assertEquals(whenModified, aggregate.whenModified());
}
Also used : Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 72 with Timestamp

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

the class EntityBuilderShould method create_entity.

@Test
public void create_entity() {
    final long id = 1024L;
    final int version = 100500;
    final StringValue state = Wrapper.forString(getClass().getName());
    final Timestamp timestamp = Time.getCurrentTime();
    final VersionableEntity entity = givenEntity().withId(id).withVersion(version).withState(state).modifiedOn(timestamp).build();
    assertEquals(TestEntity.class, entity.getClass());
    assertEquals(id, entity.getId());
    assertEquals(state, entity.getState());
    assertEquals(version, entity.getVersion().getNumber());
    assertEquals(timestamp, entity.getVersion().getTimestamp());
}
Also used : StringValue(com.google.protobuf.StringValue) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 73 with Timestamp

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

the class CommandTestShould method create_command_with_custom_Timestamp.

@Test
public void create_command_with_custom_Timestamp() {
    final StringValue commandMessage = newUuidValue();
    final Timestamp timestamp = TimeTests.Past.minutesAgo(5);
    final Command command = commandTest.createCommand(commandMessage, timestamp);
    assertEquals(timestamp, command.getContext().getActorContext().getTimestamp());
}
Also used : Command(io.spine.base.Command) StringValue(com.google.protobuf.StringValue) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 74 with Timestamp

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

the class TimeTestsShould method have_frozen_time_provider.

@Test
public void have_frozen_time_provider() {
    final Timestamp fiveMinutesAgo = subtract(getCurrentTime(), fromMinutes(5));
    final Time.Provider provider = new TimeTests.FrozenMadHatterParty(fiveMinutesAgo);
    assertEquals(fiveMinutesAgo, provider.getCurrentTime());
}
Also used : Time(io.spine.time.Time) Time.getCurrentTime(io.spine.time.Time.getCurrentTime) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 75 with Timestamp

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

the class MessageFieldValidator method validateTimestamps.

private void validateTimestamps() {
    final Time when = timeOption.getIn();
    if (when == TIME_UNDEFINED) {
        return;
    }
    final Timestamp now = getCurrentTime();
    for (Message value : getValues()) {
        final Timestamp time = (Timestamp) value;
        if (isTimeInvalid(time, when, now)) {
            addViolation(newTimeViolation(time));
            // return because one error message is enough for the "time" option
            return;
        }
    }
}
Also used : Message(com.google.protobuf.Message) Time(io.spine.option.Time) Time.getCurrentTime(io.spine.time.Time.getCurrentTime) Timestamp(com.google.protobuf.Timestamp)

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