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 ;
2140import static org .neo4j .shell .prettyprint .OutputFormatter .NEWLINE ;
2241import static org .neo4j .shell .util .Versions .version ;
2342
24- public class CypherShellPlainIntegrationTest extends CypherShellIntegrationTest {
43+ public class CypherShellPlainIntegrationTest extends CypherShellIntegrationTest
44+ {
2545 @ Rule
2646 public final ExpectedException thrown = ExpectedException .none ();
2747
2848 private StringLinePrinter linePrinter = new StringLinePrinter ();
2949
3050 @ Before
31- public void setUp () throws Exception {
51+ public void setUp () throws Exception
52+ {
3253 linePrinter .clear ();
33- shell = new CypherShell (linePrinter , new PrettyConfig (Format .PLAIN , true , 1000 ), false , new ShellParameterMap ());
54+ shell = new CypherShell ( linePrinter , new PrettyConfig ( Format .PLAIN , true , 1000 ), false , new ShellParameterMap () );
3455 connect ( "neo" );
3556 }
3657
3758 @ After
38- public void tearDown () throws Exception {
39- shell .execute ("MATCH (n) DETACH DELETE (n)" );
59+ public void tearDown () throws Exception
60+ {
61+ shell .execute ( "MATCH (n) DETACH DELETE (n)" );
4062 }
4163
4264 @ Test
43- public void periodicCommitWorks () throws CommandException {
44- shell .execute ("USING PERIODIC COMMIT\n " +
45- "LOAD CSV FROM 'https://neo4j.com/docs/cypher-refcard/3.2/csv/artists.csv' AS line\n " +
46- "CREATE (:Artist {name: line[1], year: toInteger(line[2])});" );
65+ public void periodicCommitWorks () throws CommandException
66+ {
67+ shell .execute ( "USING PERIODIC COMMIT\n " +
68+ "LOAD CSV FROM 'https://neo4j.com/docs/cypher-refcard/3.2/csv/artists.csv' AS line\n " +
69+ "CREATE (:Artist {name: line[1], year: toInteger(line[2])});" );
4770 linePrinter .clear ();
4871
49- shell .execute ("MATCH (a:Artist) WHERE a.name = 'Europe' RETURN a.name" );
72+ shell .execute ( "MATCH (a:Artist) WHERE a.name = 'Europe' RETURN a.name" );
5073
51- assertThat (linePrinter .output (), containsString ("a.name" + NEWLINE + "\" Europe\" " ) );
74+ assertThat ( linePrinter .output (), containsString ( "a.name" + NEWLINE + "\" Europe\" " ) );
5275 }
5376
5477 @ Test
55- public void cypherWithProfileStatements () throws CommandException {
78+ public void cypherWithProfileStatements () throws CommandException
79+ {
5680 //when
57- shell .execute ("CYPHER RUNTIME=INTERPRETED PROFILE RETURN null" );
81+ shell .execute ( "CYPHER RUNTIME=INTERPRETED PROFILE RETURN null" );
5882
5983 //then
6084 String actual = linePrinter .output ();
6185 // This assertion checks everything except for time and cypher
62- assertThat (actual , containsString ("Plan: \" PROFILE\" " ) );
63- assertThat (actual , containsString ("Statement: \" READ_ONLY\" " ) );
64- assertThat (actual , containsString ("Planner: \" COST\" " ) );
65- assertThat (actual , containsString ("Runtime: \" INTERPRETED\" " ) );
66- assertThat (actual , containsString ("DbHits: 0" ) );
67- assertThat (actual , containsString ("Rows: 1" ) );
68- assertThat (actual , containsString ("null" ) );
69- assertThat (actual , containsString ("NULL" ) );
86+ assertThat ( actual , containsString ( "Plan: \" PROFILE\" " ) );
87+ assertThat ( actual , containsString ( "Statement: \" READ_ONLY\" " ) );
88+ assertThat ( actual , containsString ( "Planner: \" COST\" " ) );
89+ assertThat ( actual , containsString ( "Runtime: \" INTERPRETED\" " ) );
90+ assertThat ( actual , containsString ( "DbHits: 0" ) );
91+ assertThat ( actual , containsString ( "Rows: 1" ) );
92+ assertThat ( actual , containsString ( "null" ) );
93+ assertThat ( actual , containsString ( "NULL" ) );
7094 }
7195
7296 @ Test
73- public void cypherWithProfileWithMemory () throws CommandException {
97+ public void cypherWithProfileWithMemory () throws CommandException
98+ {
7499 // given
75100
76101 String serverVersion = shell .getServerVersion ();
77102 // Memory profile are only available from 4.1
78- assumeThat ( version (serverVersion ), greaterThanOrEqualTo (version ("4.1" )) );
103+ assumeThat ( version ( serverVersion ), greaterThanOrEqualTo ( version ( "4.1" ) ) );
79104
80105 //when
81- shell .execute ("CYPHER RUNTIME=INTERPRETED PROFILE RETURN null" );
106+ shell .execute ( "CYPHER RUNTIME=INTERPRETED PROFILE RETURN null" );
82107
83108 //then
84109 String actual = linePrinter .output ();
85- System .out .println (actual );
86- assertThat (actual , containsString ("Memory (Bytes): 0" ) );
110+ System .out .println ( actual );
111+ assertThat ( actual , containsString ( "Memory (Bytes): 0" ) );
87112 }
88113
89114 @ Test
90- public void cypherWithExplainStatements () throws CommandException {
115+ public void cypherWithExplainStatements () throws CommandException
116+ {
91117 //when
92- shell .execute ("CYPHER RUNTIME=INTERPRETED EXPLAIN RETURN null" );
118+ shell .execute ( "CYPHER RUNTIME=INTERPRETED EXPLAIN RETURN null" );
93119
94120 //then
95121 String actual = linePrinter .output ();
96122 // This assertion checks everything except for time and cypher
97- assertThat (actual , containsString ("Plan: \" EXPLAIN\" " ) );
98- assertThat (actual , containsString ("Statement: \" READ_ONLY\" " ) );
99- assertThat (actual , containsString ("Planner: \" COST\" " ) );
100- assertThat (actual , containsString ("Runtime: \" INTERPRETED\" " ) );
123+ assertThat ( actual , containsString ( "Plan: \" EXPLAIN\" " ) );
124+ assertThat ( actual , containsString ( "Statement: \" READ_ONLY\" " ) );
125+ assertThat ( actual , containsString ( "Planner: \" COST\" " ) );
126+ assertThat ( actual , containsString ( "Runtime: \" INTERPRETED\" " ) );
101127 }
102128
103129 @ Test
@@ -106,15 +132,15 @@ public void shouldUseParamFromCLIArgs() throws EvaluationException, CommandExcep
106132 // given a CLI arg
107133 ShellParameterMap parameterMap = new ShellParameterMap ();
108134 parameterMap .setParameter ( "foo" , "'bar'" );
109- shell = new CypherShell ( linePrinter , new PrettyConfig ( Format .PLAIN , true , 1000 ), false , parameterMap );
135+ shell = new CypherShell ( linePrinter , new PrettyConfig ( Format .PLAIN , true , 1000 ), false , parameterMap );
110136 connect ( "neo" );
111137
112138 //when
113- shell .execute ("CYPHER RETURN $foo" );
139+ shell .execute ( "CYPHER RETURN $foo" );
114140
115141 //then
116142 String actual = linePrinter .output ();
117- assertThat (actual , containsString ("$foo" ) );
118- assertThat (actual , containsString ("bar" ) );
143+ assertThat ( actual , containsString ( "$foo" ) );
144+ assertThat ( actual , containsString ( "bar" ) );
119145 }
120146}
0 commit comments