use of com.google.protobuf.Duration 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);
}
use of com.google.protobuf.Duration in project core-java by SpineEventEngine.
the class OffsetTimesShould method add_minutes.
@Test
public void add_minutes() {
final int minutesDelta = random(1, 300);
final Duration deltaDuration = Durations2.minutes(minutesDelta);
final Timestamp gmtFuture = Timestamps.add(gmtNow, deltaDuration);
final LocalTime expectedFuture = LocalTimes.timeAt(gmtFuture, zoneOffset);
final LocalTime actualFuture = addMinutes(now, minutesDelta).getTime();
assertEquals(expectedFuture, actualFuture);
}
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);
}
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);
}
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);
}
Aggregations