1+ /*
2+ * Copyright (c) 2002-2020 "Neo4j,"
3+ * Neo4j Sweden AB [http://neo4j.com]
4+ *
5+ * This file is part of Neo4j.
6+ *
7+ * Neo4j is free software: you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation, either version 3 of the License, or
10+ * (at your option) any later version.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ */
120package org.neo4j.shell.commands;
221
322import org.junit.After;
1635
1736import static org.hamcrest.CoreMatchers.containsString;
1837import static org.hamcrest.MatcherAssert.assertThat;
19- import static org.hamcrest.Matchers.greaterThanOrEqualTo;
20- import static org.junit.Assume.assumeThat;
21- import static org.junit.Assert.assertEquals;
2238import static org.neo4j.shell.prettyprint.OutputFormatter.NEWLINE;
23- import static org.neo4j.shell.util.Versions.version;
2439
25- public class CypherShellPlainIntegrationTest extends CypherShellIntegrationTest {
40+ public class CypherShellPlainIntegrationTest extends CypherShellIntegrationTest
41+ {
2642 @Rule
2743 public final ExpectedException thrown = ExpectedException.none();
2844
2945 private StringLinePrinter linePrinter = new StringLinePrinter();
3046
3147 @Before
32- public void setUp() throws Exception {
48+ public void setUp() throws Exception
49+ {
3350 linePrinter.clear();
34- shell = new CypherShell(linePrinter, new PrettyConfig(Format.PLAIN, true, 1000), false, new ShellParameterMap());
51+ shell = new CypherShell( linePrinter, new PrettyConfig( Format.PLAIN, true, 1000 ), false, new ShellParameterMap() );
3552 connect( "neo" );
3653 }
3754
3855 @After
39- public void tearDown() throws Exception {
40- shell.execute("MATCH (n) DETACH DELETE (n)");
56+ public void tearDown() throws Exception
57+ {
58+ shell.execute( "MATCH (n) DETACH DELETE (n)" );
4159 }
4260
4361 @Test
44- public void periodicCommitWorks() throws CommandException {
45- shell.execute("USING PERIODIC COMMIT\n" +
46- "LOAD CSV FROM 'https://neo4j.com/docs/cypher-refcard/3.2/csv/artists.csv' AS line\n" +
47- "CREATE (:Artist {name: line[1], year: toInteger(line[2])});");
62+ public void periodicCommitWorks() throws CommandException
63+ {
64+ shell.execute( "USING PERIODIC COMMIT\n" +
65+ "LOAD CSV FROM 'https://neo4j.com/docs/cypher-refcard/3.2/csv/artists.csv' AS line\n" +
66+ "CREATE (:Artist {name: line[1], year: toInteger(line[2])});" );
4867 linePrinter.clear();
4968
50- shell.execute("MATCH (a:Artist) WHERE a.name = 'Europe' RETURN a.name");
69+ shell.execute( "MATCH (a:Artist) WHERE a.name = 'Europe' RETURN a.name" );
5170
52- assertThat(linePrinter.output(), containsString("a.name"+ NEWLINE+ "\"Europe\"") );
71+ assertThat( linePrinter.output(), containsString( "a.name" + NEWLINE + "\"Europe\"" ) );
5372 }
5473
5574 @Test
56- public void cypherWithProfileStatements() throws CommandException {
75+ public void cypherWithProfileStatements() throws CommandException
76+ {
5777 //when
58- shell.execute("CYPHER RUNTIME=INTERPRETED PROFILE RETURN null");
78+ shell.execute( "CYPHER RUNTIME=INTERPRETED PROFILE RETURN null" );
5979
6080 //then
6181 String actual = linePrinter.output();
6282 // This assertion checks everything except for time and cypher
63- assertThat(actual, containsString("Plan: \"PROFILE\"") );
64- assertThat(actual, containsString("Statement: \"READ_ONLY\"") );
65- assertThat(actual, containsString("Planner: \"COST\"") );
66- assertThat(actual, containsString("Runtime: \"INTERPRETED\"") );
67- assertThat(actual, containsString("DbHits: 0") );
68- assertThat(actual, containsString("Rows: 1") );
69- assertThat(actual, containsString("null") );
70- assertThat(actual, containsString("NULL") );
83+ assertThat( actual, containsString( "Plan: \"PROFILE\"" ) );
84+ assertThat( actual, containsString( "Statement: \"READ_ONLY\"" ) );
85+ assertThat( actual, containsString( "Planner: \"COST\"" ) );
86+ assertThat( actual, containsString( "Runtime: \"INTERPRETED\"" ) );
87+ assertThat( actual, containsString( "DbHits: 0" ) );
88+ assertThat( actual, containsString( "Rows: 1" ) );
89+ assertThat( actual, containsString( "null" ) );
90+ assertThat( actual, containsString( "NULL" ) );
7191 }
7292
7393 @Test
74- public void cypherWithExplainStatements() throws CommandException {
94+ public void cypherWithExplainStatements() throws CommandException
95+ {
7596 //when
76- shell.execute("CYPHER RUNTIME=INTERPRETED EXPLAIN RETURN null");
97+ shell.execute( "CYPHER RUNTIME=INTERPRETED EXPLAIN RETURN null" );
7798
7899 //then
79100 String actual = linePrinter.output();
80101 // This assertion checks everything except for time and cypher
81- assertThat(actual, containsString("Plan: \"EXPLAIN\"") );
82- assertThat(actual, containsString("Statement: \"READ_ONLY\"") );
83- assertThat(actual, containsString("Planner: \"COST\"") );
84- assertThat(actual, containsString("Runtime: \"INTERPRETED\"") );
102+ assertThat( actual, containsString( "Plan: \"EXPLAIN\"" ) );
103+ assertThat( actual, containsString( "Statement: \"READ_ONLY\"" ) );
104+ assertThat( actual, containsString( "Planner: \"COST\"" ) );
105+ assertThat( actual, containsString( "Runtime: \"INTERPRETED\"" ) );
85106 }
86107
87108 @Test
@@ -90,15 +111,15 @@ public void shouldUseParamFromCLIArgs() throws EvaluationException, CommandExcep
90111 // given a CLI arg
91112 ShellParameterMap parameterMap = new ShellParameterMap();
92113 parameterMap.setParameter( "foo", "'bar'" );
93- shell = new CypherShell( linePrinter, new PrettyConfig( Format.PLAIN, true, 1000), false, parameterMap );
114+ shell = new CypherShell( linePrinter, new PrettyConfig( Format.PLAIN, true, 1000 ), false, parameterMap );
94115 connect( "neo" );
95116
96117 //when
97- shell.execute("CYPHER RETURN $foo");
118+ shell.execute( "CYPHER RETURN $foo" );
98119
99120 //then
100121 String actual = linePrinter.output();
101- assertThat(actual, containsString("$foo") );
102- assertThat(actual, containsString("bar") );
122+ assertThat( actual, containsString( "$foo" ) );
123+ assertThat( actual, containsString( "bar" ) );
103124 }
104125}
0 commit comments