|
35 | 35 | import static java.util.Arrays.asList; |
36 | 36 | import static java.util.Collections.singletonMap; |
37 | 37 | import static org.hamcrest.CoreMatchers.is; |
| 38 | +import static org.hamcrest.CoreMatchers.startsWith; |
38 | 39 | import static org.hamcrest.MatcherAssert.assertThat; |
39 | 40 | import static org.hamcrest.core.StringContains.containsString; |
40 | 41 | import static org.mockito.Matchers.anyObject; |
@@ -77,6 +78,36 @@ public void prettyPrintPlanInformation() { |
77 | 78 | }); |
78 | 79 | } |
79 | 80 |
|
| 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 | + |
80 | 111 | @Test |
81 | 112 | public void prettyPrintPoint() { |
82 | 113 | // given |
|
0 commit comments