Search in sources :

Example 21 with ZoneOffset

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

the class ZoneOffsetsShould method convert_to_string.

@Test
public void convert_to_string() throws ParseException {
    final ZoneOffset positive = ZoneOffsets.ofHoursMinutes(5, 48);
    final ZoneOffset negative = ZoneOffsets.ofHoursMinutes(-3, -36);
    Assert.assertEquals(positive, ZoneOffsets.parse(ZoneOffsets.toString(positive)));
    Assert.assertEquals(negative, ZoneOffsets.parse(ZoneOffsets.toString(negative)));
}
Also used : ZoneOffset(io.spine.time.ZoneOffset) Test(org.junit.Test)

Example 22 with ZoneOffset

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

the class TimeChangesShould method create_OffsetDateTimeChange_instance.

@Test
public void create_OffsetDateTimeChange_instance() {
    final ZoneOffset inKiev = ZoneOffsets.ofHours(3);
    final ZoneOffset inLuxembourg = ZoneOffsets.ofHours(1);
    final OffsetDateTime previousDateTime = OffsetDateTimes.now(inKiev);
    final OffsetDateTime newDateTime = OffsetDateTimes.now(inLuxembourg);
    final OffsetDateTimeChange result = TimeChanges.of(previousDateTime, newDateTime);
    assertEquals(previousDateTime, result.getPreviousValue());
    assertEquals(newDateTime, result.getNewValue());
}
Also used : OffsetDateTime(io.spine.time.OffsetDateTime) ZoneOffset(io.spine.time.ZoneOffset) Test(org.junit.Test)

Example 23 with ZoneOffset

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

the class TimeChangesShould method do_not_accept_equal_OffsetTime_values.

@Test(expected = IllegalArgumentException.class)
public void do_not_accept_equal_OffsetTime_values() {
    final ZoneOffset inLuxembourg = ZoneOffsets.ofHours(1);
    final OffsetTime now = OffsetTimes.now(inLuxembourg);
    TimeChanges.of(now, now);
}
Also used : OffsetTime(io.spine.time.OffsetTime) ZoneOffset(io.spine.time.ZoneOffset) Test(org.junit.Test)

Example 24 with ZoneOffset

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

the class TimeChangesShould method do_not_accept_equal_OffsetDateTime_values.

@Test(expected = IllegalArgumentException.class)
public void do_not_accept_equal_OffsetDateTime_values() {
    final ZoneOffset inLuxembourg = ZoneOffsets.ofHours(1);
    final OffsetDateTime now = OffsetDateTimes.now(inLuxembourg);
    TimeChanges.of(now, now);
}
Also used : OffsetDateTime(io.spine.time.OffsetDateTime) ZoneOffset(io.spine.time.ZoneOffset) Test(org.junit.Test)

Example 25 with ZoneOffset

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

the class TimeChangesShould method do_not_accept_null_OffsetDateTime_newValue.

@Test(expected = NullPointerException.class)
public void do_not_accept_null_OffsetDateTime_newValue() {
    final ZoneOffset inKiev = ZoneOffsets.ofHours(3);
    final OffsetDateTime now = OffsetDateTimes.now(inKiev);
    TimeChanges.of(now, null);
}
Also used : OffsetDateTime(io.spine.time.OffsetDateTime) ZoneOffset(io.spine.time.ZoneOffset) Test(org.junit.Test)

Aggregations

ZoneOffset (io.spine.time.ZoneOffset)30 Test (org.junit.Test)29 OffsetDate (io.spine.time.OffsetDate)8 OffsetDateTime (io.spine.time.OffsetDateTime)8 OffsetTime (io.spine.time.OffsetTime)8 Timestamp (com.google.protobuf.Timestamp)1 ActorContext (io.spine.core.ActorContext)1 CommandContext (io.spine.core.CommandContext)1 TenantId (io.spine.core.TenantId)1 UserId (io.spine.core.UserId)1 GivenTenantId (io.spine.core.given.GivenTenantId)1 GivenUserId (io.spine.core.given.GivenUserId)1 ParseException (java.text.ParseException)1 TimeZone (java.util.TimeZone)1