Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Commit 644bc23

Browse files
committed
Add some integration tests for Bolt RESET
1 parent 0c003c3 commit 644bc23

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellIntegrationTest.java

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class CypherShellIntegrationTest {
3232
private Logger logger = mock(Logger.class);
3333
private Command rollbackCommand;
3434
private Command commitCommand;
35-
private Command beginCommand ;
35+
private Command beginCommand;
3636
private CypherShell shell;
3737

3838
@Before
@@ -49,7 +49,7 @@ public void setUp() throws Exception {
4949

5050
@After
5151
public void tearDown() throws Exception {
52-
shell.execute("MATCH (n:TestPerson) DETACH DELETE (n)");
52+
shell.execute("MATCH (n) DETACH DELETE (n)");
5353
}
5454

5555
@Test
@@ -100,7 +100,43 @@ public void rollbackScenario() throws CommandException {
100100
rollbackCommand.execute("");
101101

102102
//then
103-
shell.execute("MATCH (n:TestPerson) RETURN n");
103+
shell.execute("MATCH (n) RETURN n");
104+
105+
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
106+
verify(logger, times(3)).printOut(captor.capture());
107+
108+
List<String> result = captor.getAllValues();
109+
assertThat(result.get(2), is("n\n(:TestPerson {name: \"Jane Smith\"})"));
110+
}
111+
112+
@Test
113+
public void resetOutOfTxScenario() throws CommandException {
114+
//when
115+
shell.execute("CREATE (:TestPerson {name: \"Jane Smith\"})");
116+
shell.reset();
117+
118+
//then
119+
shell.execute("CREATE (:TestPerson {name: \"Jane Smith\"})");
120+
shell.execute("MATCH (n) RETURN n");
121+
122+
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
123+
verify(logger, times(3)).printOut(captor.capture());
124+
125+
List<String> result = captor.getAllValues();
126+
assertThat(result.get(2), is("n\n(:TestPerson {name: \"Jane Smith\"})" +
127+
"\n(:TestPerson {name: \"Jane Smith\"})"));
128+
}
129+
130+
@Test
131+
public void resetInTxScenario() throws CommandException {
132+
//when
133+
beginCommand.execute("");
134+
shell.execute("CREATE (:Random)");
135+
shell.reset();
136+
137+
//then
138+
shell.execute("CREATE (:TestPerson {name: \"Jane Smith\"})");
139+
shell.execute("MATCH (n) RETURN n");
104140

105141
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
106142
verify(logger, times(3)).printOut(captor.capture());
@@ -116,7 +152,7 @@ public void commitScenario() throws CommandException {
116152
commitCommand.execute("");
117153

118154
//then
119-
shell.execute("MATCH (n:TestPerson) RETURN n");
155+
shell.execute("MATCH (n) RETURN n");
120156

121157
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
122158
verify(logger, times(2)).printOut(captor.capture());
@@ -126,7 +162,7 @@ public void commitScenario() throws CommandException {
126162
}
127163

128164
@Test
129-
public void setUnsetVariables() throws CommandException {
165+
public void setAndListVariables() throws CommandException {
130166
assertTrue(shell.getAll().isEmpty());
131167

132168
long randomLong = System.currentTimeMillis();

0 commit comments

Comments
 (0)