Search in sources :

Example 1 with PathValue

use of org.neo4j.driver.internal.value.PathValue in project neo4j by neo4j.

the class TableOutputFormatterTest method prettyPrintPath.

@Test
public void prettyPrintPath() {
    // given
    List<String> keys = asList("path");
    Node n1 = mock(Node.class);
    when(n1.id()).thenReturn(1L);
    List<String> labels = asList("L1");
    when(n1.labels()).thenReturn(labels);
    when(n1.asMap(anyObject())).thenReturn(Collections.emptyMap());
    Relationship r1 = mock(Relationship.class);
    when(r1.startNodeId()).thenReturn(2L);
    when(r1.type()).thenReturn("R1");
    when(r1.asMap(anyObject())).thenReturn(Collections.emptyMap());
    Node n2 = mock(Node.class);
    when(n2.id()).thenReturn(2L);
    when(n2.labels()).thenReturn(asList("L2"));
    when(n2.asMap(anyObject())).thenReturn(Collections.emptyMap());
    Relationship r2 = mock(Relationship.class);
    when(r2.startNodeId()).thenReturn(2L);
    when(r2.type()).thenReturn("R2");
    when(r2.asMap(anyObject())).thenReturn(Collections.emptyMap());
    Node n3 = mock(Node.class);
    when(n3.id()).thenReturn(3L);
    when(n3.labels()).thenReturn(asList("L3"));
    when(n3.asMap(anyObject())).thenReturn(Collections.emptyMap());
    Path.Segment s1 = mock(Path.Segment.class);
    when(s1.relationship()).thenReturn(r1);
    when(s1.start()).thenReturn(n1);
    when(s1.end()).thenReturn(n2);
    Path.Segment s2 = mock(Path.Segment.class);
    when(s2.relationship()).thenReturn(r2);
    when(s2.start()).thenReturn(n2);
    when(s2.end()).thenReturn(n3);
    List<Path.Segment> segments = asList(s1, s2);
    List<Node> nodes = asList(n1, n2);
    List<Relationship> relationships = asList(r1);
    InternalPath internalPath = new InternalPath(segments, nodes, relationships);
    Value value = new PathValue(internalPath);
    Record record = new InternalRecord(keys, new Value[] { value });
    // when
    String actual = verbosePrinter.format(new ListBoltResult(asList(record), mock(ResultSummary.class)));
    // then
    assertThat(actual, containsString("| (:L1)<-[:R1]-(:L2)-[:R2]->(:L3) |"));
}
Also used : Path(org.neo4j.driver.types.Path) InternalPath(org.neo4j.driver.internal.InternalPath) PathValue(org.neo4j.driver.internal.value.PathValue) Node(org.neo4j.driver.types.Node) InternalNode(org.neo4j.driver.internal.InternalNode) InternalPath(org.neo4j.driver.internal.InternalPath) StringContains.containsString(org.hamcrest.core.StringContains.containsString) InternalRecord(org.neo4j.driver.internal.InternalRecord) ListBoltResult(org.neo4j.shell.state.ListBoltResult) Relationship(org.neo4j.driver.types.Relationship) InternalRelationship(org.neo4j.driver.internal.InternalRelationship) Value(org.neo4j.driver.Value) RelationshipValue(org.neo4j.driver.internal.value.RelationshipValue) NodeValue(org.neo4j.driver.internal.value.NodeValue) DurationValue(org.neo4j.driver.internal.value.DurationValue) PathValue(org.neo4j.driver.internal.value.PathValue) PointValue(org.neo4j.driver.internal.value.PointValue) InternalRecord(org.neo4j.driver.internal.InternalRecord) Record(org.neo4j.driver.Record) Test(org.junit.Test)

Aggregations

StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 Test (org.junit.Test)1 Record (org.neo4j.driver.Record)1 Value (org.neo4j.driver.Value)1 InternalNode (org.neo4j.driver.internal.InternalNode)1 InternalPath (org.neo4j.driver.internal.InternalPath)1 InternalRecord (org.neo4j.driver.internal.InternalRecord)1 InternalRelationship (org.neo4j.driver.internal.InternalRelationship)1 DurationValue (org.neo4j.driver.internal.value.DurationValue)1 NodeValue (org.neo4j.driver.internal.value.NodeValue)1 PathValue (org.neo4j.driver.internal.value.PathValue)1 PointValue (org.neo4j.driver.internal.value.PointValue)1 RelationshipValue (org.neo4j.driver.internal.value.RelationshipValue)1 Node (org.neo4j.driver.types.Node)1 Path (org.neo4j.driver.types.Path)1 Relationship (org.neo4j.driver.types.Relationship)1 ListBoltResult (org.neo4j.shell.state.ListBoltResult)1