use of org.neo4j.driver.internal.InternalRecord 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) |"));
}
use of org.neo4j.driver.internal.InternalRecord in project neo4j by neo4j.
the class TableOutputFormatterTest method prettyPrintDurationWithNoTrailingZeroes.
@Test
public void prettyPrintDurationWithNoTrailingZeroes() {
// given
List<String> keys = asList("d");
Value duration = new DurationValue(new InternalIsoDuration(1, 2, 3, 0));
Record record = new InternalRecord(keys, new Value[] { duration });
// when
String actual = verbosePrinter.format(new ListBoltResult(asList(record), mock(ResultSummary.class)));
// then
assertThat(actual, containsString("| P1M2DT3S |"));
}
use of org.neo4j.driver.internal.InternalRecord in project neo4j by neo4j.
the class TableOutputFormatter method formatInfo.
@Override
@Nonnull
public String formatInfo(@Nonnull ResultSummary summary) {
Map<String, Value> info = OutputFormatter.info(summary);
if (info.isEmpty()) {
return "";
}
String[] columns = info.keySet().toArray(new String[0]);
StringBuilder sb = new StringBuilder();
Record record = new InternalRecord(asList(columns), info.values().toArray(new Value[0]));
formatResultAndCountRows(columns, Collections.singletonList(record).iterator(), line -> sb.append(line).append(OutputFormatter.NEWLINE));
return sb.toString();
}
use of org.neo4j.driver.internal.InternalRecord in project neo4j by neo4j.
the class TableOutputFormatterTest method prettyPrintRelationships.
@Test
public void prettyPrintRelationships() {
// given
List<String> keys = asList("rel");
Map<String, Value> propertiesAsMap = new HashMap<>();
propertiesAsMap.put("prop1", Values.value("prop1_value"));
propertiesAsMap.put("prop2", Values.value("prop2_value"));
RelationshipValue relationship = new RelationshipValue(new InternalRelationship(1, 1, 2, "RELATIONSHIP_TYPE", propertiesAsMap));
Record record = new InternalRecord(keys, new Value[] { relationship });
// when
String actual = verbosePrinter.format(new ListBoltResult(asList(record), mock(ResultSummary.class)));
// then
assertThat(actual, containsString("| [:RELATIONSHIP_TYPE {prop2: \"prop2_value\", prop1: \"prop1_value\"}] |"));
}
use of org.neo4j.driver.internal.InternalRecord in project neo4j by neo4j.
the class TableOutputFormatterTest method prettyPrintPoint.
@Test
public void prettyPrintPoint() {
// given
List<String> keys = asList("p1", "p2");
Value point2d = new PointValue(new InternalPoint2D(4326, 42.78, 56.7));
Value point3d = new PointValue(new InternalPoint3D(4326, 1.7, 26.79, 34.23));
Record record = new InternalRecord(keys, new Value[] { point2d, point3d });
// when
String actual = verbosePrinter.format(new ListBoltResult(asList(record), mock(ResultSummary.class)));
// then
assertThat(actual, containsString("| point({srid:4326, x:42.78, y:56.7}) |"));
assertThat(actual, containsString("| point({srid:4326, x:1.7, y:26.79, z:34.23}) |"));
}
Aggregations