use of org.neo4j.driver.internal.InternalRelationship in project neo4j by neo4j.
the class TableOutputFormatterTest method printRelationshipsAndNodesWithEscapingForSpecialCharacters.
@Test
public void printRelationshipsAndNodesWithEscapingForSpecialCharacters() {
// given
Record record = mock(Record.class);
Map<String, Value> propertiesAsMap = new HashMap<>();
propertiesAsMap.put("prop1", Values.value("prop1, value"));
propertiesAsMap.put("prop2", Values.value(1));
Value relVal = new RelationshipValue(new InternalRelationship(1, 1, 2, "RELATIONSHIP,TYPE", propertiesAsMap));
List<String> labels = asList("label `1", "label2");
Map<String, Value> nodeProperties = new HashMap<>();
nodeProperties.put("prop1", Values.value("prop1:value"));
String doubleQuotes = "\"\"";
nodeProperties.put("1prop1", Values.value(doubleQuotes));
nodeProperties.put("ä", Values.value("not-escaped"));
Value nodeVal = new NodeValue(new InternalNode(1, labels, nodeProperties));
Map<String, Value> recordMap = new LinkedHashMap<>();
recordMap.put("rel", relVal);
recordMap.put("node", nodeVal);
List<String> keys = asList("rel", "node");
when(record.keys()).thenReturn(keys);
when(record.size()).thenReturn(2);
when(record.get(0)).thenReturn(relVal);
when(record.get(1)).thenReturn(nodeVal);
when(record.<Value>asMap(anyObject())).thenReturn(recordMap);
when(record.values()).thenReturn(asList(relVal, nodeVal));
// when
String actual = verbosePrinter.format(new ListBoltResult(asList(record), mock(ResultSummary.class)));
// then
assertThat(actual, containsString("| [:`RELATIONSHIP,TYPE` {prop2: 1, prop1: \"prop1, value\"}] |"));
assertThat(actual, containsString("| (:`label ``1`:label2 {`1prop1`: \"\\\"\\\"\", " + "prop1: \"prop1:value\", ä: \"not-escaped\"}) |"));
}
use of org.neo4j.driver.internal.InternalRelationship 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.InternalRelationship 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