Search in sources :

Example 11 with RelationshipValue

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

the class PathValueBuilderTest method shouldHandleLongerPathWithMultiRel.

@Test
void shouldHandleLongerPathWithMultiRel() {
    // 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));
    // 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)

Example 12 with RelationshipValue

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

the class PrettyPrinterTest method shouldHandlePaths.

@Test
void shouldHandlePaths() {
    // 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"), EMPTY_MAP);
    PathValue path = VirtualValues.path(new NodeValue[] { startNode, endNode }, new RelationshipValue[] { rel });
    PrettyPrinter printer = new PrettyPrinter();
    // When
    path.writeTo(printer);
    // Then
    assertThat(printer.value()).isEqualTo("(id=1 :L)-[id=42 :R]->(id=2 :L)");
}
Also used : NodeValue(org.neo4j.values.virtual.NodeValue) PathValue(org.neo4j.values.virtual.PathValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) Test(org.junit.jupiter.api.Test)

Example 13 with RelationshipValue

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

the class PrettyPrinterTest method shouldHandleRelationshipValueWithoutProperties.

@Test
void shouldHandleRelationshipValueWithoutProperties() {
    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"), EMPTY_MAP);
    PrettyPrinter printer = new PrettyPrinter();
    // When
    rel.writeTo(printer);
    // Then
    assertThat(printer.value()).isEqualTo("-[id=42 :R]-");
}
Also used : NodeValue(org.neo4j.values.virtual.NodeValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) Test(org.junit.jupiter.api.Test)

Example 14 with RelationshipValue

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

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

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