Skip to content

Commit 5d005dd

Browse files
committed
Unit tests for InternalStatementResultCursor
Also removed naming differentiation between async cursor and blocking result. It was an unnecessary complication and did not make error messages any better.
1 parent b0f546d commit 5d005dd

File tree

6 files changed

+529
-28
lines changed

6 files changed

+529
-28
lines changed

driver/src/main/java/org/neo4j/driver/internal/InternalStatementResultCursor.java

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,37 +34,17 @@
3434
import org.neo4j.driver.v1.util.Function;
3535
import org.neo4j.driver.v1.util.Functions;
3636

37-
// todo: unit tests
3837
public class InternalStatementResultCursor implements StatementResultCursor
3938
{
40-
// todo: maybe smth better than these two string constants?
41-
private static final String BLOCKING_NAME = "result";
42-
private static final String ASYNC_NAME = "cursor";
43-
44-
private final String name;
4539
private final RunResponseHandler runResponseHandler;
4640
private final PullAllResponseHandler pullAllHandler;
4741

48-
private InternalStatementResultCursor( String name, RunResponseHandler runResponseHandler,
49-
PullAllResponseHandler pullAllHandler )
42+
public InternalStatementResultCursor( RunResponseHandler runResponseHandler, PullAllResponseHandler pullAllHandler )
5043
{
51-
this.name = name;
5244
this.runResponseHandler = runResponseHandler;
5345
this.pullAllHandler = pullAllHandler;
5446
}
5547

56-
public static InternalStatementResultCursor forBlockingRun( RunResponseHandler runResponseHandler,
57-
PullAllResponseHandler pullAllHandler )
58-
{
59-
return new InternalStatementResultCursor( BLOCKING_NAME, runResponseHandler, pullAllHandler );
60-
}
61-
62-
public static InternalStatementResultCursor forAsyncRun( RunResponseHandler runResponseHandler,
63-
PullAllResponseHandler pullAllHandler )
64-
{
65-
return new InternalStatementResultCursor( ASYNC_NAME, runResponseHandler, pullAllHandler );
66-
}
67-
6848
@Override
6949
public List<String> keys()
7050
{
@@ -97,14 +77,14 @@ public CompletionStage<Record> singleAsync()
9777
if ( firstRecord == null )
9878
{
9979
throw new NoSuchRecordException(
100-
"Cannot retrieve a single record, because this " + name + " is empty." );
80+
"Cannot retrieve a single record, because this result is empty." );
10181
}
10282
return nextAsync().thenApply( secondRecord ->
10383
{
10484
if ( secondRecord != null )
10585
{
10686
throw new NoSuchRecordException(
107-
"Expected a " + name + " with a single record, but this " + name + " " +
87+
"Expected a result with a single record, but this result " +
10888
"contains at least one more. Ensure your query returns only " +
10989
"one record." );
11090
}

driver/src/main/java/org/neo4j/driver/internal/async/QueryRunner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ private static CompletionStage<InternalStatementResultCursor> run( Connection co
9797
{
9898
// wait for response of RUN before proceeding
9999
return runCompletedFuture.thenApply( ignore ->
100-
InternalStatementResultCursor.forAsyncRun( runHandler, pullAllHandler ) );
100+
new InternalStatementResultCursor( runHandler, pullAllHandler ) );
101101
}
102102
else
103103
{
104-
return completedFuture( InternalStatementResultCursor.forBlockingRun( runHandler, pullAllHandler ) );
104+
return completedFuture( new InternalStatementResultCursor( runHandler, pullAllHandler ) );
105105
}
106106
}
107107

0 commit comments

Comments
 (0)