Search in sources :

Example 81 with Timestamp

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

the class IntervalsShould method calculate_duration_of_zero_interval.

@Test(expected = IllegalArgumentException.class)
public void calculate_duration_of_zero_interval() {
    final Timestamp start = newTimestamp(5, 6);
    final Timestamp end = newTimestamp(5, 6);
    final Duration expectedDuration = Duration.newBuilder().setSeconds(end.getSeconds() - start.getSeconds()).setNanos(end.getNanos() - start.getNanos()).build();
    final Interval interval = Intervals.between(start, end);
    final Duration actualDuration = Intervals.toDuration(interval);
    assertEquals(expectedDuration, actualDuration);
}
Also used : Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Interval(io.spine.time.Interval) Test(org.junit.Test)

Example 82 with Timestamp

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

the class IntervalsShould method return_interval_between_two_timestamps.

@Test
public void return_interval_between_two_timestamps() {
    final Timestamp start = newTimestamp(5, 6);
    final Timestamp end = newTimestamp(10, 10);
    final Interval interval = Interval.newBuilder().setStart(start).setEnd(end).build();
    assertEquals(interval, Intervals.between(start, end));
}
Also used : Timestamp(com.google.protobuf.Timestamp) Interval(io.spine.time.Interval) Test(org.junit.Test)

Example 83 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 84 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 85 with Timestamp

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

the class TimeChangesShould method do_not_accept_null_Interval_newValue.

@Test(expected = NullPointerException.class)
public void do_not_accept_null_Interval_newValue() {
    final Timestamp fourMinutesAgo = TimeTests.Past.minutesAgo(4);
    final Timestamp now = getCurrentTime();
    final Interval fourMinutes = Intervals.between(fourMinutesAgo, now);
    TimeChanges.of(fourMinutes, null);
}
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