Class ScmProviderStub

  • All Implemented Interfaces:
    ScmProvider

    public class ScmProviderStub
    extends java.lang.Object
    implements ScmProvider
    Stub implementation of ScmProvider for unit testing purposes. It allows setting the expected results that the different methods will return. More information about Stubs on Martin Fowler's TestDouble
    • Constructor Detail

      • ScmProviderStub

        public ScmProviderStub()
        Create a new ScmProviderStub with bogus (not null) attributes
    • Method Detail

      • sanitizeTagName

        public java.lang.String sanitizeTagName​(java.lang.String tag)
        Given a tag name, make it suitable for this SCM provider. For example, CVS converts "." into "_"
        Specified by:
        sanitizeTagName in interface ScmProvider
        Parameters:
        tag - input tag name
        Returns:
        sanitized tag name
      • validateTagName

        public boolean validateTagName​(java.lang.String tag)
        Check if this tag is valid for this SCM provider.
        Specified by:
        validateTagName in interface ScmProvider
        Parameters:
        tag - tag name to check
        Returns:
        true if tag is valid
      • setScmSpecificFilename

        public void setScmSpecificFilename​(java.lang.String scmSpecificFilename)
      • addListener

        public void addListener​(ScmLogger logger)
        Add a logger listener.
        Specified by:
        addListener in interface ScmProvider
        Parameters:
        logger - The logger
      • setAddScmResult

        public void setAddScmResult​(AddScmResult addScmResult)
      • setBranchScmResult

        public void setBranchScmResult​(BranchScmResult branchScmResult)
      • setCheckInScmResult

        public void setCheckInScmResult​(CheckInScmResult checkInScmResult)
      • setCheckOutScmResult

        public void setCheckOutScmResult​(CheckOutScmResult checkOutScmResult)
      • setChangeLogScmResult

        public void setChangeLogScmResult​(ChangeLogScmResult changeLogScmResult)
      • setDiffScmResult

        public void setDiffScmResult​(DiffScmResult diffScmResult)
      • setExportScmResult

        public void setExportScmResult​(ExportScmResult exportScmResult)
      • setTagScmResult

        public void setTagScmResult​(TagScmResult tagScmResult)
      • setUntagScmResult

        public void setUntagScmResult​(UntagScmResult untagScmResult)
      • setRemoveScmResult

        public void setRemoveScmResult​(RemoveScmResult removeScmResult)
      • setStatusScmResult

        public void setStatusScmResult​(StatusScmResult statusScmResult)
      • setUpdateScmResult

        public void setUpdateScmResult​(UpdateScmResult updateScmResult)
      • setEditScmResult

        public void setEditScmResult​(EditScmResult editScmResult)
      • setUnEditScmResult

        public void setUnEditScmResult​(UnEditScmResult unEditScmResult)
      • setListScmResult

        public void setListScmResult​(ListScmResult listScmResult)
      • setBlameScmResult

        public void setBlameScmResult​(BlameScmResult blameScmResult)
      • setMkdirScmResult

        public void setMkdirScmResult​(MkdirScmResult mkdirScmResult)
      • validateScmUrl

        public java.util.List<java.lang.String> validateScmUrl​(java.lang.String scmSpecificUrl,
                                                               char delimiter)
        Validate the scm url.
        Specified by:
        validateScmUrl in interface ScmProvider
        Parameters:
        scmSpecificUrl - The SCM url
        delimiter - The delimiter used in the SCM url
        Returns:
        Returns a list of messages if the validation failed
      • getScmSpecificFilename

        public java.lang.String getScmSpecificFilename()
        Returns the scm reserved file name where the SCM stores information like 'CVS', '.svn'.
        Specified by:
        getScmSpecificFilename in interface ScmProvider
        Returns:
        the scm reserved file name
      • add

        public AddScmResult add​(ScmRepository repository,
                                ScmFileSet fileSet,
                                java.lang.String message)
                         throws ScmException
        Adds the given files to the source control system
        Specified by:
        add in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to be added
        message - a string that is a comment on the new added file
        Returns:
        an AddScmResult that contains the files that have been added
        Throws:
        ScmException - if any
      • branch

        public BranchScmResult branch​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.lang.String branchName)
                               throws ScmException
        Branch (or label in some systems) will create a branch of the source file with a certain branch name
        Specified by:
        branch in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to branch. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        branchName - the branch name to apply to the files
        Returns:
        Throws:
        ScmException - if any
      • branch

        public BranchScmResult branch​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.lang.String branchName,
                                      java.lang.String message)
                               throws ScmException
        Branch (or label in some systems) will create a branch of the source file with a certain branch name
        Specified by:
        branch in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to branch. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        branchName - the branch name to apply to the files
        message - the commit message used for the tag creation
        Returns:
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ScmRepository repository,
                                            ScmFileSet fileSet,
                                            java.util.Date startDate,
                                            java.util.Date endDate,
                                            int numDays,
                                            java.lang.String branch)
                                     throws ScmException
        Returns the changes that have happened in the source control system in a certain period of time. This can be adding, removing, updating, ... of files
        Specified by:
        changeLog in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to know the changes about. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        startDate - the start date of the period
        endDate - the end date of the period
        numDays - the number days before the current time if startdate and enddate are null
        branch - the branch/tag name
        Returns:
        The SCM result of the changelog command
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ScmRepository repository,
                                            ScmFileSet fileSet,
                                            java.util.Date startDate,
                                            java.util.Date endDate,
                                            int numDays,
                                            java.lang.String branch,
                                            java.lang.String datePattern)
                                     throws ScmException
        Returns the changes that have happened in the source control system in a certain period of time. This can be adding, removing, updating, ... of files
        Specified by:
        changeLog in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to know the changes about. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        startDate - the start date of the period
        endDate - the end date of the period
        numDays - the number days before the current time if startdate and enddate are null
        branch - the branch/tag name
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        The SCM result of the changelog command
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ScmRepository repository,
                                            ScmFileSet fileSet,
                                            java.lang.String startTag,
                                            java.lang.String endTag)
                                     throws ScmException
        Returns the changes that have happened in the source control system between two tags. This can be adding, removing, updating, ... of files
        Specified by:
        changeLog in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to know the changes about. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        startTag - the start tag
        endTag - the end tag
        Returns:
        The SCM result of the changelog command
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ScmRepository repository,
                                            ScmFileSet fileSet,
                                            java.lang.String startTag,
                                            java.lang.String endTag,
                                            java.lang.String datePattern)
                                     throws ScmException
        Returns the changes that have happened in the source control system between two tags. This can be adding, removing, updating, ... of files
        Specified by:
        changeLog in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to know the changes about. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        startTag - the start tag
        endTag - the end tag
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ScmRepository repository,
                                            ScmFileSet fileSet,
                                            java.util.Date startDate,
                                            java.util.Date endDate,
                                            int numDays,
                                            ScmBranch branch)
                                     throws ScmException
        Returns the changes that have happened in the source control system in a certain period of time. This can be adding, removing, updating, ... of files
        Specified by:
        changeLog in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to know the changes about. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        startDate - the start date of the period
        endDate - the end date of the period
        numDays - the number days before the current time if startdate and enddate are null
        branch - the branch/tag
        Returns:
        The SCM result of the changelog command
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ScmRepository repository,
                                            ScmFileSet fileSet,
                                            java.util.Date startDate,
                                            java.util.Date endDate,
                                            int numDays,
                                            ScmBranch branch,
                                            java.lang.String datePattern)
                                     throws ScmException
        Returns the changes that have happened in the source control system in a certain period of time. This can be adding, removing, updating, ... of files
        Specified by:
        changeLog in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to know the changes about. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        startDate - the start date of the period
        endDate - the end date of the period
        numDays - the number days before the current time if startDate and endDate are null
        branch - the branch/tag
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        The SCM result of the changelog command
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ChangeLogScmRequest scmRequest)
                                     throws ScmException
        Description copied from interface: ScmProvider
        Returns the changes that have happened in the source control system in a certain period of time. This can be adding, removing, updating, ... of files
        Specified by:
        changeLog in interface ScmProvider
        Parameters:
        scmRequest - request wrapping detailed parameters for the changelog command
        Returns:
        The SCM result of the changelog command
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ScmRepository repository,
                                            ScmFileSet fileSet,
                                            ScmVersion startVersion,
                                            ScmVersion endVersion)
                                     throws ScmException
        Returns the changes that have happened in the source control system between two tags. This can be adding, removing, updating, ... of files
        Specified by:
        changeLog in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to know the changes about. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        startVersion - the start branch/tag/revision
        endVersion - the end branch/tag/revision
        Returns:
        The SCM result of the changelog command
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ScmRepository repository,
                                            ScmFileSet fileSet,
                                            ScmVersion startRevision,
                                            ScmVersion endRevision,
                                            java.lang.String datePattern)
                                     throws ScmException
        Returns the changes that have happened in the source control system between two tags. This can be adding, removing, updating, ... of files
        Specified by:
        changeLog in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to know the changes about. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        startRevision - the start revision
        endRevision - the end revision
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        Throws:
        ScmException - if any
      • checkIn

        public CheckInScmResult checkIn​(ScmRepository repository,
                                        ScmFileSet fileSet,
                                        java.lang.String tag,
                                        java.lang.String message)
                                 throws ScmException
        Save the changes you have done into the repository. This will create a new version of the file or directory in the repository.

        When the fileSet has no entries, the fileSet.getBaseDir() is recursively committed. When the fileSet has entries, the commit is non-recursive and only the elements in the fileSet are committed.

        Specified by:
        checkIn in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to check in (sometimes called commit)
        tag - tag or revision
        message - a string that is a comment on the changes that where done
        Returns:
        Throws:
        ScmException - if any
      • checkIn

        public CheckInScmResult checkIn​(ScmRepository repository,
                                        ScmFileSet fileSet,
                                        java.lang.String message)
                                 throws ScmException
        Save the changes you have done into the repository. This will create a new version of the file or directory in the repository.

        When the fileSet has no entries, the fileSet.getBaseDir() is recursively committed. When the fileSet has entries, the commit is non-recursive and only the elements in the fileSet are committed.

        Specified by:
        checkIn in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to check in (sometimes called commit)
        message - a string that is a comment on the changes that where done
        Returns:
        Throws:
        ScmException - if any
      • checkIn

        public CheckInScmResult checkIn​(ScmRepository repository,
                                        ScmFileSet fileSet,
                                        ScmVersion revision,
                                        java.lang.String message)
                                 throws ScmException
        Save the changes you have done into the repository. This will create a new version of the file or directory in the repository.

        When the fileSet has no entries, the fileSet.getBaseDir() is recursively committed. When the fileSet has entries, the commit is non-recursive and only the elements in the fileSet are committed.

        Specified by:
        checkIn in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to check in (sometimes called commit)
        revision - branch/tag/revision
        message - a string that is a comment on the changes that where done
        Returns:
        Throws:
        ScmException - if any
      • edit

        public EditScmResult edit​(ScmRepository repository,
                                  ScmFileSet fileSet)
                           throws ScmException
        Make a file editable. This is used in source control systems where you look at read-only files and you need to make them not read-only anymore before you can edit them. This can also mean that no other user in the system can make the file not read-only anymore.
        Specified by:
        edit in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to make editable
        Returns:
        Throws:
        ScmException - if any
      • export

        public ExportScmResult export​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.lang.String tag,
                                      java.lang.String outputDirectory)
                               throws ScmException
        Create an exported copy of the repository on your local machine
        Specified by:
        export in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files are copied to the ScmFileSet.getBasedir() location
        tag - get the version defined by the tag
        outputDirectory - the directory where the export will be stored
        Returns:
        Throws:
        ScmException - if any
      • export

        public ExportScmResult export​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      ScmVersion version,
                                      java.lang.String outputDirectory)
                               throws ScmException
        Create an exported copy of the repository on your local machine
        Specified by:
        export in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files are copied to the ScmFileSet.getBasedir() location
        version - get the version defined by the branch/tag/revision
        outputDirectory - the directory where the export will be stored
        Returns:
        Throws:
        ScmException - if any
      • list

        public ListScmResult list​(ScmRepository repository,
                                  ScmFileSet fileSet,
                                  boolean recursive,
                                  java.lang.String tag)
                           throws ScmException
        List each element (files and directories) of fileSet as they exist in the repository.
        Specified by:
        list in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to list
        recursive - descend recursively
        tag - use the version defined by the tag
        Returns:
        the list of files in the repository
        Throws:
        ScmException
      • list

        public ListScmResult list​(ScmRepository repository,
                                  ScmFileSet fileSet,
                                  boolean recursive,
                                  ScmVersion version)
                           throws ScmException
        List each element (files and directories) of fileSet as they exist in the repository.
        Specified by:
        list in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to list
        recursive - descend recursively
        version - use the version defined by the branch/tag/revision
        Returns:
        the list of files in the repository
        Throws:
        ScmException - if any
      • tag

        public TagScmResult tag​(ScmRepository repository,
                                ScmFileSet fileSet,
                                java.lang.String tag)
                         throws ScmException
        Tag (or label in some systems) will tag the source file with a certain tag
        Specified by:
        tag in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to tag. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        tag - the tag name to apply to the files
        Returns:
        Throws:
        ScmException - if any
      • tag

        public TagScmResult tag​(ScmRepository repository,
                                ScmFileSet fileSet,
                                java.lang.String tag,
                                java.lang.String message)
                         throws ScmException
        Tag (or label in some systems) will tag the source file with a certain tag
        Specified by:
        tag in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - the files to tag. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        tag - the tag name to apply to the files
        message - the commit message used for the tag creation
        Returns:
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.lang.String tag)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository
        Specified by:
        update in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        tag - use the version defined by the tag
        Returns:
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.lang.String tag,
                                      boolean runChangelog)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository
        Specified by:
        update in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        tag - use the version defined by the tag
        runChangelog - Run the changelog command after the update
        Returns:
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.lang.String tag,
                                      java.lang.String datePattern)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository
        Specified by:
        update in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        tag - use the version defined by the tag
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.lang.String tag,
                                      java.util.Date lastUpdate)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository
        Specified by:
        update in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        tag - use the version defined by the tag
        Returns:
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.lang.String tag,
                                      java.util.Date lastUpdate,
                                      java.lang.String datePattern)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository
        Specified by:
        update in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        tag - use the version defined by the tag
        lastUpdate - Date of last update
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      boolean runChangelog)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository
        Specified by:
        update in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        runChangelog - Run the changelog command after the update
        Returns:
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      ScmVersion version,
                                      boolean runChangelog)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository
        Specified by:
        update in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        version - use the version defined by the branch/tag/revision
        runChangelog - Run the changelog command after the update
        Returns:
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      ScmVersion version,
                                      java.lang.String datePattern)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository
        Specified by:
        update in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        version - use the version defined by the branch/tag/revision
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      ScmVersion version,
                                      java.util.Date lastUpdate)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository
        Specified by:
        update in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        version - use the version defined by the branch/tag/revision
        Returns:
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      ScmVersion version,
                                      java.util.Date lastUpdate,
                                      java.lang.String datePattern)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository
        Specified by:
        update in interface ScmProvider
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        version - use the version defined by the branch/tag/revision
        lastUpdate - Date of last update
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        Throws:
        ScmException - if any