Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Commit 72fecb9

Browse files
committed
Merge remote-tracking branch 'origin/1.1' into 1.2
2 parents 2684011 + b9ecf0e commit 72fecb9

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

cypher-shell/src/main/java/org/neo4j/shell/prettyprint/TableOutputFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public String formatInfo(@Nonnull ResultSummary summary) {
158158
String[] columns = info.keySet().toArray(new String[0]);
159159
StringBuilder sb = new StringBuilder();
160160
Record record = new InternalRecord(asList(columns), info.values().toArray(new Value[0]));
161-
formatResultAndCountRows(columns, Collections.singletonList(record).iterator(), sb::append);
161+
formatResultAndCountRows(columns, Collections.singletonList(record).iterator(), line -> sb.append( line).append( OutputFormatter.NEWLINE) );
162162
return sb.toString();
163163
}
164164

cypher-shell/src/test/java/org/neo4j/shell/prettyprint/TableOutputFormatterTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import static java.util.Arrays.asList;
3636
import static java.util.Collections.singletonMap;
3737
import static org.hamcrest.CoreMatchers.is;
38+
import static org.hamcrest.CoreMatchers.startsWith;
3839
import static org.hamcrest.MatcherAssert.assertThat;
3940
import static org.hamcrest.core.StringContains.containsString;
4041
import static org.mockito.Matchers.anyObject;
@@ -77,6 +78,36 @@ public void prettyPrintPlanInformation() {
7778
});
7879
}
7980

81+
@Test
82+
public void prettyPrintPlanInformationWithNewlines() {
83+
// given
84+
ResultSummary resultSummary = mock(ResultSummary.class);
85+
ProfiledPlan plan = mock(ProfiledPlan.class);
86+
87+
when(resultSummary.hasPlan()).thenReturn(true);
88+
when(resultSummary.hasProfile()).thenReturn(false);
89+
when(resultSummary.plan()).thenReturn(plan);
90+
when(resultSummary.resultAvailableAfter(anyObject())).thenReturn(5L);
91+
when(resultSummary.resultConsumedAfter(anyObject())).thenReturn(7L);
92+
when(resultSummary.statementType()).thenReturn(StatementType.READ_ONLY);
93+
Map<String, Value> argumentMap = Values.parameters("Version", "3.1", "Planner", "COST", "Runtime", "INTERPRETED").asMap(v -> v);
94+
when(plan.arguments()).thenReturn(argumentMap);
95+
96+
BoltResult result = new ListBoltResult(Collections.emptyList(), resultSummary);
97+
98+
// when
99+
String actual = verbosePrinter.format(result);
100+
101+
// THEN
102+
assertThat(actual, startsWith(String.join(NEWLINE,
103+
"+--------------------------------------------------------------------+",
104+
"| Plan | Statement | Version | Planner | Runtime | Time |",
105+
"+--------------------------------------------------------------------+",
106+
"| \"EXPLAIN\" | \"READ_ONLY\" | \"3.1\" | \"COST\" | \"INTERPRETED\" | 12 |",
107+
"+--------------------------------------------------------------------+",
108+
NEWLINE)));
109+
}
110+
80111
@Test
81112
public void prettyPrintPoint() {
82113
// given

0 commit comments

Comments
 (0)