Skip to content

Commit

Permalink
Bump mockito-core from 1.10.19 to 2.28.2
Browse files Browse the repository at this point in the history
- required to pass tests with Java 16
  • Loading branch information
slachiewicz committed Feb 22, 2021
1 parent 1f79009 commit 541c8a4
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -97,10 +98,10 @@ public void testChangeLogToNow()
when( accurev.showStream( "aStream" ) ).thenReturn( basisStream );

List<FileDifference> emptyList = Collections.emptyList();
when( accurev.diff( "myStream", "12", "42" ) ).thenReturn( emptyList );
lenient().when( accurev.diff( "myStream", "12", "42" ) ).thenReturn( emptyList );

List<Transaction> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -136,7 +135,7 @@ public void testReCheckoutExistingWorkspaceDifferentBasis()
when( accurev.chws( basedir, "someOldStream_someUser", "mySnapShot" ) ).thenReturn( true );

List<File> emptyPop = Collections.emptyList();
when( accurev.popExternal( basedir, null, null, null ) ).thenReturn( emptyPop );
lenient().when( accurev.popExternal( basedir, null, null, null ) ).thenReturn( emptyPop );

List<File> updatedFiles = Collections.singletonList( new File( "updated/file" ) );
when( accurev.update( basedir, null ) ).thenReturn( updatedFiles );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -179,7 +180,7 @@ public void testNonPersistentWithinExistingWorkspace()
when( accurev.stat( basedir ) ).thenReturn( null );
when( accurev.rmws( "myStream_me" ) ).thenReturn( Boolean.TRUE );
List<File> poppedFiles = Collections.singletonList( new File( "exported/file" ) );
when(
lenient().when(
accurev.popExternal( eq( basedir ), eq( "mySnapShot" ), eq( "now" ),
(Collection<File>) argThat( hasItem( new File( "/./project/dir" ) ) ) ) ).thenReturn(
poppedFiles );
Expand Down Expand Up @@ -216,7 +217,7 @@ public void testNonPersistentCheckoutUsesExport()
when( accurev.stat( basedir ) ).thenReturn( null );
when( accurev.rmws( "myStream_me" ) ).thenReturn( Boolean.TRUE );
List<File> poppedFiles = Collections.singletonList( new File( "exported/file" ) );
when(
lenient().when(
accurev.popExternal( eq( basedir ), eq( "mySnapShot" ), eq( "now" ),
(Collection<File>) argThat( hasItem( new File( "/./project/dir" ) ) ) ) ).thenReturn(
poppedFiles );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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() );

Expand All @@ -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() );

Expand All @@ -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() );
Expand All @@ -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() );
Expand All @@ -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() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -90,7 +90,8 @@ public void testStatus()
when(
accurev.statBackingStream( eq( basedir ), (Collection<File>) argThat( hasItems( modifiedFile,
modifiedAdded, keptFile,
keptAdded ) ) ) ).thenReturn(
keptAdded ) ) ) )
.thenReturn(
catElems );

AccuRevStatusCommand command = new AccuRevStatusCommand( getLogger() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -76,7 +77,7 @@ public void testUpdate()

List<File> 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() );

Expand All @@ -103,15 +104,15 @@ public void testUpdateWithChangeLog()
when( accurev.showWorkSpaces() ).thenReturn( workspaces );

List<File> 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<Transaction> 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.<String>any(), ArgumentMatchers.<String>any(), ArgumentMatchers.<String>any(),
eq( 1 ), eq( true ), eq( true ) ) ).thenReturn( transactions );

AccuRevUpdateCommand command = new AccuRevUpdateCommand( getLogger() );

Expand All @@ -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.<String>any() ) ).thenReturn( null );

AccuRevUpdateCommand command = new AccuRevUpdateCommand( getLogger() );

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
<version>2.28.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
Expand Down

0 comments on commit 541c8a4

Please sign in to comment.