@Test public void prettyPrintPaths() { Record record = mock(Record.class); Value value = mock(Value.class); Node start = mock(Node.class); HashMap<String, Object> startProperties = new HashMap<>(); startProperties.put("prop1", "prop1_value"); when(start.labels()).thenReturn(asList("start")); when(start.id()).thenReturn(1L); Node middle = mock(Node.class); when(middle.labels()).thenReturn(asList("middle")); when(middle.id()).thenReturn(2L); Node end = mock(Node.class); HashMap<String, Object> endProperties = new HashMap<>(); endProperties.put("prop2", "prop2_value"); when(end.labels()).thenReturn(asList("end")); when(end.id()).thenReturn(3L); Path path = mock(Path.class); when(path.start()).thenReturn(start); Relationship relationship = mock(Relationship.class); when(relationship.type()).thenReturn("RELATIONSHIP_TYPE"); when(relationship.startNodeId()).thenReturn(1L).thenReturn(3L); Path.Segment segment1 = mock(Path.Segment.class); when(segment1.start()).thenReturn(start); when(segment1.end()).thenReturn(middle); when(segment1.relationship()).thenReturn(relationship); Path.Segment segment2 = mock(Path.Segment.class); when(segment2.start()).thenReturn(middle); when(segment2.end()).thenReturn(end); when(segment2.relationship()).thenReturn(relationship); when(value.type()).thenReturn(InternalTypeSystem.TYPE_SYSTEM.PATH()); when(value.asPath()).thenReturn(path); when(path.iterator()).thenReturn(asList(segment1, segment2).iterator()); when(start.asMap(anyObject())).thenReturn(unmodifiableMap(startProperties)); when(end.asMap(anyObject())).thenReturn(unmodifiableMap(endProperties)); when(record.keys()).thenReturn(asList("path")); when(record.values()).thenReturn(asList(value)); BoltResult result = new ListBoltResult(asList(record), mock(ResultSummary.class)); String actual = plainPrinter.format(result); assertThat(actual, is("path" + NEWLINE + "(:start {prop1: prop1_value})-[:RELATIONSHIP_TYPE]->" + "(:middle)<-[:RELATIONSHIP_TYPE]-(:end {prop2: prop2_value})" + 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);  }