|
20 | 20 | import static java.util.Arrays.asList; |
21 | 21 | import static java.util.Collections.singletonMap; |
22 | 22 | import static org.hamcrest.CoreMatchers.is; |
| 23 | +import static org.hamcrest.CoreMatchers.startsWith; |
23 | 24 | import static org.hamcrest.MatcherAssert.assertThat; |
24 | 25 | import static org.hamcrest.core.StringContains.containsString; |
25 | 26 | import static org.mockito.Matchers.anyObject; |
@@ -62,6 +63,36 @@ public void prettyPrintPlanInformation() { |
62 | 63 | }); |
63 | 64 | } |
64 | 65 |
|
| 66 | + @Test |
| 67 | + public void prettyPrintPlanInformationWithNewlines() { |
| 68 | + // given |
| 69 | + ResultSummary resultSummary = mock(ResultSummary.class); |
| 70 | + ProfiledPlan plan = mock(ProfiledPlan.class); |
| 71 | + |
| 72 | + when(resultSummary.hasPlan()).thenReturn(true); |
| 73 | + when(resultSummary.hasProfile()).thenReturn(false); |
| 74 | + when(resultSummary.plan()).thenReturn(plan); |
| 75 | + when(resultSummary.resultAvailableAfter(anyObject())).thenReturn(5L); |
| 76 | + when(resultSummary.resultConsumedAfter(anyObject())).thenReturn(7L); |
| 77 | + when(resultSummary.statementType()).thenReturn(StatementType.READ_ONLY); |
| 78 | + Map<String, Value> argumentMap = Values.parameters("Version", "3.1", "Planner", "COST", "Runtime", "INTERPRETED").asMap(v -> v); |
| 79 | + when(plan.arguments()).thenReturn(argumentMap); |
| 80 | + |
| 81 | + BoltResult result = new ListBoltResult(Collections.emptyList(), resultSummary); |
| 82 | + |
| 83 | + // when |
| 84 | + String actual = verbosePrinter.format(result); |
| 85 | + |
| 86 | + // THEN |
| 87 | + assertThat(actual, startsWith(String.join(NEWLINE, |
| 88 | + "+--------------------------------------------------------------------+", |
| 89 | + "| Plan | Statement | Version | Planner | Runtime | Time |", |
| 90 | + "+--------------------------------------------------------------------+", |
| 91 | + "| \"EXPLAIN\" | \"READ_ONLY\" | \"3.1\" | \"COST\" | \"INTERPRETED\" | 12 |", |
| 92 | + "+--------------------------------------------------------------------+", |
| 93 | + NEWLINE))); |
| 94 | + } |
| 95 | + |
65 | 96 | @Test |
66 | 97 | public void prettyPrintPoint() { |
67 | 98 | // given |
|
0 commit comments