Search in sources :

Example 1 with DurationValue

use of org.neo4j.values.storable.DurationValue in project neo4j by neo4j.

the class AnyValueComparatorTest method shouldTernaryCompareDurationValues.

@Test
void shouldTernaryCompareDurationValues() {
    DurationValue duration = duration(0, 0, 0, 0);
    assertTernaryCompare(duration, duration, EQUAL);
    assertTernaryCompare(duration, duration(0, 0, 0, 0), EQUAL);
    assertTernaryCompare(duration, duration(1, 0, 0, 0), UNDEFINED);
    assertTernaryCompare(duration, localTime(0, 0, 0, 1), UNDEFINED);
}
Also used : DurationValue(org.neo4j.values.storable.DurationValue) Test(org.junit.jupiter.api.Test)

Example 2 with DurationValue

use of org.neo4j.values.storable.DurationValue in project neo4j by neo4j.

the class PrettyPrinterTest method shouldHandleDuration.

@Test
void shouldHandleDuration() {
    DurationValue duration = duration(12, 45, 90, 9911);
    PrettyPrinter printer = new PrettyPrinter();
    duration.writeTo(printer);
    assertEquals("{duration: {months: 12, days: 45, seconds: 90, nanos: 9911}}", printer.value());
}
Also used : DurationValue(org.neo4j.values.storable.DurationValue) Test(org.junit.jupiter.api.Test)

Example 3 with DurationValue

use of org.neo4j.values.storable.DurationValue in project neo4j by neo4j.

the class GenericKeyStateCompareTest method compareGenericKeyState.

@Test
void compareGenericKeyState() {
    List<Value> allValues = Arrays.asList(Values.of("string1"), Values.of(42), Values.of(true), Values.of(new char[] { 'a', 'z' }), Values.of(new String[] { "arrayString1", "arraysString2" }), Values.of(new byte[] { (byte) 1, (byte) 12 }), Values.of(new short[] { 314, 1337 }), Values.of(new int[] { 3140, 13370 }), Values.of(new long[] { 31400, 133700 }), Values.of(new boolean[] { false, true }), DateValue.epochDate(2), LocalTimeValue.localTime(100000), // Noon
    TimeValue.time(43_200_000_000_000L, ZoneOffset.UTC), TimeValue.time(43_201_000_000_000L, ZoneOffset.UTC), // Noon in the next time-zone
    TimeValue.time(43_200_000_000_000L, ZoneOffset.of("+01:00")), // Same time UTC as prev time
    TimeValue.time(46_800_000_000_000L, ZoneOffset.UTC), LocalDateTimeValue.localDateTime(2018, 3, 1, 13, 50, 42, 1337), DateTimeValue.datetime(2014, 3, 25, 12, 45, 13, 7474, "UTC"), DateTimeValue.datetime(2014, 3, 25, 12, 45, 13, 7474, "Europe/Stockholm"), DateTimeValue.datetime(2014, 3, 25, 12, 45, 13, 7474, "+05:00"), DateTimeValue.datetime(2015, 3, 25, 12, 45, 13, 7474, "+05:00"), DateTimeValue.datetime(2014, 4, 25, 12, 45, 13, 7474, "+05:00"), DateTimeValue.datetime(2014, 3, 26, 12, 45, 13, 7474, "+05:00"), DateTimeValue.datetime(2014, 3, 25, 13, 45, 13, 7474, "+05:00"), DateTimeValue.datetime(2014, 3, 25, 12, 46, 13, 7474, "+05:00"), DateTimeValue.datetime(2014, 3, 25, 12, 45, 14, 7474, "+05:00"), DateTimeValue.datetime(2014, 3, 25, 12, 45, 13, 7475, "+05:00"), // DateTimeValue.datetime( 2001, 1, 25, 11, 11, 30, 0, "Canada/East-Saskatchewan" ),
    DateTimeValue.datetime(2038, 1, 18, 9, 14, 7, 0, "-18:00"), DateTimeValue.datetime(10000, 100, ZoneOffset.ofTotalSeconds(3)), DateTimeValue.datetime(10000, 101, ZoneOffset.ofTotalSeconds(-3)), DurationValue.duration(10, 20, 30, 40), DurationValue.duration(11, 20, 30, 40), DurationValue.duration(10, 21, 30, 40), DurationValue.duration(10, 20, 31, 40), DurationValue.duration(10, 20, 30, 41), Values.dateTimeArray(new ZonedDateTime[] { ZonedDateTime.of(2018, 10, 9, 8, 7, 6, 5, ZoneId.of("UTC")), ZonedDateTime.of(2017, 9, 8, 7, 6, 5, 4, ZoneId.of("UTC")) }), Values.localDateTimeArray(new LocalDateTime[] { LocalDateTime.of(2018, 10, 9, 8, 7, 6, 5), LocalDateTime.of(2018, 10, 9, 8, 7, 6, 5) }), Values.timeArray(new OffsetTime[] { OffsetTime.of(20, 8, 7, 6, ZoneOffset.UTC), OffsetTime.of(20, 8, 7, 6, ZoneOffset.UTC) }), Values.dateArray(new LocalDate[] { LocalDate.of(2018, 12, 28), LocalDate.of(2018, 12, 28) }), Values.localTimeArray(new LocalTime[] { LocalTime.of(9, 28), LocalTime.of(9, 28) }), Values.durationArray(new DurationValue[] { DurationValue.duration(12, 10, 10, 10), DurationValue.duration(12, 10, 10, 10) }));
    allValues.sort(Values.COMPARATOR);
    List<GenericKey> states = new ArrayList<>();
    for (Value value : allValues) {
        GenericKey state = new GenericKey(null);
        state.writeValue(value, NativeIndexKey.Inclusion.NEUTRAL);
        states.add(state);
    }
    Collections.shuffle(states);
    states.sort(GenericKey::compareValueTo);
    List<Value> sortedStatesAsValues = states.stream().map(GenericKey::asValue).collect(Collectors.toList());
    assertEquals(allValues, sortedStatesAsValues);
}
Also used : LocalDateTime(java.time.LocalDateTime) LocalTime(java.time.LocalTime) DurationValue(org.neo4j.values.storable.DurationValue) ZonedDateTime(java.time.ZonedDateTime) OffsetTime(java.time.OffsetTime) DurationValue(org.neo4j.values.storable.DurationValue) Value(org.neo4j.values.storable.Value) LocalDateTimeValue(org.neo4j.values.storable.LocalDateTimeValue) TimeValue(org.neo4j.values.storable.TimeValue) DateTimeValue(org.neo4j.values.storable.DateTimeValue) DateValue(org.neo4j.values.storable.DateValue) LocalTimeValue(org.neo4j.values.storable.LocalTimeValue) ArrayList(java.util.ArrayList) LocalDate(java.time.LocalDate) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 DurationValue (org.neo4j.values.storable.DurationValue)3 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 LocalTime (java.time.LocalTime)1 OffsetTime (java.time.OffsetTime)1 ZonedDateTime (java.time.ZonedDateTime)1 ArrayList (java.util.ArrayList)1 DateTimeValue (org.neo4j.values.storable.DateTimeValue)1 DateValue (org.neo4j.values.storable.DateValue)1 LocalDateTimeValue (org.neo4j.values.storable.LocalDateTimeValue)1 LocalTimeValue (org.neo4j.values.storable.LocalTimeValue)1 TimeValue (org.neo4j.values.storable.TimeValue)1 Value (org.neo4j.values.storable.Value)1