Search in sources :

Example 16 with RelationshipValue

use of org.neo4j.values.virtual.RelationshipValue 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 17 with RelationshipValue

use of org.neo4j.values.virtual.RelationshipValue 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 18 with RelationshipValue

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

the class BoltRequestMessageV3Test method shouldSerializeRelationship.

@Test
void shouldSerializeRelationship() throws Throwable {
    RelationshipValue rel = relationshipValue(12L, nodeValue(1L, stringArray(), VirtualValues.EMPTY_MAP), nodeValue(2L, stringArray(), VirtualValues.EMPTY_MAP), stringValue("KNOWS"), map(new String[] { "name", "age" }, new AnyValue[] { stringValue("Bob"), intValue(14) }));
    assertThat(serialized(rel)).isEqualTo("B1 71 91 B5 52 0C 01 02 85 4B 4E 4F 57 53 A2 84" + lineSeparator() + "6E 61 6D 65 83 42 6F 62 83 61 67 65 0E");
}
Also used : AnyValue(org.neo4j.values.AnyValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) Test(org.junit.jupiter.api.Test)

Example 19 with RelationshipValue

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

the class CypherFunctions method asPoint.

private static Value asPoint(DbAccess access, VirtualRelationshipValue relationshipValue, RelationshipScanCursor relationshipScanCursor, PropertyCursor propertyCursor) {
    MapValueBuilder builder = new MapValueBuilder();
    for (String key : POINT_KEYS) {
        Value value = access.relationshipProperty(relationshipValue.id(), access.propertyKey(key), relationshipScanCursor, propertyCursor, true);
        if (value == NO_VALUE) {
            continue;
        }
        builder.add(key, value);
    }
    return PointValue.fromMap(builder.build());
}
Also used : MapValueBuilder(org.neo4j.values.virtual.MapValueBuilder) TemporalValue(org.neo4j.values.storable.TemporalValue) ArrayValue(org.neo4j.values.storable.ArrayValue) Values.doubleValue(org.neo4j.values.storable.Values.doubleValue) NodeValue(org.neo4j.values.virtual.NodeValue) Value(org.neo4j.values.storable.Value) Values.longValue(org.neo4j.values.storable.Values.longValue) StringValue(org.neo4j.values.storable.StringValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) TextValue(org.neo4j.values.storable.TextValue) PointValue(org.neo4j.values.storable.PointValue) SequenceValue(org.neo4j.values.SequenceValue) PathValue(org.neo4j.values.virtual.PathValue) AnyValue(org.neo4j.values.AnyValue) DoubleValue(org.neo4j.values.storable.DoubleValue) DurationValue(org.neo4j.values.storable.DurationValue) MapValue(org.neo4j.values.virtual.MapValue) NumberValue(org.neo4j.values.storable.NumberValue) LongValue(org.neo4j.values.storable.LongValue) BooleanValue(org.neo4j.values.storable.BooleanValue) ListValue(org.neo4j.values.virtual.ListValue) Values.stringValue(org.neo4j.values.storable.Values.stringValue) VirtualNodeValue(org.neo4j.values.virtual.VirtualNodeValue) IntegralValue(org.neo4j.values.storable.IntegralValue) VirtualRelationshipValue(org.neo4j.values.virtual.VirtualRelationshipValue)

Example 20 with RelationshipValue

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

the class PathValueBuilderTest method shouldHandleLongerPathWithMultiRelWhereEndNodeIsKnown.

@Test
void shouldHandleLongerPathWithMultiRelWhereEndNodeIsKnown() {
    // Given  (n1)<--(n2)-->(n3)
    NodeValue n1 = node(42);
    NodeValue n2 = node(43);
    NodeValue n3 = node(44);
    RelationshipValue r1 = relationship(1337, n2, n1);
    RelationshipValue r2 = relationship(1338, n2, n3);
    PathValueBuilder builder = builder(n1, n2, n3, r1, r2);
    // When (n1)<--(n2)--(n3)
    builder.addNode(n1);
    builder.addMultipleUndirected(list(r1, r2), n3);
    // Then
    assertEquals(path(n1, r1, n2, r2, n3), builder.build());
}
Also used : NodeValue(org.neo4j.values.virtual.NodeValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) Test(org.junit.jupiter.api.Test)

Aggregations

RelationshipValue (org.neo4j.values.virtual.RelationshipValue)24 Test (org.junit.jupiter.api.Test)15 NodeValue (org.neo4j.values.virtual.NodeValue)13 AnyValue (org.neo4j.values.AnyValue)11 CalledFromGeneratedCode (org.neo4j.util.CalledFromGeneratedCode)6 ListValue (org.neo4j.values.virtual.ListValue)3 PathValue (org.neo4j.values.virtual.PathValue)3 Relationship (org.neo4j.graphdb.Relationship)2 Values.stringValue (org.neo4j.values.storable.Values.stringValue)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