use of io.spine.time.Interval in project core-java by SpineEventEngine.
the class IntervalsShould method return_duration_zero.
@Test
public void return_duration_zero() {
final Timestamp start = newTimestamp(5, 6);
final Interval interval = Interval.newBuilder().setStart(start).setEnd(start).build();
assertEquals(0L, Intervals.toDuration(interval).getSeconds());
}
use of io.spine.time.Interval 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 io.spine.time.Interval 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));
}
use of io.spine.time.Interval 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);
}
use of io.spine.time.Interval in project core-java by SpineEventEngine.
the class TimeChangesShould method do_not_accept_equal_Interval_values.
@Test(expected = IllegalArgumentException.class)
public void do_not_accept_equal_Interval_values() {
final Timestamp fourMinutesAgo = TimeTests.Past.minutesAgo(4);
final Timestamp now = getCurrentTime();
final Interval fourMinutes = Intervals.between(now, fourMinutesAgo);
TimeChanges.of(fourMinutes, fourMinutes);
}
Aggregations