Skip to content

Commit

Permalink
Migrate mockito to latest 2.10.0
Browse files Browse the repository at this point in the history
Upgrade from mockito to latest version that among other nice features has
support of Java 9, report for unnecessary mocking, possibility to mock
final classes.
Full release notes can be found at: https://github.com/mockito/mockito/blob/release/2.x/doc/release-notes/official.md#2100-2017-09-08-published-to-jcentermaven-central
  • Loading branch information
MishaDemianenko committed Sep 28, 2017
1 parent e8b3a5c commit af5a8bd
Show file tree
Hide file tree
Showing 148 changed files with 485 additions and 569 deletions.
Expand Up @@ -26,7 +26,7 @@
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.InOrder; import org.mockito.InOrder;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;


import org.neo4j.bolt.logging.BoltMessageLogger; import org.neo4j.bolt.logging.BoltMessageLogger;


Expand Down
Expand Up @@ -19,16 +19,16 @@
*/ */
package org.neo4j.bolt.logging; package org.neo4j.bolt.logging;


import java.net.InetSocketAddress;

import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.unix.DomainSocketAddress; import io.netty.channel.unix.DomainSocketAddress;
import io.netty.util.Attribute; import io.netty.util.Attribute;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;

import java.net.InetSocketAddress;


import org.neo4j.bolt.v1.runtime.Neo4jError; import org.neo4j.bolt.v1.runtime.Neo4jError;
import org.neo4j.kernel.DeadlockDetectedException; import org.neo4j.kernel.DeadlockDetectedException;
Expand All @@ -37,7 +37,6 @@
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;

import static org.neo4j.bolt.logging.BoltMessageLoggerImpl.CORRELATION_ATTRIBUTE_KEY; import static org.neo4j.bolt.logging.BoltMessageLoggerImpl.CORRELATION_ATTRIBUTE_KEY;
import static org.neo4j.helpers.ValueUtils.asMapValue; import static org.neo4j.helpers.ValueUtils.asMapValue;
import static org.neo4j.helpers.collection.MapUtil.map; import static org.neo4j.helpers.collection.MapUtil.map;
Expand Down
Expand Up @@ -19,15 +19,15 @@
*/ */
package org.neo4j.bolt.logging; package org.neo4j.bolt.logging;


import java.io.IOException;
import java.net.InetSocketAddress;

import io.netty.channel.Channel; import io.netty.channel.Channel;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Answers; import org.mockito.Answers;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;

import java.io.IOException;
import java.net.InetSocketAddress;


import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Config;
Expand All @@ -42,7 +42,6 @@
import static org.mockito.Matchers.startsWith; import static org.mockito.Matchers.startsWith;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;

import static org.neo4j.graphdb.factory.GraphDatabaseSettings.bolt_logging_enabled; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.bolt_logging_enabled;
import static org.neo4j.helpers.collection.MapUtil.stringMap; import static org.neo4j.helpers.collection.MapUtil.stringMap;


Expand All @@ -64,7 +63,6 @@ public void shouldCreateNullLoggerWhenDisabled()
{ {
Config config = newConfig( false ); Config config = newConfig( false );


when( channel.remoteAddress() ).thenReturn( inetSocketAddress );
BoltMessageLogging logging = BoltMessageLogging.create( fs, jobScheduler, config, log ); BoltMessageLogging logging = BoltMessageLogging.create( fs, jobScheduler, config, log );
BoltMessageLogger logger = logging.newLogger( channel ); BoltMessageLogger logger = logging.newLogger( channel );


Expand Down
Expand Up @@ -22,7 +22,6 @@
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.buffer.UnpooledByteBufAllocator;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelPromise;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
Expand All @@ -43,6 +42,7 @@
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -193,10 +193,10 @@ public void shouldQueueWritesMadeWhileFlushing() throws Throwable
final CountDownLatch finishLatch = new CountDownLatch( 1 ); final CountDownLatch finishLatch = new CountDownLatch( 1 );
final AtomicBoolean parallelException = new AtomicBoolean( false ); final AtomicBoolean parallelException = new AtomicBoolean( false );


when( ch.writeAndFlush( any(), any( ChannelPromise.class ) ) ).thenAnswer( invocation -> when( ch.writeAndFlush( any(), isNull() ) ).thenAnswer( invocation ->
{ {
startLatch.countDown(); startLatch.countDown();
ByteBuf byteBuf = (ByteBuf) invocation.getArguments()[0]; ByteBuf byteBuf = invocation.getArgument( 0 );
writtenData.limit( writtenData.position() + byteBuf.readableBytes() ); writtenData.limit( writtenData.position() + byteBuf.readableBytes() );
byteBuf.readBytes( writtenData ); byteBuf.readBytes( writtenData );
return null; return null;
Expand Down Expand Up @@ -275,9 +275,9 @@ public void shouldFlushOnClose() throws Throwable


private void setupWriteAndFlush() private void setupWriteAndFlush()
{ {
when( ch.writeAndFlush( any(), any( ChannelPromise.class ) ) ).thenAnswer( invocation -> when( ch.writeAndFlush( any(), isNull() ) ).thenAnswer( invocation ->
{ {
ByteBuf byteBuf = (ByteBuf) invocation.getArguments()[0]; ByteBuf byteBuf = invocation.getArgument( 0 );
writtenData.limit( writtenData.position() + byteBuf.readableBytes() ); writtenData.limit( writtenData.position() + byteBuf.readableBytes() );
byteBuf.readBytes( writtenData ); byteBuf.readBytes( writtenData );
return null; return null;
Expand Down
Expand Up @@ -22,15 +22,13 @@
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.buffer.UnpooledByteBufAllocator;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelPromise;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;


import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;


import org.neo4j.bolt.v1.transport.ChunkedOutput; import org.neo4j.bolt.v1.transport.ChunkedOutput;


import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
Expand All @@ -48,9 +46,9 @@ public static byte[] chunk( int maxChunkSize, byte[][] messages ) throws IOExcep


Channel ch = mock( Channel.class ); Channel ch = mock( Channel.class );
when( ch.alloc() ).thenReturn( UnpooledByteBufAllocator.DEFAULT ); when( ch.alloc() ).thenReturn( UnpooledByteBufAllocator.DEFAULT );
when( ch.writeAndFlush( any(), any( ChannelPromise.class ) ) ).then( inv -> when( ch.writeAndFlush( any(), isNull() ) ).then( inv ->
{ {
ByteBuf buf = (ByteBuf) inv.getArguments()[0]; ByteBuf buf = inv.getArgument( 0 );
outputBuffer.limit( outputBuffer.position() + buf.readableBytes() ); outputBuffer.limit( outputBuffer.position() + buf.readableBytes() );
buf.readBytes( outputBuffer ); buf.readBytes( outputBuffer );
buf.release(); buf.release();
Expand Down
Expand Up @@ -113,10 +113,10 @@ private void testPermutation( byte[] unfragmented, ByteBuf[] fragments ) throws
BoltStateMachine machine = mock( BoltStateMachine.class ); BoltStateMachine machine = mock( BoltStateMachine.class );


Channel ch = mock( Channel.class ); Channel ch = mock( Channel.class );
when(ch.alloc()).thenReturn( UnpooledByteBufAllocator.DEFAULT ); when( ch.alloc() ).thenReturn( UnpooledByteBufAllocator.DEFAULT );


ChannelHandlerContext ctx = mock( ChannelHandlerContext.class ); ChannelHandlerContext ctx = mock( ChannelHandlerContext.class );
when(ctx.channel()).thenReturn( ch ); when( ctx.channel() ).thenReturn( ch );


BoltChannel boltChannel = mock( BoltChannel.class ); BoltChannel boltChannel = mock( BoltChannel.class );
when( boltChannel.channelHandlerContext() ).thenReturn( ctx ); when( boltChannel.channelHandlerContext() ).thenReturn( ctx );
Expand Down
Expand Up @@ -51,7 +51,6 @@
import static org.mockito.Matchers.anyObject; import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.eq; import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.stub;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;


Expand Down Expand Up @@ -158,9 +157,9 @@ public void shouldWriteReportFileToCurrentDirectoryByDefault()
new CheckConsistencyCommand( homeDir, testDir.directory( "conf" ).toPath(), outsideWorld, new CheckConsistencyCommand( homeDir, testDir.directory( "conf" ).toPath(), outsideWorld,
consistencyCheckService ); consistencyCheckService );


stub( consistencyCheckService.runFullConsistencyCheck( anyObject(), anyObject(), anyObject(), anyObject(), when( consistencyCheckService.runFullConsistencyCheck( anyObject(), anyObject(), anyObject(), anyObject(),
anyObject(), anyBoolean(), anyObject(), any( CheckConsistencyConfig.class ) ) ) anyObject(), anyBoolean(), anyObject(), any( CheckConsistencyConfig.class ) ) )
.toReturn( ConsistencyCheckService.Result.success( null ) ); .thenReturn( ConsistencyCheckService.Result.success( null ) );


checkConsistencyCommand.execute( new String[]{"--database=mydb"} ); checkConsistencyCommand.execute( new String[]{"--database=mydb"} );


Expand All @@ -182,9 +181,9 @@ public void shouldWriteReportFileToSpecifiedDirectory()
new CheckConsistencyCommand( homeDir, testDir.directory( "conf" ).toPath(), outsideWorld, new CheckConsistencyCommand( homeDir, testDir.directory( "conf" ).toPath(), outsideWorld,
consistencyCheckService ); consistencyCheckService );


stub( consistencyCheckService.runFullConsistencyCheck( anyObject(), anyObject(), anyObject(), anyObject(), when( consistencyCheckService.runFullConsistencyCheck( anyObject(), anyObject(), anyObject(), anyObject(),
anyObject(), anyBoolean(), anyObject(), any( CheckConsistencyConfig.class ) ) ) anyObject(), anyBoolean(), anyObject(), any( CheckConsistencyConfig.class ) ) )
.toReturn( ConsistencyCheckService.Result.success( null ) ); .thenReturn( ConsistencyCheckService.Result.success( null ) );


checkConsistencyCommand.execute( new String[]{"--database=mydb", "--report-dir=some-dir-or-other"} ); checkConsistencyCommand.execute( new String[]{"--database=mydb", "--report-dir=some-dir-or-other"} );


Expand All @@ -207,9 +206,9 @@ public void shouldCanonicalizeReportDirectory()
new CheckConsistencyCommand( homeDir, testDir.directory( "conf" ).toPath(), outsideWorld, new CheckConsistencyCommand( homeDir, testDir.directory( "conf" ).toPath(), outsideWorld,
consistencyCheckService ); consistencyCheckService );


stub( consistencyCheckService.runFullConsistencyCheck( anyObject(), anyObject(), anyObject(), anyObject(), when( consistencyCheckService.runFullConsistencyCheck( anyObject(), anyObject(), anyObject(), anyObject(),
anyObject(), anyBoolean(), anyObject(), any( CheckConsistencyConfig.class ) ) ) anyObject(), anyBoolean(), anyObject(), any( CheckConsistencyConfig.class ) ) )
.toReturn( ConsistencyCheckService.Result.success( null ) ); .thenReturn( ConsistencyCheckService.Result.success( null ) );


checkConsistencyCommand.execute( new String[]{"--database=mydb", "--report-dir=" + Paths.get( "..", "bar" )} ); checkConsistencyCommand.execute( new String[]{"--database=mydb", "--report-dir=" + Paths.get( "..", "bar" )} );


Expand All @@ -231,9 +230,9 @@ public void passesOnCheckParameters() throws Exception
new CheckConsistencyCommand( homeDir, testDir.directory( "conf" ).toPath(), outsideWorld, new CheckConsistencyCommand( homeDir, testDir.directory( "conf" ).toPath(), outsideWorld,
consistencyCheckService ); consistencyCheckService );


stub( consistencyCheckService.runFullConsistencyCheck( anyObject(), anyObject(), anyObject(), anyObject(), when( consistencyCheckService.runFullConsistencyCheck( anyObject(), anyObject(), anyObject(), anyObject(),
anyObject(), anyBoolean(), anyObject(), any( CheckConsistencyConfig.class ) ) ) anyObject(), anyBoolean(), anyObject(), any( CheckConsistencyConfig.class ) ) )
.toReturn( ConsistencyCheckService.Result.success( null ) ); .thenReturn( ConsistencyCheckService.Result.success( null ) );


checkConsistencyCommand.execute( new String[]{"--database=mydb", "--check-graph=false", checkConsistencyCommand.execute( new String[]{"--database=mydb", "--check-graph=false",
"--check-indexes=false", "--check-label-scan-store=false", "--check-property-owners=true"} ); "--check-indexes=false", "--check-label-scan-store=false", "--check-property-owners=true"} );
Expand All @@ -254,9 +253,9 @@ public void databaseAndBackupAreMutuallyExclusive() throws Exception
new CheckConsistencyCommand( homeDir, testDir.directory( "conf" ).toPath(), outsideWorld, new CheckConsistencyCommand( homeDir, testDir.directory( "conf" ).toPath(), outsideWorld,
consistencyCheckService ); consistencyCheckService );


stub( consistencyCheckService.runFullConsistencyCheck( anyObject(), anyObject(), anyObject(), anyObject(), when( consistencyCheckService.runFullConsistencyCheck( anyObject(), anyObject(), anyObject(), anyObject(),
anyObject(), anyBoolean(), any( CheckConsistencyConfig.class ) ) ) anyObject(), anyBoolean(), any( CheckConsistencyConfig.class ) ) )
.toReturn( ConsistencyCheckService.Result.success( null ) ); .thenReturn( ConsistencyCheckService.Result.success( null ) );


expect.expect( IncorrectUsage.class ); expect.expect( IncorrectUsage.class );
expect.expectMessage( "Only one of '--database' and '--backup' can be specified." ); expect.expectMessage( "Only one of '--database' and '--backup' can be specified." );
Expand Down
Expand Up @@ -31,6 +31,7 @@
import org.junit.runners.Suite; import org.junit.runners.Suite;
import org.junit.runners.model.Statement; import org.junit.runners.model.Statement;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;


Expand All @@ -52,8 +53,8 @@
import org.neo4j.consistency.store.synthetic.IndexEntry; import org.neo4j.consistency.store.synthetic.IndexEntry;
import org.neo4j.consistency.store.synthetic.LabelScanDocument; import org.neo4j.consistency.store.synthetic.LabelScanDocument;
import org.neo4j.kernel.api.index.SchemaIndexProvider; import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.schema.SchemaDescriptor;
import org.neo4j.kernel.api.labelscan.NodeLabelRange; import org.neo4j.kernel.api.labelscan.NodeLabelRange;
import org.neo4j.kernel.api.schema.SchemaDescriptor;
import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory;
import org.neo4j.kernel.impl.store.record.AbstractBaseRecord; import org.neo4j.kernel.impl.store.record.AbstractBaseRecord;
import org.neo4j.kernel.impl.store.record.DynamicRecord; import org.neo4j.kernel.impl.store.record.DynamicRecord;
Expand All @@ -75,13 +76,13 @@
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Matchers.argThat;
import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
import static org.neo4j.consistency.report.ConsistencyReporter.NO_MONITOR; import static org.neo4j.consistency.report.ConsistencyReporter.NO_MONITOR;
import static org.neo4j.kernel.impl.store.counts.keys.CountsKeyFactory.nodeKey; import static org.neo4j.kernel.impl.store.counts.keys.CountsKeyFactory.nodeKey;


Expand Down Expand Up @@ -230,8 +231,7 @@ public void shouldLogInconsistency() throws Exception
else else
{ {
verify( report ).error( any( RecordType.class ), verify( report ).error( any( RecordType.class ),
any( AbstractBaseRecord.class ), any( AbstractBaseRecord.class ), argThat( hasExpectedFormat() ), nullSafeAny() );
argThat( hasExpectedFormat() ), any( Object[].class ) );
} }
} }
else else
Expand All @@ -246,7 +246,7 @@ public void shouldLogInconsistency() throws Exception
{ {
verify( report ).warning( any( RecordType.class ), verify( report ).warning( any( RecordType.class ),
any( AbstractBaseRecord.class ), any( AbstractBaseRecord.class ),
argThat( hasExpectedFormat() ), any( Object[].class ) ); argThat( hasExpectedFormat() ), nullSafeAny() );
} }
} }
} }
Expand Down Expand Up @@ -457,6 +457,11 @@ public Object answer( InvocationOnMock invocation ) throws Throwable
} }
} }


private static <T> T[] nullSafeAny()
{
return ArgumentMatchers.argThat( argument -> true );
}

private static Matcher<String> hasExpectedFormat() private static Matcher<String> hasExpectedFormat()
{ {
return new TypeSafeMatcher<String>() return new TypeSafeMatcher<String>()
Expand Down
Expand Up @@ -56,6 +56,7 @@
import org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord; import org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord;


import static java.util.Collections.singletonMap; import static java.util.Collections.singletonMap;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -114,6 +115,7 @@ public <REFERRED extends AbstractBaseRecord> void comparativeCheck(
{ {
PendingReferenceCheck mock = mock( PendingReferenceCheck.class ); PendingReferenceCheck mock = mock( PendingReferenceCheck.class );
DeferredReferenceCheck check = new DeferredReferenceCheck( Engine.this, checker ); DeferredReferenceCheck check = new DeferredReferenceCheck( Engine.this, checker );
doAnswer( check ).when( mock ).checkReference( isNull(), isNull() );
doAnswer( check ).when( mock ).checkReference( any( AbstractBaseRecord.class ), doAnswer( check ).when( mock ).checkReference( any( AbstractBaseRecord.class ),
any( RecordAccess.class ) ); any( RecordAccess.class ) );
doAnswer( check ).when( mock ).checkDiffReference( any( AbstractBaseRecord.class ), doAnswer( check ).when( mock ).checkDiffReference( any( AbstractBaseRecord.class ),
Expand Down
Expand Up @@ -19,13 +19,13 @@
*/ */
package org.neo4j.cypher.internal.compiler.v3_4.ast.rewriters package org.neo4j.cypher.internal.compiler.v3_4.ast.rewriters


import org.mockito.Matchers._ import org.mockito.ArgumentMatchers._
import org.mockito.Mockito._ import org.mockito.Mockito._
import org.neo4j.cypher.internal.compiler.v3_4.test_helpers.ContextHelper import org.neo4j.cypher.internal.compiler.v3_4.test_helpers.ContextHelper
import org.neo4j.cypher.internal.frontend.v3_4.{AstRewritingMonitor, Rewriter}
import org.neo4j.cypher.internal.frontend.v3_4.ast.rewriters.CNFNormalizer import org.neo4j.cypher.internal.frontend.v3_4.ast.rewriters.CNFNormalizer
import org.neo4j.cypher.internal.frontend.v3_4.phases.Monitors import org.neo4j.cypher.internal.frontend.v3_4.phases.Monitors
import org.neo4j.cypher.internal.frontend.v3_4.test_helpers.CypherFunSuite import org.neo4j.cypher.internal.frontend.v3_4.test_helpers.CypherFunSuite
import org.neo4j.cypher.internal.frontend.v3_4.{AstRewritingMonitor, Rewriter}


class CNFNormalizerTest extends CypherFunSuite with PredicateTestSupport { class CNFNormalizerTest extends CypherFunSuite with PredicateTestSupport {


Expand Down
Expand Up @@ -19,7 +19,7 @@
*/ */
package org.neo4j.cypher.internal.compiler.v3_4.helpers package org.neo4j.cypher.internal.compiler.v3_4.helpers


import org.mockito.Matchers._ import org.mockito.ArgumentMatchers._
import org.mockito.Mockito._ import org.mockito.Mockito._
import org.neo4j.cypher.internal.frontend.v3_4.test_helpers.CypherFunSuite import org.neo4j.cypher.internal.frontend.v3_4.test_helpers.CypherFunSuite
import org.neo4j.cypher.internal.ir.v3_4.{IdName, QueryGraph} import org.neo4j.cypher.internal.ir.v3_4.{IdName, QueryGraph}
Expand Down
Expand Up @@ -19,7 +19,7 @@
*/ */
package org.neo4j.cypher.internal.compiler.v3_4.planner package org.neo4j.cypher.internal.compiler.v3_4.planner


import org.mockito.Matchers._ import org.mockito.ArgumentMatchers._
import org.mockito.Mockito._ import org.mockito.Mockito._
import org.neo4j.cypher.internal.compiler.v3_4._ import org.neo4j.cypher.internal.compiler.v3_4._
import org.neo4j.cypher.internal.compiler.v3_4.ast.rewriters.namePatternPredicatePatternElements import org.neo4j.cypher.internal.compiler.v3_4.ast.rewriters.namePatternPredicatePatternElements
Expand Down Expand Up @@ -94,7 +94,7 @@ trait LogicalPlanningTestSupport extends CypherTestSupport with AstConstructionT


def newMockedStrategy(plan: LogicalPlan) = { def newMockedStrategy(plan: LogicalPlan) = {
val strategy = mock[QueryGraphSolver] val strategy = mock[QueryGraphSolver]
doReturn(plan).when(strategy).plan(any())(any()) doReturn(plan, Nil: _*).when(strategy).plan(any())(any())
strategy strategy
} }


Expand All @@ -120,7 +120,7 @@ trait LogicalPlanningTestSupport extends CypherTestSupport with AstConstructionT


def newMockedPlanContext(implicit statistics: GraphStatistics = newMockedStatistics) = { def newMockedPlanContext(implicit statistics: GraphStatistics = newMockedStatistics) = {
val context = mock[PlanContext] val context = mock[PlanContext]
doReturn(statistics).when(context).statistics doReturn(statistics, Nil: _*).when(context).statistics
context context
} }


Expand Down
Expand Up @@ -19,7 +19,7 @@
*/ */
package org.neo4j.cypher.internal.compiler.v3_4.planner.logical package org.neo4j.cypher.internal.compiler.v3_4.planner.logical


import org.mockito.Matchers.any import org.mockito.ArgumentMatchers.any
import org.mockito.Mockito.{times, verify, when} import org.mockito.Mockito.{times, verify, when}
import org.neo4j.cypher.internal.compiler.v3_4.planner._ import org.neo4j.cypher.internal.compiler.v3_4.planner._
import org.neo4j.cypher.internal.compiler.v3_4.planner.logical.Metrics.QueryGraphSolverInput import org.neo4j.cypher.internal.compiler.v3_4.planner.logical.Metrics.QueryGraphSolverInput
Expand Down
Expand Up @@ -19,7 +19,7 @@
*/ */
package org.neo4j.cypher.internal.compiler.v3_4.planner.logical package org.neo4j.cypher.internal.compiler.v3_4.planner.logical


import org.mockito.Matchers.any import org.mockito.ArgumentMatchers.any
import org.mockito.Mockito.{verify, verifyZeroInteractions, when} import org.mockito.Mockito.{verify, verifyZeroInteractions, when}
import org.neo4j.cypher.internal.compiler.v3_4.planner.LogicalPlanningTestSupport2 import org.neo4j.cypher.internal.compiler.v3_4.planner.LogicalPlanningTestSupport2
import org.neo4j.cypher.internal.frontend.v3_4.test_helpers.CypherFunSuite import org.neo4j.cypher.internal.frontend.v3_4.test_helpers.CypherFunSuite
Expand Down
Expand Up @@ -19,7 +19,7 @@
*/ */
package org.neo4j.cypher.internal.compiler.v3_4.planner.logical.cardinality.assumeIndependence package org.neo4j.cypher.internal.compiler.v3_4.planner.logical.cardinality.assumeIndependence


import org.mockito.Matchers.any import org.mockito.ArgumentMatchers.any
import org.mockito.Mockito._ import org.mockito.Mockito._
import org.mockito.invocation.InvocationOnMock import org.mockito.invocation.InvocationOnMock
import org.mockito.stubbing.Answer import org.mockito.stubbing.Answer
Expand Down Expand Up @@ -90,7 +90,7 @@ class PatternSelectivityCalculatorTest extends CypherFunSuite with LogicalPlanCo
val stats: GraphStatistics = mock[GraphStatistics] val stats: GraphStatistics = mock[GraphStatistics]
when(stats.nodesWithLabelCardinality(any())).thenAnswer(new Answer[Cardinality] { when(stats.nodesWithLabelCardinality(any())).thenAnswer(new Answer[Cardinality] {
override def answer(invocationOnMock: InvocationOnMock): Cardinality = { override def answer(invocationOnMock: InvocationOnMock): Cardinality = {
val arg = invocationOnMock.getArguments()(0).asInstanceOf[Option[LabelId]] val arg:Option[LabelId] = invocationOnMock.getArgument(0)
arg match { arg match {
case None => Cardinality(10) case None => Cardinality(10)
case Some(_) => Cardinality(1) case Some(_) => Cardinality(1)
Expand Down

0 comments on commit af5a8bd

Please sign in to comment.