@Test public void printRelationshipsAndNodesWithEscapingForSpecialCharacters() { Record record = mock(Record.class); Value relVal = mock(Value.class); Value nodeVal = mock(Value.class); Relationship relationship = mock(Relationship.class); HashMap<String, Object> relProp = new HashMap<>(); relProp.put("prop1", "\"prop1, value\""); relProp.put("prop2", "prop2_value"); Node node = mock(Node.class); HashMap<String, Object> nodeProp = new HashMap<>(); nodeProp.put("prop1", "\"prop1:value\""); nodeProp.put("1prop2", "\"\""); nodeProp.put("ä", "not-escaped"); when(relVal.type()).thenReturn(InternalTypeSystem.TYPE_SYSTEM.RELATIONSHIP()); when(nodeVal.type()).thenReturn(InternalTypeSystem.TYPE_SYSTEM.NODE()); when(relVal.asRelationship()).thenReturn(relationship); when(relationship.type()).thenReturn("RELATIONSHIP,TYPE"); when(relationship.asMap(anyObject())).thenReturn(unmodifiableMap(relProp)); when(nodeVal.asNode()).thenReturn(node); when(node.labels()).thenReturn(asList("label `1", "label2")); when(node.asMap(anyObject())).thenReturn(unmodifiableMap(nodeProp)); when(record.keys()).thenReturn(asList("rel", "node")); when(record.values()).thenReturn(asList(relVal, nodeVal)); BoltResult result = new ListBoltResult(asList(record), mock(ResultSummary.class)); String actual = plainPrinter.format(result); assertThat(actual, is( "rel, node" + NEWLINE + "[:`RELATIONSHIP,TYPE` {prop2: prop2_value, prop1: \"prop1, value\"}], " + "(:`label ``1`:label2 {prop1: \"prop1:value\", `1prop2`: \"\", ä: not-escaped})" + NEWLINE)); }
public void format(@Nonnull final BoltResult result, LinePrinter linePrinter) { Set<OutputFormatter.Capabilities> capabilities = outputFormatter.capabilities(); int numberOfRows = 0; if (capabilities.contains(RESULT)) { numberOfRows = outputFormatter.formatAndCount(result, linePrinter); } if (capabilities.contains(INFO)) printIfNotEmpty(outputFormatter.formatInfo(result.getSummary()), linePrinter); if (capabilities.contains(PLAN)) printIfNotEmpty(outputFormatter.formatPlan(result.getSummary()), linePrinter); if (capabilities.contains(FOOTER)) printIfNotEmpty(outputFormatter.formatFooter(result, numberOfRows), linePrinter); if (capabilities.contains(STATISTICS)) printIfNotEmpty(statisticsCollector.collect(result.getSummary()), linePrinter); }
PrettyPrinter { public void format(@Nonnull final BoltResult result, LinePrinter linePrinter) { Set<OutputFormatter.Capabilities> capabilities = outputFormatter.capabilities(); int numberOfRows = 0; if (capabilities.contains(RESULT)) { numberOfRows = outputFormatter.formatAndCount(result, linePrinter); } if (capabilities.contains(INFO)) printIfNotEmpty(outputFormatter.formatInfo(result.getSummary()), linePrinter); if (capabilities.contains(PLAN)) printIfNotEmpty(outputFormatter.formatPlan(result.getSummary()), linePrinter); if (capabilities.contains(FOOTER)) printIfNotEmpty(outputFormatter.formatFooter(result, numberOfRows), linePrinter); if (capabilities.contains(STATISTICS)) printIfNotEmpty(statisticsCollector.collect(result.getSummary()), linePrinter); } }
PrettyPrinter { public void format(@Nonnull final BoltResult result, LinePrinter linePrinter) { Set<OutputFormatter.Capabilities> capabilities = outputFormatter.capabilities(); int numberOfRows = 0; if (capabilities.contains(RESULT)) { numberOfRows = outputFormatter.formatAndCount(result, linePrinter); } if (capabilities.contains(INFO)) printIfNotEmpty(outputFormatter.formatInfo(result.getSummary()), linePrinter); if (capabilities.contains(PLAN)) printIfNotEmpty(outputFormatter.formatPlan(result.getSummary()), linePrinter); if (capabilities.contains(FOOTER)) printIfNotEmpty(outputFormatter.formatFooter(result, numberOfRows), linePrinter); if (capabilities.contains(STATISTICS)) printIfNotEmpty(statisticsCollector.collect(result.getSummary()), linePrinter); } PrettyPrinter(@Nonnull PrettyConfig prettyConfig); }
PrettyPrinter { public void format(@Nonnull final BoltResult result, LinePrinter linePrinter) { Set<OutputFormatter.Capabilities> capabilities = outputFormatter.capabilities(); int numberOfRows = 0; if (capabilities.contains(RESULT)) { numberOfRows = outputFormatter.formatAndCount(result, linePrinter); } if (capabilities.contains(INFO)) printIfNotEmpty(outputFormatter.formatInfo(result.getSummary()), linePrinter); if (capabilities.contains(PLAN)) printIfNotEmpty(outputFormatter.formatPlan(result.getSummary()), linePrinter); if (capabilities.contains(FOOTER)) printIfNotEmpty(outputFormatter.formatFooter(result, numberOfRows), linePrinter); if (capabilities.contains(STATISTICS)) printIfNotEmpty(statisticsCollector.collect(result.getSummary()), linePrinter); } PrettyPrinter(@Nonnull PrettyConfig prettyConfig); void format(@Nonnull final BoltResult result, LinePrinter linePrinter); }
PrettyPrinter { public void format(@Nonnull final BoltResult result, LinePrinter linePrinter) { Set<OutputFormatter.Capabilities> capabilities = outputFormatter.capabilities(); int numberOfRows = 0; if (capabilities.contains(RESULT)) { numberOfRows = outputFormatter.formatAndCount(result, linePrinter); } if (capabilities.contains(INFO)) printIfNotEmpty(outputFormatter.formatInfo(result.getSummary()), linePrinter); if (capabilities.contains(PLAN)) printIfNotEmpty(outputFormatter.formatPlan(result.getSummary()), linePrinter); if (capabilities.contains(FOOTER)) printIfNotEmpty(outputFormatter.formatFooter(result, numberOfRows), linePrinter); if (capabilities.contains(STATISTICS)) printIfNotEmpty(statisticsCollector.collect(result.getSummary()), linePrinter); } PrettyPrinter(@Nonnull PrettyConfig prettyConfig); void format(@Nonnull final BoltResult result, LinePrinter linePrinter);  }