|
32 | 32 | import static org.mockito.Mockito.mock; |
33 | 33 | import static org.mockito.Mockito.when; |
34 | 34 | import static org.neo4j.driver.internal.util.Iterables.map; |
| 35 | +import static org.neo4j.shell.prettyprint.OutputFormatter.NEWLINE; |
35 | 36 |
|
36 | 37 | @SuppressWarnings("ArraysAsListWithZeroOrOneArgument") |
37 | 38 | public class PrettyPrinterTest { |
@@ -144,13 +145,17 @@ public void prettyPrintList() { |
144 | 145 | String actual = plainPrinter.format(result); |
145 | 146 |
|
146 | 147 | // then |
147 | | - assertThat(actual, is("col1, col2\n[\"val1_1\", \"val1_2\"], [\"val2_1\"]\n[\"val2_1\"]\n")); |
| 148 | + assertThat(actual, is(String.join(NEWLINE, |
| 149 | + "col1, col2", |
| 150 | + "[\"val1_1\", \"val1_2\"], [\"val2_1\"]", |
| 151 | + "[\"val2_1\"]", |
| 152 | + ""))); |
148 | 153 | } |
149 | 154 |
|
150 | 155 | @Test |
151 | 156 | public void prettyPrintMaps() { |
152 | | - checkMapForPrettyPrint(map(), "map\n{}\n"); |
153 | | - checkMapForPrettyPrint(map("abc", "def"), "map\n{abc: def}\n"); |
| 157 | + checkMapForPrettyPrint(map(), "map"+NEWLINE+"{}"+NEWLINE); |
| 158 | + checkMapForPrettyPrint(map("abc", "def"), "map"+NEWLINE+"{abc: def}"+NEWLINE); |
154 | 159 | } |
155 | 160 |
|
156 | 161 | private void checkMapForPrettyPrint(Map<String, String> map, String expectedResult) { |
@@ -200,8 +205,8 @@ public void prettyPrintNode() { |
200 | 205 | String actual = plainPrinter.format(result); |
201 | 206 |
|
202 | 207 | // then |
203 | | - assertThat(actual, is("col1, col2\n" + |
204 | | - "(:label1:label2 {prop2: prop2_value, prop1: prop1_value})\n")); |
| 208 | + assertThat(actual, is("col1, col2" + NEWLINE + |
| 209 | + "(:label1:label2 {prop2: prop2_value, prop1: prop1_value})" + NEWLINE)); |
205 | 210 | } |
206 | 211 |
|
207 | 212 | @Test |
@@ -230,7 +235,8 @@ public void prettyPrintRelationships() { |
230 | 235 | String actual = plainPrinter.format(result); |
231 | 236 |
|
232 | 237 | // then |
233 | | - assertThat(actual, is("rel\n[:RELATIONSHIP_TYPE {prop2: prop2_value, prop1: prop1_value}]\n")); |
| 238 | + assertThat(actual, is("rel" + NEWLINE+ |
| 239 | + "[:RELATIONSHIP_TYPE {prop2: prop2_value, prop1: prop1_value}]" + NEWLINE)); |
234 | 240 | } |
235 | 241 |
|
236 | 242 | @Test |
@@ -272,8 +278,10 @@ public void printRelationshipsAndNodesWithEscapingForSpecialCharacters() { |
272 | 278 | String actual = plainPrinter.format(result); |
273 | 279 |
|
274 | 280 | // then |
275 | | - assertThat(actual, is("rel, node\n[:`RELATIONSHIP,TYPE` {prop2: prop2_value, prop1: \"prop1, value\"}], " + |
276 | | - "(:`label ``1`:label2 {prop1: \"prop1:value\", `1prop2`: \"\", ä: not-escaped})\n")); |
| 281 | + assertThat(actual, is( |
| 282 | + "rel, node" + NEWLINE + |
| 283 | + "[:`RELATIONSHIP,TYPE` {prop2: prop2_value, prop1: \"prop1, value\"}], " + |
| 284 | + "(:`label ``1`:label2 {prop1: \"prop1:value\", `1prop2`: \"\", ä: not-escaped})" + NEWLINE)); |
277 | 285 | } |
278 | 286 |
|
279 | 287 | @Test |
@@ -331,9 +339,9 @@ public void prettyPrintPaths() { |
331 | 339 | String actual = plainPrinter.format(result); |
332 | 340 |
|
333 | 341 | // then |
334 | | - assertThat(actual, is("path\n" + |
| 342 | + assertThat(actual, is("path" + NEWLINE + |
335 | 343 | "(:start {prop1: prop1_value})-[:RELATIONSHIP_TYPE]->" + |
336 | | - "(:middle)<-[:RELATIONSHIP_TYPE]-(:end {prop2: prop2_value})\n")); |
| 344 | + "(:middle)<-[:RELATIONSHIP_TYPE]-(:end {prop2: prop2_value})" + NEWLINE)); |
337 | 345 | } |
338 | 346 |
|
339 | 347 | @Test |
@@ -375,7 +383,7 @@ public void prettyPrintSingleNodePath() { |
375 | 383 | String actual = plainPrinter.format(result); |
376 | 384 |
|
377 | 385 | // then |
378 | | - assertThat(actual, is("path\n(:start)-[:RELATIONSHIP_TYPE]->(:end)\n")); |
| 386 | + assertThat(actual, is("path" + NEWLINE + "(:start)-[:RELATIONSHIP_TYPE]->(:end)" + NEWLINE)); |
379 | 387 | } |
380 | 388 |
|
381 | 389 | @Test |
@@ -435,8 +443,8 @@ public void prettyPrintThreeSegmentPath() { |
435 | 443 | String actual = plainPrinter.format(result); |
436 | 444 |
|
437 | 445 | // then |
438 | | - assertThat(actual, is("path\n" + |
| 446 | + assertThat(actual, is("path" + NEWLINE + |
439 | 447 | "(:start)-[:RELATIONSHIP_TYPE]->" + |
440 | | - "(:second)<-[:RELATIONSHIP_TYPE]-(:third)-[:RELATIONSHIP_TYPE]->(:end)\n")); |
| 448 | + "(:second)<-[:RELATIONSHIP_TYPE]-(:third)-[:RELATIONSHIP_TYPE]->(:end)" + NEWLINE)); |
441 | 449 | } |
442 | 450 | } |
0 commit comments