Skip to content
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

Update mockito-core to 4.3.1 #1160

Merged
merged 2 commits into from
Feb 23, 2022
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 @@ -26,6 +26,9 @@
import java.util.List;
import java.util.Map;

import org.neo4j.driver.Record;
import org.neo4j.driver.Value;
import org.neo4j.driver.Values;
import org.neo4j.driver.internal.value.BooleanValue;
import org.neo4j.driver.internal.value.FloatValue;
import org.neo4j.driver.internal.value.IntegerValue;
Expand All @@ -36,9 +39,6 @@
import org.neo4j.driver.internal.value.PathValue;
import org.neo4j.driver.internal.value.RelationshipValue;
import org.neo4j.driver.internal.value.StringValue;
import org.neo4j.driver.Record;
import org.neo4j.driver.Value;
import org.neo4j.driver.Values;
import org.neo4j.driver.types.Entity;
import org.neo4j.driver.types.Node;
import org.neo4j.driver.types.Path;
Expand Down Expand Up @@ -115,8 +115,8 @@ void shouldGetObjectFromRecord()
Record record = createRecord();

// IntegerValue.asObject returns Long
assertThat( record.get( "IntegerValue", (Object) 3 ), equalTo( (Object) new Long( 11 ) ) );
assertThat( record.get( wrongKey, (Object) 3 ), equalTo( (Object) new Integer( 3 ) ) );
assertThat( record.get( "IntegerValue", (Object) 3 ), equalTo( 11L ) );
assertThat( record.get( wrongKey, (Object) 3 ), equalTo( 3 ) );
}

@Test
Expand All @@ -125,8 +125,8 @@ void shouldGetNumberFromRecord()
Record record = createRecord();

// IntegerValue.asNumber returns Long
assertThat( record.get( "IntegerValue", (Number) 3 ), equalTo( (Object) new Long( 11 ) ) );
assertThat( record.get( wrongKey, (Number) 3 ), equalTo( (Object) new Integer( 3 ) ) );
assertThat( record.get( "IntegerValue", (Number) 3 ), equalTo( (Object) 11L ) );
assertThat( record.get( wrongKey, (Number) 3 ), equalTo( (Object) 3 ) );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import static org.neo4j.driver.internal.BoltServerAddress.LOCAL_DEFAULT;
import static org.neo4j.driver.internal.async.connection.ChannelAttributes.authorizationStateListener;
Expand All @@ -57,7 +57,7 @@ void shouldDoNothingWhenRetainOnEmptyPool()

pool.retainAll( singleton( LOCAL_DEFAULT ) );

verifyZeroInteractions( nettyChannelTracker );
verifyNoInteractions( nettyChannelTracker );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.mockito.MockitoAnnotations.openMocks;
import static org.neo4j.driver.internal.logging.DevNullLogging.DEV_NULL_LOGGING;
import static org.neo4j.driver.internal.util.ClusterCompositionUtil.A;

Expand All @@ -51,7 +51,7 @@ class LeastConnectedLoadBalancingStrategyTest
@BeforeEach
void setUp()
{
initMocks( this );
openMocks( this );
strategy = new LeastConnectedLoadBalancingStrategy( connectionPool, DEV_NULL_LOGGING );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,11 @@ void expectsCompetedDatabaseNameAfterRoutingTableRegistry( boolean completed ) t
new LoadBalancer( connectionPool, routingTables, rediscovery, new LeastConnectedLoadBalancingStrategy( connectionPool, DEV_NULL_LOGGING ),
GlobalEventExecutor.INSTANCE, DEV_NULL_LOGGING );
ConnectionContext context = mock( ConnectionContext.class );
CompletableFuture<DatabaseName> databaseNameFuture =
spy( completed ? CompletableFuture.completedFuture( DatabaseNameUtil.systemDatabase() ) : new CompletableFuture<>() );
CompletableFuture<DatabaseName> databaseNameFuture = spy( new CompletableFuture<>() );
if ( completed )
{
databaseNameFuture.complete( DatabaseNameUtil.systemDatabase() );
}
when( context.databaseNameFuture() ).thenReturn( databaseNameFuture );
when( context.mode() ).thenReturn( WRITE );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@

import java.util.concurrent.CompletionException;

import org.neo4j.driver.internal.RoutingErrorHandler;
import org.neo4j.driver.internal.spi.ResponseHandler;
import org.neo4j.driver.AccessMode;
import org.neo4j.driver.exceptions.ClientException;
import org.neo4j.driver.exceptions.ServiceUnavailableException;
import org.neo4j.driver.exceptions.SessionExpiredException;
import org.neo4j.driver.exceptions.TransientException;
import org.neo4j.driver.internal.RoutingErrorHandler;
import org.neo4j.driver.internal.spi.ResponseHandler;

import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.junit.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.neo4j.driver.internal.BoltServerAddress.LOCAL_DEFAULT;

class RoutingResponseHandlerTest
Expand All @@ -50,7 +50,7 @@ void shouldUnwrapCompletionException()
Throwable handledError = handle( new CompletionException( error ), errorHandler );

assertEquals( error, handledError );
verifyZeroInteractions( errorHandler );
verifyNoInteractions( errorHandler );
}

@Test
Expand Down Expand Up @@ -86,7 +86,7 @@ void shouldHandleTransientException()
Throwable handledError = handle( error, errorHandler );

assertEquals( error, handledError );
verifyZeroInteractions( errorHandler );
verifyNoInteractions( errorHandler );
}

@Test
Expand Down Expand Up @@ -122,7 +122,7 @@ void shouldHandleClientException()
Throwable handledError = handle( error, errorHandler, AccessMode.READ );

assertEquals( error, handledError );
verifyZeroInteractions( errorHandler );
verifyNoInteractions( errorHandler );
}

@Test
Expand Down Expand Up @@ -158,7 +158,7 @@ private void testWriteFailureWithReadAccessMode( String code )

assertThat( handledError, instanceOf( ClientException.class ) );
assertEquals( "Write queries cannot be performed in READ access mode.", handledError.getMessage() );
verifyZeroInteractions( errorHandler );
verifyNoInteractions( errorHandler );
}

private void testWriteFailureWithWriteAccessMode( String code )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import static org.neo4j.driver.internal.logging.DevNullLogging.DEV_NULL_LOGGING;
import static org.neo4j.driver.internal.util.Futures.failedFuture;
Expand Down Expand Up @@ -1090,7 +1090,7 @@ void nothingIsLoggedOnFatalFailure()
throw new RuntimeException( "Fatal blocking" );
} ) );
assertEquals( "Fatal blocking", error.getMessage() );
verifyZeroInteractions( logger );
verifyNoInteractions( logger );
}

@Test
Expand All @@ -1106,7 +1106,7 @@ void nothingIsLoggedOnFatalFailureAsync()
await( logic.retryAsync( () -> failedFuture( new RuntimeException( "Fatal async" ) ) ) ) );

assertEquals( "Fatal async", error.getMessage() );
verifyZeroInteractions( logger );
verifyNoInteractions( logger );
}

@Test
Expand All @@ -1122,7 +1122,7 @@ void nothingIsLoggedOnFatalFailureRx()
RuntimeException error = assertThrows( RuntimeException.class, () -> await( retryRx ) );

assertEquals( "Fatal rx", error.getMessage() );
verifyZeroInteractions( logger );
verifyNoInteractions( logger );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@

// tag::driver-introduction-example-import[]

import org.neo4j.driver.*;
import org.neo4j.driver.exceptions.Neo4jException;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import static org.neo4j.driver.Config.TrustStrategy.trustAllCertificates;
import org.neo4j.driver.AuthTokens;
import org.neo4j.driver.Config;
import org.neo4j.driver.Driver;
import org.neo4j.driver.GraphDatabase;
import org.neo4j.driver.Logging;
import org.neo4j.driver.Record;
import org.neo4j.driver.Result;
import org.neo4j.driver.Session;
import org.neo4j.driver.exceptions.Neo4jException;
// end::driver-introduction-example-import[]

// tag::driver-introduction-example[]
Expand Down Expand Up @@ -61,17 +66,19 @@ public void createFriendship(final String person1Name, final String person2Name,
params.put("person2_name", person2Name);
params.put("knows_from", knowsFrom );

try (Session session = driver.session()) {
try (Session session = driver.session())
{
// Write transactions allow the driver to handle retries and transient errors
Record record = session.writeTransaction(tx -> {
Result result = tx.run(createFriendshipQuery, params);
return result.single();
});
System.out.println(String.format("Created friendship between: %s, %s from %s",
record.get("p1").get("name").asString(),
record.get("p2").get("name").asString(),
record.get("k").get("from").asString()));
// You should capture any errors along with the query and data for traceability
Record record = session.writeTransaction( tx ->
{
Result result = tx.run( createFriendshipQuery, params );
return result.single();
} );
System.out.println( String.format( "Created friendship between: %s, %s from %s",
record.get( "p1" ).get( "name" ).asString(),
record.get( "p2" ).get( "name" ).asString(),
record.get( "k" ).get( "from" ).asString() ) );
// You should capture any errors along with the query and data for traceability
} catch (Neo4jException ex) {
LOGGER.log(Level.SEVERE, createFriendshipQuery + " raised an exception", ex);
throw ex;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<rxjava.version>2.2.21</rxjava.version>
<slf4j-api.version>1.7.35</slf4j-api.version>
<hamcrest-junit.version>2.0.0.0</hamcrest-junit.version>
<mockito-core.version>2.28.2</mockito-core.version>
<mockito-core.version>4.3.1</mockito-core.version>
<junit.version>5.8.2</junit.version>
<jarchivelib.version>1.2.0</jarchivelib.version>
<bouncycastle-jdk15on.version>1.70</bouncycastle-jdk15on.version>
Expand Down