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);
}
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)));
}
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);
}
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);
}
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));
}
Aggregations