Search in sources :

Example 16 with Duration

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

the class OffsetTimesShould method subtract_hours.

@Test
public void subtract_hours() {
    final int hoursDelta = random(1, 500);
    final Duration deltaDuration = Durations2.hours(hoursDelta);
    final Timestamp gmtPast = Timestamps.subtract(gmtNow, deltaDuration);
    final LocalTime expectedPast = LocalTimes.timeAt(gmtPast, zoneOffset);
    final LocalTime actualPast = subtractHours(now, hoursDelta).getTime();
    assertEquals(expectedPast, actualPast);
}
Also used : LocalTime(io.spine.time.LocalTime) Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test) AbstractZonedTimeTest(io.spine.time.AbstractZonedTimeTest)

Example 17 with Duration

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

the class OffsetTimesShould method add_seconds.

@Test
public void add_seconds() {
    final int secondsDelta = random(1, 300);
    final Duration deltaDuration = Durations2.seconds(secondsDelta);
    final Timestamp gmtFuture = Timestamps.add(gmtNow, deltaDuration);
    final LocalTime expectedFuture = LocalTimes.timeAt(gmtFuture, zoneOffset);
    final LocalTime actualFuture = addSeconds(now, secondsDelta).getTime();
    assertEquals(expectedFuture, actualFuture);
}
Also used : LocalTime(io.spine.time.LocalTime) Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test) AbstractZonedTimeTest(io.spine.time.AbstractZonedTimeTest)

Example 18 with Duration

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

the class OffsetTimesShould method subtract_seconds.

@Test
public void subtract_seconds() {
    final int secondsDelta = random(1, 1024);
    final Duration deltaDuration = Durations2.seconds(secondsDelta);
    final Timestamp gmtPast = Timestamps.subtract(gmtNow, deltaDuration);
    final LocalTime expectedPast = LocalTimes.timeAt(gmtPast, zoneOffset);
    final LocalTime actualPast = subtractSeconds(now, secondsDelta).getTime();
    assertEquals(expectedPast, actualPast);
}
Also used : LocalTime(io.spine.time.LocalTime) Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test) AbstractZonedTimeTest(io.spine.time.AbstractZonedTimeTest)

Example 19 with Duration

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

the class OffsetTimesShould method add_millis.

@Test
public void add_millis() {
    final int millisDelta = random(1, 100_000_000);
    final Duration deltaDuration = Durations.fromMillis(millisDelta);
    final Timestamp gmtFuture = Timestamps.add(gmtNow, deltaDuration);
    final LocalTime expectedFuture = LocalTimes.timeAt(gmtFuture, zoneOffset);
    final LocalTime actualFuture = addMillis(now, millisDelta).getTime();
    assertEquals(expectedFuture, actualFuture);
}
Also used : LocalTime(io.spine.time.LocalTime) Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test) AbstractZonedTimeTest(io.spine.time.AbstractZonedTimeTest)

Example 20 with Duration

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

the class OffsetTimesShould method subtract_millis.

@Test
public void subtract_millis() {
    final int millisDelta = random(1, 999_999);
    final Duration deltaDuration = Durations.fromMillis(millisDelta);
    final Timestamp gmtPast = Timestamps.subtract(gmtNow, deltaDuration);
    final LocalTime expectedPast = LocalTimes.timeAt(gmtPast, zoneOffset);
    final LocalTime actualPast = subtractMillis(now, millisDelta).getTime();
    assertEquals(expectedPast, actualPast);
}
Also used : LocalTime(io.spine.time.LocalTime) Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test) AbstractZonedTimeTest(io.spine.time.AbstractZonedTimeTest)

Aggregations

Duration (com.google.protobuf.Duration)38 Test (org.junit.Test)26 Timestamp (com.google.protobuf.Timestamp)20 AbstractZonedTimeTest (io.spine.time.AbstractZonedTimeTest)8 LocalTime (io.spine.time.LocalTime)8 Command (io.spine.base.Command)5 Event (io.spine.base.Event)4 BulkWriteOperation (io.spine.server.projection.BulkWriteOperation)4 Message (com.google.protobuf.Message)3 Interval (io.spine.time.Interval)3 Schedule (io.spine.base.CommandContext.Schedule)2 EventStreamQuery (io.spine.server.event.EventStreamQuery)2 ProjectId (io.spine.test.projection.ProjectId)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ImmutableCollection (com.google.common.collect.ImmutableCollection)1 CommandContext (io.spine.base.CommandContext)1 CommandId (io.spine.base.CommandId)1 Commands.getMessage (io.spine.base.Commands.getMessage)1 Error (io.spine.base.Error)1 CommandEnvelope (io.spine.envelope.CommandEnvelope)1