Search in sources :

Example 6 with NodeValue

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

the class PathValueBuilderTest method shouldHandleNoValueInMultiRel.

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

Example 7 with NodeValue

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

the class PathValueBuilderTest method shouldHandleLongerPath.

@Test
void shouldHandleLongerPath() {
    // 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.addIncoming(r1);
    builder.addUndirected(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 8 with NodeValue

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

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

the class PrettyPrinterTest method shouldHandleNodeValueWithoutLabelsNorProperties.

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

Example 10 with NodeValue

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

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