Search in sources :

Example 26 with Duration

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

the class Durations2Should method addDurationsTest.

private static void addDurationsTest(long seconds1, long seconds2) {
    final long secondsTotal = seconds1 + seconds2;
    final Duration sumExpected = seconds(secondsTotal);
    final Duration sumActual = add(seconds(seconds1), seconds(seconds2));
    assertEquals(sumExpected, sumActual);
}
Also used : Duration(com.google.protobuf.Duration)

Example 27 with Duration

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

the class Durations2Should method provide_stringifier.

@Test
public void provide_stringifier() {
    final Stringifier<Duration> stringifier = TimeStringifiers.forDuration();
    final Duration duration = hoursAndMinutes(10, 20);
    assertEquals(duration, stringifier.reverse().convert(stringifier.convert(duration)));
}
Also used : Duration(com.google.protobuf.Duration) Test(org.junit.Test)

Example 28 with Duration

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

the class Durations2Should method convert_hours_and_minutes_to_duration.

@Test
public void convert_hours_and_minutes_to_duration() {
    final long hours = 3;
    final long minutes = 25;
    final long secondsTotal = hoursToSeconds(hours) + minutesToSeconds(minutes);
    final Duration expected = seconds(secondsTotal);
    final Duration actual = hoursAndMinutes(hours, minutes);
    assertEquals(expected, actual);
}
Also used : Duration(com.google.protobuf.Duration) Test(org.junit.Test)

Example 29 with Duration

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

the class Durations2Should method fail_to_subtract_too_big_values.

@Test(expected = IllegalArgumentException.class)
public void fail_to_subtract_too_big_values() {
    final Duration duration1 = seconds(Long.MAX_VALUE);
    final Duration duration2 = seconds(Long.MAX_VALUE / 2);
    subtract(duration1, duration2);
}
Also used : Duration(com.google.protobuf.Duration) Test(org.junit.Test)

Example 30 with Duration

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

the class Durations2Should method add_duration_and_null.

@Test
public void add_duration_and_null() {
    final Duration duration = seconds(525);
    assertEquals(duration, add(duration, null));
    assertEquals(duration, add(null, duration));
}
Also used : Duration(com.google.protobuf.Duration) Test(org.junit.Test)

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