### Question:
AccuRevUpdateCommand extends AbstractAccuRevCommand { public UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) throws ScmException { return (UpdateScmResult) execute( repository, fileSet, parameters ); } AccuRevUpdateCommand( ScmLogger logger ); UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters );  }### Answer:
@Test public void testUpdate() throws Exception { final File keptFile = new File( "updated/file" ); final File keptAdded = new File( "new/file" ); List<File> files = Arrays.asList( keptFile, keptAdded ); when( accurev.update( eq( basedir ), any( String.class ) ) ).thenReturn( files ); AccuRevUpdateCommand command = new AccuRevUpdateCommand( getLogger() ); CommandParameters commandParameters = new CommandParameters(); commandParameters.setString( CommandParameter.RUN_CHANGELOG_WITH_UPDATE, Boolean.toString( false ) ); UpdateScmResult result = command.update( repo, testFileSet, commandParameters ); assertThat( result.isSuccess(), is( true ) ); assertThat( result.getUpdatedFiles().size(), is( 2 ) ); assertHasScmFile( result.getUpdatedFiles(), "updated/file", ScmFileStatus.UPDATED ); assertHasScmFile( result.getUpdatedFiles(), "new/file", ScmFileStatus.UPDATED ); }
@Test public void testUpdateWithChangeLog() throws Exception { final WorkSpace wsBefore = new WorkSpace( "theWorkSpace", 123 ); Map<String, WorkSpace> workspaces = Collections.singletonMap( "theWorkSpace", wsBefore ); when( accurev.showWorkSpaces() ).thenReturn( workspaces ); List<File> emptyList = Collections.emptyList(); when( accurev.update( eq( basedir ), any( String.class ) ) ).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 ); AccuRevUpdateCommand command = new AccuRevUpdateCommand( getLogger() ); CommandParameters commandParameters = new CommandParameters(); commandParameters.setString( CommandParameter.RUN_CHANGELOG_WITH_UPDATE, Boolean.toString( true ) ); UpdateScmResult result = command.update( repo, testFileSet, commandParameters ); assertThat( result.isSuccess(), is( true ) ); assertThat( result, IsInstanceOf.instanceOf( AccuRevUpdateScmResult.class ) ); AccuRevUpdateScmResult accuRevResult = (AccuRevUpdateScmResult) result; assertThat( accuRevResult.getFromRevision(), is( "theWorkSpace/123" ) ); assertThat( accuRevResult.getToRevision(), is( "theWorkSpace/197" ) ); }
@Test public void testAccuRevFailure() throws Exception { final ScmFileSet testFileSet = new ScmFileSet( new File( "/my/workspace/project/dir" ) ); final File basedir = testFileSet.getBasedir(); info.setWorkSpace( "theWorkSpace" ); when( accurev.update( eq( basedir ), any( String.class ) ) ).thenReturn( null ); AccuRevUpdateCommand command = new AccuRevUpdateCommand( getLogger() ); CommandParameters commandParameters = new CommandParameters(); commandParameters.setString( CommandParameter.RUN_CHANGELOG_WITH_UPDATE, Boolean.toString( false ) ); UpdateScmResult result = command.update( repo, testFileSet, commandParameters ); assertThat( result.isSuccess(), is( false ) ); assertThat( result.getProviderMessage(), notNullValue() ); }