Search in sources :

Example 1 with LocalTime

use of io.spine.time.LocalTime in project core-java by SpineEventEngine.

the class TimeChangesShould method do_not_accept_null_LocalTime_newValue.

@Test(expected = NullPointerException.class)
public void do_not_accept_null_LocalTime_newValue() {
    final LocalTime now = LocalTimes.now();
    TimeChanges.of(now, null);
}
Also used : LocalTime(io.spine.time.LocalTime) Test(org.junit.Test)

Example 2 with LocalTime

use of io.spine.time.LocalTime in project core-java by SpineEventEngine.

the class OffsetTimesShould method subtract_minutes.

@Test
public void subtract_minutes() {
    final int minutesDelta = random(1, 1024);
    final Duration deltaDuration = Durations2.minutes(minutesDelta);
    final Timestamp gmtPast = Timestamps.subtract(gmtNow, deltaDuration);
    final LocalTime expectedPast = LocalTimes.timeAt(gmtPast, zoneOffset);
    final LocalTime actualPast = subtractMinutes(now, minutesDelta).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 3 with LocalTime

use of io.spine.time.LocalTime in project core-java by SpineEventEngine.

the class OffsetTimesShould method create_instance_on_local_time_at_offset.

@Test
public void create_instance_on_local_time_at_offset() {
    final LocalTime localTime = generateLocalTime();
    final OffsetTime delhiTime = OffsetTimes.of(localTime, zoneOffset);
    assertEquals(localTime, delhiTime.getTime());
    assertEquals(zoneOffset, delhiTime.getOffset());
}
Also used : LocalTime(io.spine.time.LocalTime) Test(org.junit.Test) AbstractZonedTimeTest(io.spine.time.AbstractZonedTimeTest)

Example 4 with LocalTime

use of io.spine.time.LocalTime in project core-java by SpineEventEngine.

the class OffsetTimesShould method add_hours.

/*
     * Math with time
     */
@Test
public void add_hours() {
    final int hoursDelta = random(1, 100);
    final Duration deltaDuration = Durations2.hours(hoursDelta);
    final Timestamp gmtFuture = Timestamps.add(gmtNow, deltaDuration);
    final LocalTime expectedFuture = LocalTimes.timeAt(gmtFuture, zoneOffset);
    final LocalTime actualFuture = addHours(now, hoursDelta).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 5 with LocalTime

use of io.spine.time.LocalTime in project core-java by SpineEventEngine.

the class TimeChangesShould method do_not_accept_equal_LocalTime_values.

@Test(expected = IllegalArgumentException.class)
public void do_not_accept_equal_LocalTime_values() {
    final LocalTime now = LocalTimes.now();
    TimeChanges.of(now, now);
}
Also used : LocalTime(io.spine.time.LocalTime) Test(org.junit.Test)

Aggregations

LocalTime (io.spine.time.LocalTime)19 Test (org.junit.Test)18 AbstractZonedTimeTest (io.spine.time.AbstractZonedTimeTest)10 Duration (com.google.protobuf.Duration)8 Timestamp (com.google.protobuf.Timestamp)8 LocalTimeChange (io.spine.time.change.LocalTimeChange)1 ParseException (java.text.ParseException)1 Calendar (java.util.Calendar)1