Skip to content

Renamed RxResult to RxStatementResult #590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.util.Map;

import org.neo4j.driver.reactive.RxResult;
import org.neo4j.driver.reactive.RxStatementResult;
import org.neo4j.driver.reactive.RxStatementRunner;
import org.neo4j.driver.Record;
import org.neo4j.driver.Statement;
Expand All @@ -31,25 +31,25 @@
public abstract class AbstractRxStatementRunner implements RxStatementRunner
{
@Override
public final RxResult run( String statementTemplate, Value parameters )
public final RxStatementResult run( String statementTemplate, Value parameters )
{
return run( new Statement( statementTemplate, parameters ) );
}

@Override
public final RxResult run( String statementTemplate, Map<String,Object> statementParameters )
public final RxStatementResult run( String statementTemplate, Map<String,Object> statementParameters )
{
return run( statementTemplate, parameters( statementParameters ) );
}

@Override
public final RxResult run( String statementTemplate, Record statementParameters )
public final RxStatementResult run( String statementTemplate, Record statementParameters )
{
return run( statementTemplate, parameters( statementParameters ) );
}

@Override
public final RxResult run( String statementTemplate )
public final RxStatementResult run( String statementTemplate )
{
return run( new Statement( statementTemplate ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.neo4j.driver.internal.async.NetworkSession;
import org.neo4j.driver.internal.cursor.RxStatementResultCursor;
import org.neo4j.driver.internal.util.Futures;
import org.neo4j.driver.reactive.RxResult;
import org.neo4j.driver.reactive.RxStatementResult;
import org.neo4j.driver.reactive.RxSession;
import org.neo4j.driver.reactive.RxTransaction;
import org.neo4j.driver.reactive.RxTransactionWork;
Expand Down Expand Up @@ -126,27 +126,27 @@ private <T> Publisher<T> runTransaction( AccessMode mode, RxTransactionWork<Publ
}

@Override
public RxResult run( String statement, TransactionConfig config )
public RxStatementResult run( String statement, TransactionConfig config )
{
return run( new Statement( statement ), config );
}

@Override
public RxResult run( String statement, Map<String,Object> parameters, TransactionConfig config )
public RxStatementResult run( String statement, Map<String,Object> parameters, TransactionConfig config )
{
return run( new Statement( statement, parameters ), config );
}

@Override
public RxResult run( Statement statement )
public RxStatementResult run( Statement statement )
{
return run( statement, TransactionConfig.empty() );
}

@Override
public RxResult run( Statement statement, TransactionConfig config )
public RxStatementResult run( Statement statement, TransactionConfig config )
{
return new InternalRxResult( () -> {
return new InternalRxStatementResult( () -> {
CompletableFuture<RxStatementResultCursor> resultCursorFuture = new CompletableFuture<>();
session.runRx( statement, config ).whenComplete( ( cursor, completionError ) -> {
if ( cursor != null )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@

import org.neo4j.driver.Record;
import org.neo4j.driver.internal.util.Futures;
import org.neo4j.driver.reactive.RxResult;
import org.neo4j.driver.reactive.RxStatementResult;
import org.neo4j.driver.internal.cursor.RxStatementResultCursor;
import org.neo4j.driver.summary.ResultSummary;

public class InternalRxResult implements RxResult
public class InternalRxStatementResult implements RxStatementResult
{
private Supplier<CompletionStage<RxStatementResultCursor>> cursorFutureSupplier;
private volatile CompletionStage<RxStatementResultCursor> cursorFuture;

public InternalRxResult( Supplier<CompletionStage<RxStatementResultCursor>> cursorFuture )
public InternalRxStatementResult( Supplier<CompletionStage<RxStatementResultCursor>> cursorFuture )
{
this.cursorFutureSupplier = cursorFuture;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.neo4j.driver.internal.async.ExplicitTransaction;
import org.neo4j.driver.internal.cursor.RxStatementResultCursor;
import org.neo4j.driver.internal.util.Futures;
import org.neo4j.driver.reactive.RxResult;
import org.neo4j.driver.reactive.RxStatementResult;
import org.neo4j.driver.reactive.RxTransaction;

import static org.neo4j.driver.internal.reactive.RxUtils.createEmptyPublisher;
Expand All @@ -41,9 +41,9 @@ public InternalRxTransaction( ExplicitTransaction tx )
}

@Override
public RxResult run( Statement statement )
public RxStatementResult run( Statement statement )
{
return new InternalRxResult( () -> {
return new InternalRxStatementResult( () -> {
CompletableFuture<RxStatementResultCursor> cursorFuture = new CompletableFuture<>();
tx.runRx( statement ).whenComplete( ( cursor, completionError ) -> {
if ( cursor != null )
Expand Down
8 changes: 4 additions & 4 deletions driver/src/main/java/org/neo4j/driver/reactive/RxSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* A reactive session is the same as {@link Session} except it provides a reactive API.
* @see Session
* @see RxResult
* @see RxStatementResult
* @see RxTransaction
* @see Publisher
* @since 2.0
Expand Down Expand Up @@ -158,7 +158,7 @@ public interface RxSession extends RxStatementRunner
* @param config configuration for the new transaction.
* @return a reactive result.
*/
RxResult run( String statement, TransactionConfig config );
RxStatementResult run( String statement, TransactionConfig config );

/**
* Run a statement with parameters in an auto-commit transaction with specified {@link TransactionConfig} and return a reactive result stream.
Expand Down Expand Up @@ -196,7 +196,7 @@ public interface RxSession extends RxStatementRunner
* @param config configuration for the new transaction.
* @return a reactive result.
*/
RxResult run( String statement, Map<String,Object> parameters, TransactionConfig config );
RxStatementResult run( String statement, Map<String,Object> parameters, TransactionConfig config );

/**
* Run a statement in an auto-commit transaction with specified {@link TransactionConfig configuration} and return a reactive result stream.
Expand All @@ -222,7 +222,7 @@ public interface RxSession extends RxStatementRunner
* @param config configuration for the new transaction.
* @return a reactive result.
*/
RxResult run( Statement statement, TransactionConfig config );
RxStatementResult run( Statement statement, TransactionConfig config );

/**
* Return the bookmark received following the last completed statement within this session.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @see Subscription
* @since 2.0
*/
public interface RxResult
public interface RxStatementResult
{
/**
* Returns a cold publisher of keys.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public interface RxStatementRunner
* @param parameters input parameters, should be a map Value, see {@link Values#parameters(Object...)}.
* @return a reactive result.
*/
RxResult run( String statementTemplate, Value parameters );
RxStatementResult run( String statementTemplate, Value parameters );

/**
* Register running of a statement and return a reactive result stream.
Expand All @@ -74,7 +74,7 @@ public interface RxStatementRunner
* @param statementParameters input data for the statement
* @return a reactive result.
*/
RxResult run( String statementTemplate, Map<String,Object> statementParameters );
RxStatementResult run( String statementTemplate, Map<String,Object> statementParameters );

/**
* Register running of a statement and return a reactive result stream.
Expand All @@ -93,7 +93,7 @@ public interface RxStatementRunner
* @param statementParameters input data for the statement
* @return a reactive result.
*/
RxResult run( String statementTemplate, Record statementParameters );
RxStatementResult run( String statementTemplate, Record statementParameters );

/**
* Register running of a statement and return a reactive result stream.
Expand All @@ -103,7 +103,7 @@ public interface RxStatementRunner
* @param statementTemplate text of a Neo4j statement
* @return a reactive result.
*/
RxResult run( String statementTemplate );
RxStatementResult run( String statementTemplate );

/**
* Register running of a statement and return a reactive result stream.
Expand All @@ -113,5 +113,5 @@ public interface RxStatementRunner
* @param statement a Neo4j statement
* @return a reactive result.
*/
RxResult run( Statement statement );
RxStatementResult run( Statement statement );
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import org.neo4j.driver.internal.spi.ConnectionPool;
import org.neo4j.driver.internal.util.Clock;
import org.neo4j.driver.internal.util.EnabledOnNeo4jWith;
import org.neo4j.driver.reactive.RxResult;
import org.neo4j.driver.reactive.RxStatementResult;
import org.neo4j.driver.reactive.RxSession;
import org.neo4j.driver.reactive.RxTransaction;
import org.neo4j.driver.AuthToken;
Expand Down Expand Up @@ -313,7 +313,7 @@ void connectionUsedForBeginTxReturnedToThePoolWhenSessionClose()
void sessionCloseShouldReleaseConnectionUsedBySessionRun() throws Throwable
{
RxSession session = driver.rxSession();
RxResult res = session.run( "UNWIND [1,2,3,4] AS a RETURN a" );
RxStatementResult res = session.run( "UNWIND [1,2,3,4] AS a RETURN a" );

// When we only run but not pull
StepVerifier.create( Flux.from( res.keys() ) ).expectNext( "a" ).verifyComplete();
Expand All @@ -332,7 +332,7 @@ void sessionCloseShouldReleaseConnectionUsedBySessionRun() throws Throwable
void resultRecordsShouldReleaseConnectionUsedBySessionRun() throws Throwable
{
RxSession session = driver.rxSession();
RxResult res = session.run( "UNWIND [1,2,3,4] AS a RETURN a" );
RxStatementResult res = session.run( "UNWIND [1,2,3,4] AS a RETURN a" );
Connection connection1 = connectionPool.lastAcquiredConnectionSpy;
assertNull( connection1 );

Expand All @@ -350,7 +350,7 @@ void resultRecordsShouldReleaseConnectionUsedBySessionRun() throws Throwable
void resultSummaryShouldReleaseConnectionUsedBySessionRun() throws Throwable
{
RxSession session = driver.rxSession();
RxResult res = session.run( "UNWIND [1,2,3,4] AS a RETURN a" );
RxStatementResult res = session.run( "UNWIND [1,2,3,4] AS a RETURN a" );
Connection connection1 = connectionPool.lastAcquiredConnectionSpy;
assertNull( connection1 );

Expand All @@ -371,7 +371,7 @@ void txCommitShouldReleaseConnectionUsedByBeginTx() throws Throwable
Connection connection1 = connectionPool.lastAcquiredConnectionSpy;
verify( connection1, never() ).release();

RxResult result = tx.run( "UNWIND [1,2,3,4] AS a RETURN a" );
RxStatementResult result = tx.run( "UNWIND [1,2,3,4] AS a RETURN a" );
StepVerifier.create( Flux.from( result.records() ).map( record -> record.get( "a" ).asInt() ) )
.expectNext( 1, 2, 3, 4 ).verifyComplete();

Expand All @@ -393,7 +393,7 @@ void txRollbackShouldReleaseConnectionUsedByBeginTx() throws Throwable
Connection connection1 = connectionPool.lastAcquiredConnectionSpy;
verify( connection1, never() ).release();

RxResult result = tx.run( "UNWIND [1,2,3,4] AS a RETURN a" );
RxStatementResult result = tx.run( "UNWIND [1,2,3,4] AS a RETURN a" );
StepVerifier.create( Flux.from( result.records() ).map( record -> record.get( "a" ).asInt() ) )
.expectNext( 1, 2, 3, 4 ).verifyComplete();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import org.neo4j.driver.internal.util.DriverFactoryWithFixedRetryLogic;
import org.neo4j.driver.internal.util.DriverFactoryWithOneEventLoopThread;
import org.neo4j.driver.internal.util.EnabledOnNeo4jWith;
import org.neo4j.driver.reactive.RxResult;
import org.neo4j.driver.reactive.RxStatementResult;
import org.neo4j.driver.reactive.RxSession;
import org.neo4j.driver.summary.ResultSummary;
import org.neo4j.driver.summary.StatementType;
Expand Down Expand Up @@ -1208,7 +1208,7 @@ void shouldErrorWhenTryingToUseRxAPIWithoutBoltV4() throws Throwable
{
// Given
RxSession session = neo4j.driver().rxSession();
RxResult result = session.run( "RETURN 1" );
RxStatementResult result = session.run( "RETURN 1" );

// When trying to run the query on a server that is using a protocol that is lower than V4
StepVerifier.create( result.records() ).expectErrorSatisfies( error -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import org.neo4j.driver.exceptions.SessionExpiredException;
import org.neo4j.driver.exceptions.TransientException;
import org.neo4j.driver.internal.util.EnabledOnNeo4jWith;
import org.neo4j.driver.reactive.RxResult;
import org.neo4j.driver.reactive.RxStatementResult;
import org.neo4j.driver.reactive.RxSession;
import org.neo4j.driver.reactive.RxTransaction;
import org.neo4j.driver.reactive.RxTransactionWork;
Expand All @@ -65,7 +65,7 @@ void shouldAllowSessionRun()
{
// When
RxSession session = neo4j.driver().rxSession();
RxResult res = session.run( "UNWIND [1,2,3,4] AS a RETURN a" );
RxStatementResult res = session.run( "UNWIND [1,2,3,4] AS a RETURN a" );

// Then I should be able to iterate over the result
StepVerifier.create( Flux.from( res.records() ).map( r -> r.get( "a" ).asInt() ) )
Expand All @@ -82,12 +82,12 @@ void shouldBeAbleToReuseSessionAfterFailure()
{
// Given
RxSession session = neo4j.driver().rxSession();
RxResult res1 = session.run( "INVALID" );
RxStatementResult res1 = session.run( "INVALID" );

StepVerifier.create( res1.records() ).expectError( ClientException.class ).verify();

// When
RxResult res2 = session.run( "RETURN 1" );
RxStatementResult res2 = session.run( "RETURN 1" );

// Then
StepVerifier.create( res2.records() ).assertNext( record -> {
Expand Down
Loading