use of org.neo4j.driver.Value in project neo4j by neo4j.
the class PrettyPrinterTest method checkMapForPrettyPrint.
private void checkMapForPrettyPrint(Map<String, String> map, String expectedResult) {
// given
Record record = mock(Record.class);
Value value = mock(Value.class);
when(value.type()).thenReturn(InternalTypeSystem.TYPE_SYSTEM.MAP());
when(value.asMap((Function<Value, String>) anyObject())).thenReturn(map);
when(record.keys()).thenReturn(asList("map"));
when(record.values()).thenReturn(asList(value));
BoltResult result = new ListBoltResult(asList(record), mock(ResultSummary.class));
// when
String actual = plainPrinter.format(result);
// then
assertThat(actual, is(expectedResult));
}
use of org.neo4j.driver.Value in project neo4j by neo4j.
the class PrettyPrinterTest method prettyPrintProfileInformation.
@Test
public void prettyPrintProfileInformation() {
// given
ResultSummary resultSummary = mock(ResultSummary.class);
ProfiledPlan plan = mock(ProfiledPlan.class);
when(plan.dbHits()).thenReturn(1000L);
when(plan.records()).thenReturn(20L);
when(resultSummary.hasPlan()).thenReturn(true);
when(resultSummary.hasProfile()).thenReturn(true);
when(resultSummary.plan()).thenReturn(plan);
when(resultSummary.profile()).thenReturn(plan);
when(resultSummary.resultAvailableAfter(anyObject())).thenReturn(5L);
when(resultSummary.resultConsumedAfter(anyObject())).thenReturn(7L);
when(resultSummary.queryType()).thenReturn(QueryType.READ_ONLY);
Map<String, Value> argumentMap = Values.parameters("Version", "3.1", "Planner", "COST", "Runtime", "INTERPRETED", "GlobalMemory", 10).asMap(v -> v);
when(plan.arguments()).thenReturn(argumentMap);
BoltResult result = new ListBoltResult(Collections.emptyList(), resultSummary);
// when
String actual = plainPrinter.format(result);
// then
String expected = "Plan: \"PROFILE\"\n" + "Statement: \"READ_ONLY\"\n" + "Version: \"3.1\"\n" + "Planner: \"COST\"\n" + "Runtime: \"INTERPRETED\"\n" + "Time: 12\n" + "Rows: 20\n" + "DbHits: 1000\n" + "Memory (Bytes): 10";
Stream.of(expected.split("\n")).forEach(e -> assertThat(actual, containsString(e)));
}
use of org.neo4j.driver.Value 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.Value 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}) |"));
}
use of org.neo4j.driver.Value in project neo4j by neo4j.
the class TableOutputFormatterTest method formatEntities.
@Test
public void formatEntities() {
// GIVEN
Map<String, Value> properties = singletonMap("name", Values.value("Mark"));
Map<String, Value> relProperties = singletonMap("since", Values.value(2016));
InternalNode node = new InternalNode(12, asList("Person"), properties);
InternalRelationship relationship = new InternalRelationship(24, 12, 12, "TEST", relProperties);
Result result = mockResult(asList("a", "b", "c"), node, relationship, new InternalPath(node, relationship, node));
// WHEN
String table = formatResult(result);
// THEN
assertThat(table, containsString("| (:Person {name: \"Mark\"}) | [:TEST {since: 2016}] |"));
assertThat(table, containsString("| (:Person {name: \"Mark\"})-[:TEST {since: 2016}]->(:Person {name: \"Mark\"}) |"));
}
Aggregations