Search in sources :

Example 16 with NodeValue

use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.

the class PrettyPrinterTest method shouldHandleRelationshipValueAsReference.

@Test
void shouldHandleRelationshipValueAsReference() {
    // Given
    NodeValue startNode = VirtualValues.nodeValue(1L, Values.stringArray("L"), EMPTY_MAP);
    NodeValue endNode = VirtualValues.nodeValue(2L, Values.stringArray("L"), EMPTY_MAP);
    RelationshipValue rel = VirtualValues.relationshipValue(42L, startNode, endNode, stringValue("R"), props("foo", intValue(42), "bar", list(intValue(1337), stringValue("baz"))));
    PrettyPrinter printer = new PrettyPrinter(REFERENCE);
    // When
    rel.writeTo(printer);
    // Then
    assertThat(printer.value()).isEqualTo("-[id=42]-");
}
Also used : NodeValue(org.neo4j.values.virtual.NodeValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) Test(org.junit.jupiter.api.Test)

Example 17 with NodeValue

use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.

the class PrettyPrinterTest method shouldHandleRelationshipValue.

@Test
void shouldHandleRelationshipValue() {
    // Given
    NodeValue startNode = VirtualValues.nodeValue(1L, Values.stringArray("L"), EMPTY_MAP);
    NodeValue endNode = VirtualValues.nodeValue(2L, Values.stringArray("L"), EMPTY_MAP);
    RelationshipValue rel = VirtualValues.relationshipValue(42L, startNode, endNode, stringValue("R"), props("foo", intValue(42), "bar", list(intValue(1337), stringValue("baz"))));
    PrettyPrinter printer = new PrettyPrinter();
    // When
    rel.writeTo(printer);
    // Then
    assertThat(printer.value()).isEqualTo("-[id=42 :R {bar: [1337, \"baz\"], foo: 42}]-");
}
Also used : NodeValue(org.neo4j.values.virtual.NodeValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) Test(org.junit.jupiter.api.Test)

Example 18 with NodeValue

use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.

the class ValueMapperTest method parameters.

private static Stream<AnyValue> parameters() {
    NodeValue node1 = nodeValue(1, stringArray(), EMPTY_MAP);
    NodeValue node2 = nodeValue(2, stringArray(), EMPTY_MAP);
    NodeValue node3 = nodeValue(3, stringArray(), EMPTY_MAP);
    RelationshipValue relationship1 = relationshipValue(100, node1, node2, stringValue("ONE"), EMPTY_MAP);
    RelationshipValue relationship2 = relationshipValue(200, node2, node2, stringValue("TWO"), EMPTY_MAP);
    return Stream.of(node1, relationship1, path(new NodeValue[] { node1, node2, node3 }, new RelationshipValue[] { relationship1, relationship2 }), map(new String[] { "alpha", "beta" }, new AnyValue[] { stringValue("one"), numberValue(2) }), NO_VALUE, list(numberValue(1), stringValue("fine"), node2), stringValue("hello world"), stringArray("hello", "brave", "new", "world"), booleanValue(false), booleanArray(new boolean[] { true, false, true }), charValue('\n'), charArray(new char[] { 'h', 'e', 'l', 'l', 'o' }), byteValue((byte) 3), byteArray(new byte[] { 0x00, (byte) 0x99, (byte) 0xcc }), shortValue((short) 42), shortArray(new short[] { 1337, (short) 0xcafe, (short) 0xbabe }), intValue(987654321), intArray(new int[] { 42, 11 }), longValue(9876543210L), longArray(new long[] { 0xcafebabe, 0x1ee7 }), floatValue(Float.MAX_VALUE), floatArray(new float[] { Float.NEGATIVE_INFINITY, Float.MIN_VALUE }), doubleValue(Double.MIN_NORMAL), doubleArray(new double[] { Double.POSITIVE_INFINITY, Double.MAX_VALUE }), datetime(2018, 1, 16, 10, 36, 43, 123456788, ZoneId.of("Europe/Stockholm")), localDateTime(2018, 1, 16, 10, 36, 43, 123456788), date(2018, 1, 16), time(10, 36, 43, 123456788, ZoneOffset.ofHours(1)), localTime(10, 36, 43, 123456788), duration(399, 4, 48424, 133701337), pointValue(Cartesian, 11, 32), pointArray(new Point[] { pointValue(Cartesian, 11, 32), pointValue(WGS84, 13, 56) }));
}
Also used : NodeValue(org.neo4j.values.virtual.NodeValue) VirtualNodeValue(org.neo4j.values.virtual.VirtualNodeValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) VirtualRelationshipValue(org.neo4j.values.virtual.VirtualRelationshipValue) Point(org.neo4j.graphdb.spatial.Point)

Example 19 with NodeValue

use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.

the class AnyValueComparatorTest method shouldTernaryCompareRelationships.

@Test
void shouldTernaryCompareRelationships() {
    NodeValue start = nodeValue(42, stringArray("L"), EMPTY_MAP);
    NodeValue end = nodeValue(43, stringArray("L"), EMPTY_MAP);
    MapValue propMap = map("foo", "bar");
    RelationshipValue rel1 = relationshipValue(42, start, end, stringValue("R"), propMap);
    RelationshipValue rel2 = relationshipValue(43, start, end, stringValue("R"), propMap);
    assertTernaryCompare(rel1, rel1, EQUAL);
    assertTernaryCompare(rel1, rel2, SMALLER_THAN);
    assertTernaryCompare(rel1, relationship(rel1.id()), EQUAL);
    assertTernaryCompare(rel1, intValue(42), UNDEFINED);
    assertTernaryCompare(rel1, propMap, UNDEFINED);
}
Also used : NodeValue(org.neo4j.values.virtual.NodeValue) MapValue(org.neo4j.values.virtual.MapValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) Test(org.junit.jupiter.api.Test)

Example 20 with NodeValue

use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.

the class PrettyPrinterTest method shouldHandleRelationshipValueWithoutLabelsNorProperties.

@Test
void shouldHandleRelationshipValueWithoutLabelsNorProperties() {
    // Given
    NodeValue node = VirtualValues.nodeValue(42L, Values.stringArray(), EMPTY_MAP);
    PrettyPrinter printer = new PrettyPrinter();
    // When
    node.writeTo(printer);
    // Then
    assertThat(printer.value()).isEqualTo("(id=42)");
}
Also used : NodeValue(org.neo4j.values.virtual.NodeValue) Test(org.junit.jupiter.api.Test)

Aggregations

NodeValue (org.neo4j.values.virtual.NodeValue)26 Test (org.junit.jupiter.api.Test)22 RelationshipValue (org.neo4j.values.virtual.RelationshipValue)13 AnyValue (org.neo4j.values.AnyValue)5 PathValue (org.neo4j.values.virtual.PathValue)3 Values.stringValue (org.neo4j.values.storable.Values.stringValue)2 ListValue (org.neo4j.values.virtual.ListValue)2 MapValue (org.neo4j.values.virtual.MapValue)2 VirtualNodeValue (org.neo4j.values.virtual.VirtualNodeValue)2 VirtualRelationshipValue (org.neo4j.values.virtual.VirtualRelationshipValue)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 ArgumentMatchers.anyLong (org.mockito.ArgumentMatchers.anyLong)1 Mockito (org.mockito.Mockito)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.when (org.mockito.Mockito.when)1 Answer (org.mockito.stubbing.Answer)1