Coverage Report - org.apache.maven.scm.manager.ScmManagerStub
 
Classes in this File Line Coverage Branch Coverage Complexity
ScmManagerStub
32 %
20/61
N/A
1
 
 1  
 package org.apache.maven.scm.manager;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  * http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.maven.scm.ScmBranch;
 23  
 import org.apache.maven.scm.ScmException;
 24  
 import org.apache.maven.scm.ScmFileSet;
 25  
 import org.apache.maven.scm.ScmVersion;
 26  
 import org.apache.maven.scm.command.add.AddScmResult;
 27  
 import org.apache.maven.scm.command.blame.BlameScmResult;
 28  
 import org.apache.maven.scm.command.branch.BranchScmResult;
 29  
 import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
 30  
 import org.apache.maven.scm.command.checkin.CheckInScmResult;
 31  
 import org.apache.maven.scm.command.checkout.CheckOutScmResult;
 32  
 import org.apache.maven.scm.command.diff.DiffScmResult;
 33  
 import org.apache.maven.scm.command.edit.EditScmResult;
 34  
 import org.apache.maven.scm.command.export.ExportScmResult;
 35  
 import org.apache.maven.scm.command.list.ListScmResult;
 36  
 import org.apache.maven.scm.command.mkdir.MkdirScmResult;
 37  
 import org.apache.maven.scm.command.remove.RemoveScmResult;
 38  
 import org.apache.maven.scm.command.status.StatusScmResult;
 39  
 import org.apache.maven.scm.command.tag.TagScmResult;
 40  
 import org.apache.maven.scm.command.unedit.UnEditScmResult;
 41  
 import org.apache.maven.scm.command.update.UpdateScmResult;
 42  
 import org.apache.maven.scm.provider.ScmProvider;
 43  
 import org.apache.maven.scm.provider.ScmProviderStub;
 44  
 import org.apache.maven.scm.repository.ScmRepository;
 45  
 import org.apache.maven.scm.repository.ScmRepositoryException;
 46  
 import org.apache.maven.scm.repository.ScmRepositoryStub;
 47  
 import org.apache.maven.scm.repository.UnknownRepositoryStructure;
 48  
 
 49  
 import java.io.File;
 50  
 import java.util.ArrayList;
 51  
 import java.util.Date;
 52  
 import java.util.List;
 53  
 
 54  
 /**
 55  
  * Stub implementation of ScmManager for unit testing purposes. 
 56  
  * It allows setting the expected results that the different methods will return.
 57  
  * More information about Stubs on <a href="http://martinfowler.com/bliki/TestDouble.html">Martin Fowler's TestDouble</a>
 58  
  *
 59  
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
 60  
  * @version $Id: ScmManagerStub.java 1058791 2011-01-13 23:18:20Z olamy $
 61  
  */
 62  
 public class ScmManagerStub
 63  
     implements ScmManager
 64  
 {
 65  
 
 66  
     private ScmRepository scmRepository;
 67  
 
 68  
     private ScmProvider scmProvider;
 69  
 
 70  
     private List<String> messages;
 71  
 
 72  
     /**
 73  
      * Creates a new stub with stub repository and provider, and empty list of messages
 74  
      */
 75  
     public ScmManagerStub()
 76  6
     {
 77  6
         setScmRepository( new ScmRepositoryStub() );
 78  6
         setScmProvider( new ScmProviderStub() );
 79  6
         setMessages( new ArrayList<String>( 0 ) );
 80  6
     }
 81  
 
 82  
     public void setScmProvider( ScmProvider scmProvider )
 83  
     {
 84  12
         this.scmProvider = scmProvider;
 85  12
     }
 86  
 
 87  
     public ScmProvider getScmProvider()
 88  
     {
 89  3
         return scmProvider;
 90  
     }
 91  
 
 92  
     /** {@inheritDoc} */
 93  
     public void setScmProvider( String providerType, ScmProvider provider )
 94  
     {
 95  0
         setScmProvider( provider );
 96  0
     }
 97  
 
 98  
     /** {@inheritDoc} */
 99  
     public void setScmProviderImplementation( String providerType, String providerImplementation )
 100  
     {
 101  
         //Do nothing there
 102  0
     }
 103  
 
 104  
     public void setScmRepository( ScmRepository scmRepository )
 105  
     {
 106  12
         this.scmRepository = scmRepository;
 107  12
     }
 108  
 
 109  
     public ScmRepository getScmRepository()
 110  
     {
 111  2
         return scmRepository;
 112  
     }
 113  
 
 114  
     /**
 115  
      * Set the messages to return in validateScmRepository
 116  
      *
 117  
      * @param messages <code>List</code> of <code>String</code> objects
 118  
      */
 119  
     public void setMessages( List<String> messages )
 120  
     {
 121  12
         this.messages = messages;
 122  12
     }
 123  
 
 124  
     /**
 125  
      * Get the messages to return in validateScmRepository
 126  
      *
 127  
      * @return <code>List</code> of <code>String</code> objects
 128  
      */
 129  
     public List<String> getMessages()
 130  
     {
 131  1
         return messages;
 132  
     }
 133  
 
 134  
     /** {@inheritDoc} */
 135  
     public ScmRepository makeScmRepository( String scmUrl )
 136  
         throws ScmRepositoryException, NoSuchScmProviderException
 137  
     {
 138  1
         return getScmRepository();
 139  
     }
 140  
 
 141  
     /** {@inheritDoc} */
 142  
     public ScmRepository makeProviderScmRepository( String providerType, File path )
 143  
         throws ScmRepositoryException, UnknownRepositoryStructure, NoSuchScmProviderException
 144  
     {
 145  1
         return getScmRepository();
 146  
     }
 147  
 
 148  
     /**
 149  
      * Returns the same list as getMessages()
 150  
      *
 151  
      * @param scmUrl ignored
 152  
      * @return <code>List</code> of <code>String</code> objects, the same list returned by getMessages()
 153  
      */
 154  
     public List<String> validateScmRepository( String scmUrl )
 155  
     {
 156  1
         return getMessages();
 157  
     }
 158  
 
 159  
     /** {@inheritDoc} */
 160  
     public ScmProvider getProviderByUrl( String scmUrl )
 161  
         throws ScmRepositoryException, NoSuchScmProviderException
 162  
     {
 163  1
         return getScmProvider();
 164  
     }
 165  
 
 166  
     /** {@inheritDoc} */
 167  
     public ScmProvider getProviderByType( String providerType )
 168  
         throws NoSuchScmProviderException
 169  
     {
 170  1
         return getScmProvider();
 171  
     }
 172  
 
 173  
     /** {@inheritDoc} */
 174  
     public ScmProvider getProviderByRepository( ScmRepository repository )
 175  
         throws NoSuchScmProviderException
 176  
     {
 177  1
         return getScmProvider();
 178  
     }
 179  
 
 180  
     /** {@inheritDoc} */
 181  
     public AddScmResult add( ScmRepository repository, ScmFileSet fileSet )
 182  
         throws ScmException
 183  
     {
 184  0
         return this.getProviderByRepository( repository ).add( repository, fileSet );
 185  
     }
 186  
 
 187  
     /** {@inheritDoc} */
 188  
     public AddScmResult add( ScmRepository repository, ScmFileSet fileSet, String message )
 189  
         throws ScmException
 190  
     {
 191  0
         return this.getProviderByRepository( repository ).add( repository, fileSet, message );
 192  
     }
 193  
 
 194  
     /** {@inheritDoc} */
 195  
     @SuppressWarnings( "deprecation" )
 196  
     public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName )
 197  
         throws ScmException
 198  
     {
 199  0
         return this.getProviderByRepository( repository ).branch( repository, fileSet, branchName );
 200  
     }
 201  
 
 202  
     /** {@inheritDoc} */
 203  
     @SuppressWarnings( "deprecation" )
 204  
     public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, String message )
 205  
         throws ScmException
 206  
     {
 207  0
         return this.getProviderByRepository( repository ).branch( repository, fileSet, branchName, message );
 208  
     }
 209  
 
 210  
     /** {@inheritDoc} */
 211  
     public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate,
 212  
                                          int numDays, ScmBranch branch )
 213  
         throws ScmException
 214  
     {
 215  0
         return this.getProviderByRepository( repository ).changeLog( repository, fileSet, startDate, endDate, numDays,
 216  
                                                                      branch );
 217  
     }
 218  
 
 219  
     /** {@inheritDoc} */
 220  
     public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate,
 221  
                                          int numDays, ScmBranch branch, String datePattern )
 222  
         throws ScmException
 223  
     {
 224  0
         return this.getProviderByRepository( repository ).changeLog( repository, fileSet, startDate, endDate, numDays,
 225  
                                                                      branch, datePattern );
 226  
     }
 227  
 
 228  
     /** {@inheritDoc} */
 229  
     public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion,
 230  
                                          ScmVersion endVersion )
 231  
         throws ScmException
 232  
     {
 233  0
         return this.getProviderByRepository( repository ).changeLog( repository, fileSet, startVersion, endVersion );
 234  
     }
 235  
 
 236  
     /** {@inheritDoc} */
 237  
     public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startRevision,
 238  
                                          ScmVersion endRevision, String datePattern )
 239  
         throws ScmException
 240  
     {
 241  0
         return this.getProviderByRepository( repository ).changeLog( repository, fileSet, startRevision, endRevision,
 242  
                                                                      datePattern );
 243  
     }
 244  
 
 245  
     /** {@inheritDoc} */
 246  
     public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String message )
 247  
         throws ScmException
 248  
     {
 249  0
         return this.getProviderByRepository( repository ).checkIn( repository, fileSet, message );
 250  
     }
 251  
 
 252  
     /** {@inheritDoc} */
 253  
     public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, ScmVersion revision, String message )
 254  
         throws ScmException
 255  
     {
 256  0
         return this.getProviderByRepository( repository ).checkIn( repository, fileSet, revision, message );
 257  
     }
 258  
 
 259  
     /** {@inheritDoc} */
 260  
     public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet )
 261  
         throws ScmException
 262  
     {
 263  0
         return this.getProviderByRepository( repository ).checkOut( repository, fileSet );
 264  
     }
 265  
 
 266  
     /** {@inheritDoc} */
 267  
     public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion version )
 268  
         throws ScmException
 269  
     {
 270  0
         return this.getProviderByRepository( repository ).checkOut( repository, fileSet, version );
 271  
     }
 272  
 
 273  
     /** {@inheritDoc} */
 274  
     public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, boolean recursive )
 275  
         throws ScmException
 276  
     {
 277  0
         return this.getProviderByRepository( repository ).checkOut( repository, fileSet, recursive );
 278  
     }
 279  
 
 280  
     /** {@inheritDoc} */
 281  
     public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion version,
 282  
                                        boolean recursive )
 283  
         throws ScmException
 284  
     {
 285  0
         return this.getProviderByRepository( repository ).checkOut( repository, fileSet, version, recursive );
 286  
     }
 287  
 
 288  
     /** {@inheritDoc} */
 289  
     public DiffScmResult diff( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion,
 290  
                                ScmVersion endVersion )
 291  
         throws ScmException
 292  
     {
 293  0
         return this.getProviderByRepository( repository ).diff( repository, fileSet, startVersion, endVersion );
 294  
     }
 295  
 
 296  
     /** {@inheritDoc} */
 297  
     public EditScmResult edit( ScmRepository repository, ScmFileSet fileSet )
 298  
         throws ScmException
 299  
     {
 300  0
         return this.getProviderByRepository( repository ).edit( repository, fileSet );
 301  
     }
 302  
 
 303  
     /** {@inheritDoc} */
 304  
     public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet )
 305  
         throws ScmException
 306  
     {
 307  0
         return this.getProviderByRepository( repository ).export( repository, fileSet );
 308  
     }
 309  
 
 310  
     /** {@inheritDoc} */
 311  
     public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion version )
 312  
         throws ScmException
 313  
     {
 314  0
         return this.getProviderByRepository( repository ).export( repository, fileSet, version );
 315  
     }
 316  
 
 317  
     /** {@inheritDoc} */
 318  
     public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String outputDirectory )
 319  
         throws ScmException
 320  
     {
 321  0
         return this.export( repository, fileSet, outputDirectory );
 322  
     }
 323  
 
 324  
     /** {@inheritDoc} */
 325  
     public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion version,
 326  
                                    String outputDirectory )
 327  
         throws ScmException
 328  
     {
 329  0
         return this.getProviderByRepository( repository ).export( repository, fileSet, version, outputDirectory );
 330  
     }
 331  
 
 332  
     /** {@inheritDoc} */
 333  
     public ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion version )
 334  
         throws ScmException
 335  
     {
 336  0
         return this.getProviderByRepository( repository ).list( repository, fileSet, recursive, version );
 337  
     }
 338  
 
 339  
     /** {@inheritDoc} */
 340  
     public RemoveScmResult remove( ScmRepository repository, ScmFileSet fileSet, String message )
 341  
         throws ScmException
 342  
     {
 343  0
         return this.getProviderByRepository( repository ).remove( repository, fileSet, message );
 344  
     }
 345  
 
 346  
     /** {@inheritDoc} */
 347  
     public StatusScmResult status( ScmRepository repository, ScmFileSet fileSet )
 348  
         throws ScmException
 349  
     {
 350  0
         return this.getProviderByRepository( repository ).status( repository, fileSet );
 351  
     }
 352  
 
 353  
     /** {@inheritDoc} */
 354  
     @SuppressWarnings( "deprecation" )
 355  
     public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName )
 356  
         throws ScmException
 357  
     {
 358  0
         return this.getProviderByRepository( repository ).tag( repository, fileSet, tagName );
 359  
     }
 360  
 
 361  
     /** {@inheritDoc} */
 362  
     @SuppressWarnings( "deprecation" )
 363  
     public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, String message )
 364  
         throws ScmException
 365  
     {
 366  0
         return this.getProviderByRepository( repository ).tag( repository, fileSet, tagName, message );
 367  
     }
 368  
 
 369  
     /** {@inheritDoc} */
 370  
     public UnEditScmResult unedit( ScmRepository repository, ScmFileSet fileSet )
 371  
         throws ScmException
 372  
     {
 373  0
         return this.getProviderByRepository( repository ).unedit( repository, fileSet );
 374  
     }
 375  
 
 376  
     /** {@inheritDoc} */
 377  
     public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet )
 378  
         throws ScmException
 379  
     {
 380  0
         return this.getProviderByRepository( repository ).update( repository, fileSet );
 381  
     }
 382  
 
 383  
     /** {@inheritDoc} */
 384  
     public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version )
 385  
         throws ScmException
 386  
     {
 387  0
         return this.getProviderByRepository( repository ).update( repository, fileSet, version );
 388  
     }
 389  
 
 390  
     /** {@inheritDoc} */
 391  
     public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, boolean runChangelog )
 392  
         throws ScmException
 393  
     {
 394  0
         return this.getProviderByRepository( repository ).update( repository, fileSet, runChangelog );
 395  
     }
 396  
 
 397  
     /** {@inheritDoc} */
 398  
     public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version,
 399  
                                    boolean runChangelog )
 400  
         throws ScmException
 401  
     {
 402  0
         return this.getProviderByRepository( repository ).update( repository, fileSet, version, runChangelog );
 403  
     }
 404  
 
 405  
     /** {@inheritDoc} */
 406  
     public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String datePattern )
 407  
         throws ScmException
 408  
     {
 409  0
         return this.getProviderByRepository( repository ).update( repository, fileSet, (ScmVersion) null, datePattern );
 410  
     }
 411  
 
 412  
     /** {@inheritDoc} */
 413  
     public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version,
 414  
                                    String datePattern )
 415  
         throws ScmException
 416  
     {
 417  0
         return this.getProviderByRepository( repository ).update( repository, fileSet, version, datePattern );
 418  
     }
 419  
 
 420  
     /** {@inheritDoc} */
 421  
     public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Date lastUpdate )
 422  
         throws ScmException
 423  
     {
 424  0
         return this.getProviderByRepository( repository ).update( repository, fileSet, (ScmVersion) null, lastUpdate );
 425  
     }
 426  
 
 427  
     /** {@inheritDoc} */
 428  
     public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate )
 429  
         throws ScmException
 430  
     {
 431  0
         return this.getProviderByRepository( repository ).update( repository, fileSet, version, lastUpdate );
 432  
     }
 433  
 
 434  
     /** {@inheritDoc} */
 435  
     public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, Date lastUpdate, String datePattern )
 436  
         throws ScmException
 437  
     {
 438  0
         return this.getProviderByRepository( repository ).update( repository, fileSet, (ScmVersion) null, lastUpdate,
 439  
                                                                   datePattern );
 440  
     }
 441  
 
 442  
     /** {@inheritDoc} */
 443  
     public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion version, Date lastUpdate,
 444  
                                    String datePattern )
 445  
         throws ScmException
 446  
     {
 447  0
         return this.getProviderByRepository( repository ).update( repository, fileSet, version, lastUpdate,
 448  
                                                                   datePattern );
 449  
     }
 450  
 
 451  
     /** {@inheritDoc} */
 452  
     public BlameScmResult blame( ScmRepository repository, ScmFileSet fileSet, String filename )
 453  
         throws ScmException
 454  
     {
 455  0
         return this.getProviderByRepository( repository ).blame( repository, fileSet, filename );
 456  
     }
 457  
 
 458  
     /** {@inheritDoc} */
 459  
     public MkdirScmResult mkdir( ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal )
 460  
         throws ScmException
 461  
     {  
 462  0
         return this.getProviderByRepository( repository ).mkdir( repository, fileSet, message, createInLocal );
 463  
     }
 464  
 }