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

Commit daf4726

Browse files
committed
Commit does not return results.
1 parent 002a3d9 commit daf4726

File tree

4 files changed

+4
-29
lines changed

4 files changed

+4
-29
lines changed

cypher-shell/src/main/java/org/neo4j/shell/CypherShell.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.neo4j.shell;
22

3-
import java.util.List;
43
import java.util.Optional;
54
import java.util.regex.Matcher;
65
import java.util.regex.Pattern;
@@ -158,12 +157,10 @@ public void beginTransaction() throws CommandException {
158157
}
159158

160159
@Override
161-
public Optional<List<BoltResult>> commitTransaction() throws CommandException {
160+
public void commitTransaction() throws CommandException {
162161
try {
163-
Optional<List<BoltResult>> results = boltStateHandler.commitTransaction();
164-
results.ifPresent(boltResult -> boltResult.forEach(result -> prettyPrinter.format(result, linePrinter)));
162+
boltStateHandler.commitTransaction();
165163
lastNeo4jErrorCode = null;
166-
return results;
167164
} catch (Neo4jException e) {
168165
lastNeo4jErrorCode = getErrorCode(e);
169166
throw e;

cypher-shell/src/main/java/org/neo4j/shell/TransactionHandler.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
package org.neo4j.shell;
22

33
import org.neo4j.shell.exception.CommandException;
4-
import org.neo4j.shell.state.BoltResult;
5-
6-
import java.util.List;
7-
import java.util.Optional;
84

95
/**
106
* An object capable of starting, committing, and rolling back transactions.
@@ -21,7 +17,7 @@ public interface TransactionHandler {
2117
*
2218
* @throws CommandException if current transaction could not be committed
2319
*/
24-
Optional<List<BoltResult>> commitTransaction() throws CommandException;
20+
void commitTransaction() throws CommandException;
2521

2622
/**
2723
*

cypher-shell/src/main/java/org/neo4j/shell/state/BoltStateHandler.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void beginTransaction() throws CommandException {
118118
}
119119

120120
@Override
121-
public Optional<List<BoltResult>> commitTransaction() throws CommandException {
121+
public void commitTransaction() throws CommandException {
122122
if (!isConnected()) {
123123
throw new CommandException("Not connected to Neo4j");
124124
}
@@ -128,8 +128,6 @@ public Optional<List<BoltResult>> commitTransaction() throws CommandException {
128128
tx.commit();
129129
tx.close();
130130
tx = null;
131-
132-
return Optional.empty();
133131
}
134132

135133
@Override

cypher-shell/src/test/java/org/neo4j/shell/CypherShellTest.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ public void verifyDelegationOfIsTransactionOpenMethod() throws CommandException
100100
@Test
101101
public void verifyDelegationOfTransactionMethods() throws CommandException {
102102
CypherShell shell = new CypherShell(logger, mockedBoltStateHandler, mockedPrettyPrinter, new ShellParameterMap());
103-
when(mockedBoltStateHandler.commitTransaction()).thenReturn(Optional.empty());
104103

105104
shell.beginTransaction();
106105
verify(mockedBoltStateHandler).beginTransaction();
@@ -187,21 +186,6 @@ public void executeShouldPrintResult() throws CommandException {
187186
verify(logger).printOut(contains("999"));
188187
}
189188

190-
@Test
191-
public void commitShouldPrintResult() throws CommandException {
192-
BoltResult result = mock(ListBoltResult.class);
193-
194-
BoltStateHandler boltStateHandler = mock(BoltStateHandler.class);
195-
196-
doAnswer((a) -> { ((LinePrinter)a.getArguments()[1]).printOut("999"); return null;}).when(mockedPrettyPrinter).format(any(BoltResult.class), anyObject());
197-
when(boltStateHandler.commitTransaction()).thenReturn(Optional.of(asList(result)));
198-
199-
OfflineTestShell shell = new OfflineTestShell(logger, boltStateHandler, mockedPrettyPrinter);
200-
201-
shell.commitTransaction();
202-
verify(logger).printOut(contains("999"));
203-
}
204-
205189
@Test
206190
public void shouldStripEndingSemicolonsFromCommand() throws Exception {
207191
// Should not throw

0 commit comments

Comments
 (0)