From 541c8a4c68e55805a45f2ba5370ffee46268ee0c Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 10 Jan 2021 15:43:44 +0100 Subject: [PATCH] Bump mockito-core from 1.10.19 to 2.28.2 - required to pass tests with Java 16 --- .../command/AbstractAccuRevCommandTest.java | 20 +++++++++---------- .../AccuRevChangeLogCommandTest.java | 5 +++-- .../checkin/AccuRevCheckInCommandTest.java | 3 ++- .../checkout/AccuRevCheckOutCommandTest.java | 5 ++--- .../export/AccuRevExportCommandTest.java | 15 +++++++------- .../login/AccuRevLoginCommandTest.java | 14 ++++++------- .../status/AccuRevStatusCommandTest.java | 17 ++++++++-------- .../update/AccurevUpdateCommandTest.java | 15 +++++++------- pom.xml | 2 +- 9 files changed, 49 insertions(+), 47 deletions(-) diff --git a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/AbstractAccuRevCommandTest.java b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/AbstractAccuRevCommandTest.java index 718f7e82b..1e945db83 100644 --- a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/AbstractAccuRevCommandTest.java +++ b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/AbstractAccuRevCommandTest.java @@ -19,9 +19,6 @@ * under the License. */ -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.when; - import java.io.File; import java.io.InputStream; import java.util.Date; @@ -37,7 +34,10 @@ import org.junit.runner.RunWith; import org.mockito.InOrder; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; + +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.lenient; @RunWith( MockitoJUnitRunner.class ) public abstract class AbstractAccuRevCommandTest @@ -76,15 +76,15 @@ public void setUp() info = new AccuRevInfo( basedir ); info.setUser( "me" ); - when( accurev.getCommandLines() ).thenReturn( "accurev mock" ); - when( accurev.getErrorOutput() ).thenReturn( "accurev mock error output" ); - when( accurev.getClientVersion() ).thenReturn( "4.9.0" ); - when( accurev.showStream( "myStream" ) ).thenReturn( + lenient().when( accurev.getCommandLines() ).thenReturn( "accurev mock" ); + lenient().when( accurev.getErrorOutput() ).thenReturn( "accurev mock error output" ); + lenient().when( accurev.getClientVersion() ).thenReturn( "4.9.0" ); + lenient().when( accurev.showStream( "myStream" ) ).thenReturn( new Stream( "myStream", 10L, "myDepot", 1L, "myDepot", new Date(), "normal" ) ); - when( accurev.info( null ) ).thenReturn( info ); - when( accurev.info( basedir ) ).thenReturn( info ); + lenient().when( accurev.info( null ) ).thenReturn( info ); + lenient().when( accurev.info( basedir ) ).thenReturn( info ); repo.setLogger( getLogger() ); repo.setStreamName( "myStream" ); diff --git a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTest.java b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTest.java index f077f84e8..7617b205a 100644 --- a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTest.java +++ b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTest.java @@ -27,6 +27,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.when; import static org.apache.maven.scm.ChangeFileMatcher.changeFile; @@ -97,10 +98,10 @@ public void testChangeLogToNow() when( accurev.showStream( "aStream" ) ).thenReturn( basisStream ); List emptyList = Collections.emptyList(); - when( accurev.diff( "myStream", "12", "42" ) ).thenReturn( emptyList ); + lenient().when( accurev.diff( "myStream", "12", "42" ) ).thenReturn( emptyList ); List noTransactions = Collections.emptyList(); - when( accurev.history( "aStream", "13", "42", 0, false, false ) ).thenReturn( noTransactions ); + lenient().when( accurev.history( "aStream", "13", "42", 0, false, false ) ).thenReturn( noTransactions ); AccuRevChangeLogCommand command = new AccuRevChangeLogCommand( getLogger() ); CommandParameters params = new CommandParameters(); diff --git a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTest.java b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTest.java index d5a9fc399..e02bc2e50 100644 --- a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTest.java +++ b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTest.java @@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.when; import java.io.File; @@ -128,7 +129,7 @@ public void testCheckinExplicitFiles() final ScmFileSet testFileSet = new ScmFileSet( basedir, files ); - when( accurev.info( basedir ) ).thenReturn( info ); + lenient().when( accurev.info( basedir ) ).thenReturn( info ); when( accurev.promote( basedir, files, "A commit message" ) ).thenReturn( files ); diff --git a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/checkout/AccuRevCheckOutCommandTest.java b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/checkout/AccuRevCheckOutCommandTest.java index ef1d2c654..0aa5460aa 100644 --- a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/checkout/AccuRevCheckOutCommandTest.java +++ b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/checkout/AccuRevCheckOutCommandTest.java @@ -23,8 +23,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; import java.io.File; import java.util.Collections; @@ -136,7 +135,7 @@ public void testReCheckoutExistingWorkspaceDifferentBasis() when( accurev.chws( basedir, "someOldStream_someUser", "mySnapShot" ) ).thenReturn( true ); List emptyPop = Collections.emptyList(); - when( accurev.popExternal( basedir, null, null, null ) ).thenReturn( emptyPop ); + lenient().when( accurev.popExternal( basedir, null, null, null ) ).thenReturn( emptyPop ); List updatedFiles = Collections.singletonList( new File( "updated/file" ) ); when( accurev.update( basedir, null ) ).thenReturn( updatedFiles ); diff --git a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/export/AccuRevExportCommandTest.java b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/export/AccuRevExportCommandTest.java index 3bc67bf60..50ae2eeac 100644 --- a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/export/AccuRevExportCommandTest.java +++ b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/export/AccuRevExportCommandTest.java @@ -20,14 +20,15 @@ */ import static org.apache.maven.scm.ScmFileMatcher.assertHasScmFile; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.mockito.hamcrest.MockitoHamcrest.argThat; import java.io.File; import java.util.Collection; @@ -179,7 +180,7 @@ public void testNonPersistentWithinExistingWorkspace() when( accurev.stat( basedir ) ).thenReturn( null ); when( accurev.rmws( "myStream_me" ) ).thenReturn( Boolean.TRUE ); List poppedFiles = Collections.singletonList( new File( "exported/file" ) ); - when( + lenient().when( accurev.popExternal( eq( basedir ), eq( "mySnapShot" ), eq( "now" ), (Collection) argThat( hasItem( new File( "/./project/dir" ) ) ) ) ).thenReturn( poppedFiles ); @@ -216,7 +217,7 @@ public void testNonPersistentCheckoutUsesExport() when( accurev.stat( basedir ) ).thenReturn( null ); when( accurev.rmws( "myStream_me" ) ).thenReturn( Boolean.TRUE ); List poppedFiles = Collections.singletonList( new File( "exported/file" ) ); - when( + lenient().when( accurev.popExternal( eq( basedir ), eq( "mySnapShot" ), eq( "now" ), (Collection) argThat( hasItem( new File( "/./project/dir" ) ) ) ) ).thenReturn( poppedFiles ); diff --git a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/login/AccuRevLoginCommandTest.java b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/login/AccuRevLoginCommandTest.java index adbe49145..cfcf7ab57 100644 --- a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/login/AccuRevLoginCommandTest.java +++ b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/login/AccuRevLoginCommandTest.java @@ -24,9 +24,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; import java.io.File; @@ -48,7 +46,7 @@ public void testWhenNotLoggedIn() repo.setUser( "myUser" ); repo.setPassword( "aPassword" ); info.setUser( "(not logged in)" ); - when( accurev.info( any( File.class ) ) ).thenReturn( info ); + lenient().when( accurev.info( any( File.class ) ) ).thenReturn( info ); when( accurev.login( "myUser", "aPassword" ) ).thenReturn( true ); AccuRevLoginCommand command = new AccuRevLoginCommand( getLogger() ); @@ -66,7 +64,7 @@ public void testWhenAlreadyLoggedInAsSomeoneElse() repo.setUser( "myUser" ); repo.setPassword( "aPassword" ); info.setUser( "A.N.Other" ); - when( accurev.info( any( File.class ) ) ).thenReturn( info ); + lenient().when( accurev.info( any( File.class ) ) ).thenReturn( info ); when( accurev.login( "myUser", "aPassword" ) ).thenReturn( true ); AccuRevLoginCommand command = new AccuRevLoginCommand( getLogger() ); @@ -85,7 +83,7 @@ public void testWhenAlreadyLoggedInAsRequiredUser() repo.setUser( "myUser" ); repo.setPassword( "aPassword" ); info.setUser( "myUser" ); - when( accurev.info( any( File.class ) ) ).thenReturn( info ); + lenient().when( accurev.info( any( File.class ) ) ).thenReturn( info ); AccuRevLoginCommand command = new AccuRevLoginCommand( getLogger() ); LoginScmResult result = command.login( repo, new ScmFileSet( basedir ), new CommandParameters() ); @@ -104,7 +102,7 @@ public void testWhenNoUserSuppliedAndAlreadyLoggedIn() repo.setUser( null ); info.setUser( "anyUser" ); - when( accurev.info( any( File.class ) ) ).thenReturn( info ); + lenient().when( accurev.info( any( File.class ) ) ).thenReturn( info ); AccuRevLoginCommand command = new AccuRevLoginCommand( getLogger() ); LoginScmResult result = command.login( repo, new ScmFileSet( basedir ), new CommandParameters() ); @@ -121,7 +119,7 @@ public void testFailsWhenNoUserSuppliedAndNotLoggedIn() repo.setUser( null ); info.setUser( "(not logged in)" ); - when( accurev.info( any( File.class ) ) ).thenReturn( info ); + lenient().when( accurev.info( any( File.class ) ) ).thenReturn( info ); AccuRevLoginCommand command = new AccuRevLoginCommand( getLogger() ); LoginScmResult result = command.login( repo, new ScmFileSet( basedir ), new CommandParameters() ); diff --git a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommandTest.java b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommandTest.java index 312c258d7..1ab39ead2 100644 --- a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommandTest.java +++ b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommandTest.java @@ -21,15 +21,15 @@ import static org.apache.maven.scm.ScmFileMatcher.assertHasScmFile; import static org.apache.maven.scm.ScmFileMatcher.scmFile; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.CoreMatchers.hasItems; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; +import static org.hamcrest.core.Is.is; +import static org.mockito.ArgumentMatchers.anyListOf; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; +import static org.mockito.hamcrest.MockitoHamcrest.argThat; import java.io.File; import java.util.Arrays; @@ -90,7 +90,8 @@ public void testStatus() when( accurev.statBackingStream( eq( basedir ), (Collection) argThat( hasItems( modifiedFile, modifiedAdded, keptFile, - keptAdded ) ) ) ).thenReturn( + keptAdded ) ) ) ) + .thenReturn( catElems ); AccuRevStatusCommand command = new AccuRevStatusCommand( getLogger() ); diff --git a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/update/AccurevUpdateCommandTest.java b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/update/AccurevUpdateCommandTest.java index 4e65bbd41..bcaa13d69 100644 --- a/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/update/AccurevUpdateCommandTest.java +++ b/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/update/AccurevUpdateCommandTest.java @@ -23,8 +23,8 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import java.io.File; @@ -44,6 +44,7 @@ import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest; import org.hamcrest.core.IsInstanceOf; import org.junit.Test; +import org.mockito.ArgumentMatchers; public class AccurevUpdateCommandTest extends AbstractAccuRevCommandTest @@ -76,7 +77,7 @@ public void testUpdate() List files = Arrays.asList( keptFile, keptAdded ); - when( accurev.update( eq( basedir ), any( String.class ) ) ).thenReturn( files ); + when( accurev.update( eq( basedir ), anyString() ) ).thenReturn( files ); AccuRevUpdateCommand command = new AccuRevUpdateCommand( getLogger() ); @@ -103,15 +104,15 @@ public void testUpdateWithChangeLog() when( accurev.showWorkSpaces() ).thenReturn( workspaces ); List emptyList = Collections.emptyList(); - when( accurev.update( eq( basedir ), any( String.class ) ) ).thenReturn( emptyList ); + when( accurev.update( eq( basedir ), anyString() ) ).thenReturn( emptyList ); final Date currentDate = new Date(); List transactions = Collections.singletonList( new Transaction( 197L, currentDate, "type", "user" ) ); when( - accurev.history( any( String.class ), any( String.class ), any( String.class ), eq( 1 ), eq( true ), - eq( true ) ) ).thenReturn( transactions ); + accurev.history( ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(), + eq( 1 ), eq( true ), eq( true ) ) ).thenReturn( transactions ); AccuRevUpdateCommand command = new AccuRevUpdateCommand( getLogger() ); @@ -136,7 +137,7 @@ public void testAccuRevFailure() info.setWorkSpace( "theWorkSpace" ); - when( accurev.update( eq( basedir ), any( String.class ) ) ).thenReturn( null ); + when( accurev.update( eq( basedir ), ArgumentMatchers.any() ) ).thenReturn( null ); AccuRevUpdateCommand command = new AccuRevUpdateCommand( getLogger() ); diff --git a/pom.xml b/pom.xml index 73e6ccb9d..bdd69c476 100644 --- a/pom.xml +++ b/pom.xml @@ -287,7 +287,7 @@ org.mockito mockito-core - 1.10.19 + 2.28.2 org.apache.maven.scm