use of org.neo4j.driver.internal.value.RelationshipValue 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.value.RelationshipValue 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\"}] |"));
}
Aggregations