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) |"));
}
Aggregations