Class MockVcsModification
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.MockVcsModification
-
- All Implemented Interfaces:
Comparable<VcsModification>,ChangeDescriptor,VcsModificationEx,Modification,SVcsModification,VcsModification
- Direct Known Subclasses:
MockVcsModificationWithId
public class MockVcsModification extends Object implements VcsModificationEx
-
-
Field Summary
Fields Modifier and Type Field Description List<VcsFileModification>myChangesDatemyDateStringmyDecriptionStringmyUser
-
Constructor Summary
Constructors Constructor Description MockVcsModification(String user, String decription, Date date)MockVcsModification(String user, String decription, Date date, String version)MockVcsModification(String user, String decription, Date date, String version, Collection<SBuildType> relatedConfigurations)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChange(VcsChange vcsChange)intcompareTo(VcsModification o)voidconsumeEdgeRelations(BiConsumer<Integer,RelatedConfigurations> consumer)voidconsumeRelations(BiConsumer<String,RelationType> consumer)Calls the specified consumer, pass it buildType internalId and relation as argumentsvoidconsumeRelations(BuildTypeIds btIds, BiConsumer<String,RelationType> consumer)Same asVcsModificationEx.consumeRelations(BiConsumer)but calls the consumer only if a build type id belogs to the ids specified as the first argumentBuildTypeIdsstatic MockVcsModificationcreateWithOneChangedFile(String user, String description, Date date)static MockVcsModificationcreateWithoutFiles(String user, String description, Date date)voiddetachedFromConfigurations(Collection<String> btIds)VcsFileModificationfindChangeByPath(String fileName)Find file modification corresponding to given fileName, may be null.Map<String,Object>getAssociatedData()Map<String,String>getAttributes()Returns modification's attributes or empty map if modification doesn't have any.Map<SBuildType,RelationType>getBuildTypeRelations()intgetChangeCount()Return number of files changed in this modificationList<VcsFileModification>getChanges()Returns list of file modifications related to the changeDategetCommitDate()Returns date, when this modification was last updated (e.g.StringgetCommiterName()Returns user who last updated this modification (e.g.List<Long>getCommitterIds()Returns ids of TeamCity users mapped to this VCS modification by VCS username.Collection<SUser>getCommitters()byte[]getContentAfter(VcsChangeInfo change)byte[]getContentBefore(VcsChangeInfo change)VcsModificationContextgetContext()DategetDate()StringgetDescription()Returns user comment made for the changeStringgetDisplayVersion()Collection<SVcsModification>getDuplicates()Returns duplicates of this VCS modification, (the given modification is not included)List<FilteredVcsChange>getFilteredChanges(BuildPromotion buildPromotion)Returns list of changed files filtered according to checkout rules of the specified build promotionList<FilteredVcsChange>getFilteredChanges(SBuild build)Returns list of changed files filtered according to checkout rules of the specified buildList<FilteredVcsChange>getFilteredChanges(SBuildType buildType)Returns list of changed files filtered according to checkout rules of the specified build configurationList<FilteredVcsChange>getFilteredChanges(CheckoutRules rules)Returns list of changed files filtered according to given checkout rules.Map<SBuildType,SBuild>getFirstBuilds()For non-personal builds, returns map of build configuration -> build where this modification was included for the first time.longgetId()Unique identifier for the modificationintgetNumberOfRelatedConfigurations()Returns number of build configurations where this modification appeared.Collection<SVcsModification>getParentModifications()Returns parent modifications of this VCS modification.Collection<String>getParentRevisions()Returns parent revisions for modifications from dag-based VCSes as they were reported by a VCS plugin.PersonalChangeDescriptorgetPersonalChangeInfo()For personal changes, returns personal change information details.SProjectgetProject()Set<String>getReachableVcsBranches()DategetRegistrationDate()Returns date of this VCS modification registration in the TeamCity server database.BuildTypeIdsgetRelatedBuildTypeIds()List<String>getRelatedConfigurationIds(boolean ignoreOverridden)Returns configurations ids this modification is related to.Collection<SBuildType>getRelatedConfigurations()Returns collection of build configurations where this modification appeared.Collection<Issue>getRelatedIssues()Returns the collection of issues related to this modification (fixed bugs, introduced features, etc).Collection<SProject>getRelatedProjects()SVcsModificationgetRelatedVcsChange()RelationTypegetRelation(String buildTypeId)List<RelationType>getRelationTypes()StringgetType()StringgetUserName()Returns name of the user who did this commit (according information from VCS system)DategetVcsDate()Returns when this modification was madeVcsRootInstancegetVcsRoot()For non-personal modifications returns VCS root where this modification occurred.StringgetVersion()StringgetVersionControlName()Return version control name as returned byVcsSupportConfig.getDisplayName(); for personal builds "Remote Run" string is returned.booleanhasRelation(SBuildType buildType, RelationType relation)Returns true if the given buildType has relation of the specified typebooleanisCanBeIgnored()booleanisCommitter(User user)Returns if the specified user is committer for the modification.booleanisDuplicateOf(SVcsModification modification)booleanisHasRelatedIssues()Returns whether the modification has related issues (fixed bugs, introduced features, etc).booleanisPersonal()Return true if this modification corresponds to personal change of personal build or pre-tested commitbooleanisRelatedTo(int parentNum, SBuildType buildType, Predicate<RelationType> relationPredicate)Returns true if the edge from the parentNum-th parent to this commit has a relation to the specified buildType accepted by the given predicatebooleanisRelatedTo(String buildTypeId, Predicate<RelationType> relationPredicate)booleanisRelatedTo(SBuildType buildType)booleanisRelatedTo(SBuildType buildType, boolean ignoreOverridden)booleanisRelatedTo(SBuildType buildType, Predicate<RelationType> relationPredicate)Returns true if this modification has a relation accepted by the specified relation predicate to the given buildTypevoidprocessRelations(BiProcessor<String,RelationType> processor)Same asVcsModificationEx.consumeRelations(BiConsumer)but allows to stop processing at any point of time.booleanrelatedConfigurationsLoaded()booleanrelatedToBuildConfigurationsAccessibleTo(AuthorityHolder authorityHolder)Returns true if the specified authority holder has read access to at least one build configuration where this VCS modification was detected.voidresetEdgeRelations()Resets edge relations of this modification.voidresetRelatedConfigurations()voidsetCanBeIgnored(boolean canBeIgnored)voidsetDescription(String newDescription)Set and store new description for the modification in the database.voidsetPesonal(boolean personal)MockVcsModificationsetRoot(VcsRootInstance root)voidsetVersion(String version)
-
-
-
Field Detail
-
myUser
public String myUser
-
myDecription
public String myDecription
-
myDate
public Date myDate
-
myChanges
public List<VcsFileModification> myChanges
-
-
Constructor Detail
-
MockVcsModification
public MockVcsModification(String user, String decription, Date date, String version)
-
MockVcsModification
public MockVcsModification(String user, String decription, Date date, String version, Collection<SBuildType> relatedConfigurations)
-
-
Method Detail
-
createWithOneChangedFile
public static MockVcsModification createWithOneChangedFile(String user, String description, Date date)
-
createWithoutFiles
public static MockVcsModification createWithoutFiles(String user, String description, Date date)
-
getUserName
public String getUserName()
Description copied from interface:ModificationReturns name of the user who did this commit (according information from VCS system)- Specified by:
getUserNamein interfaceModification- Returns:
- name of the user who did this commit (according information from VCS system)
-
getDescription
@NotNull public String getDescription()
Description copied from interface:ModificationReturns user comment made for the change- Specified by:
getDescriptionin interfaceChangeDescriptor- Specified by:
getDescriptionin interfaceModification- Returns:
- user comment made for the change
-
getVcsDate
@NotNull public Date getVcsDate()
Description copied from interface:ModificationReturns when this modification was made- Specified by:
getVcsDatein interfaceModification- Returns:
- when this modification was made
-
getCommitDate
@NotNull public Date getCommitDate()
Description copied from interface:SVcsModificationReturns date, when this modification was last updated (e.g. via git rebase) unlikeModification.getVcsDate(), which returns date when the modification was initially authored. Is more or equal toModification.getVcsDate().- Specified by:
getCommitDatein interfaceSVcsModification- Returns:
- date when this modification was last updated
-
getCommiterName
@NotNull public String getCommiterName()
Description copied from interface:VcsModificationExReturns user who last updated this modification (e.g. via git rebase, amend, patch apply) unlikeModification.getUserName(), which returns user who initially authored the modification.- Specified by:
getCommiterNamein interfaceVcsModificationEx- Returns:
- name of the user who last updated this modification (according to information from VCS system)
-
getContext
public VcsModificationContext getContext()
- Specified by:
getContextin interfaceVcsModificationEx
-
getChanges
@NotNull public List<VcsFileModification> getChanges()
Description copied from interface:VcsModificationReturns list of file modifications related to the change- Specified by:
getChangesin interfaceVcsModification- Returns:
- list of file modifications related to the change
-
findChangeByPath
public VcsFileModification findChangeByPath(String fileName)
Description copied from interface:VcsModificationFind file modification corresponding to given fileName, may be null. The fileName should exactly match the value fromVcsChangeInfo.getFileName()- Specified by:
findChangeByPathin interfaceVcsModification- Parameters:
fileName- name a file to search for- Returns:
- see above
-
getFirstBuilds
@NotNull public Map<SBuildType,SBuild> getFirstBuilds()
Description copied from interface:SVcsModificationFor non-personal builds, returns map of build configuration -> build where this modification was included for the first time. Cancelled and personal builds are ignored. For personal builds, returns a map from a buildType to the corresponding build which contains this personal change- Specified by:
getFirstBuildsin interfaceSVcsModification- Returns:
- see above
-
getChangeCount
public int getChangeCount()
Description copied from interface:VcsModificationReturn number of files changed in this modification- Specified by:
getChangeCountin interfaceVcsModification- Returns:
- see above
-
getVcsRoot
@NotNull public VcsRootInstance getVcsRoot()
Description copied from interface:SVcsModificationFor non-personal modifications returns VCS root where this modification occurred. For personal modifications throws UnsupportedOperationException because personal modification can be from several VCS roots simultaneously.- Specified by:
getVcsRootin interfaceSVcsModification- Returns:
- vcs root instance.
-
getContentBefore
@NotNull public byte[] getContentBefore(@NotNull VcsChangeInfo change) throws VcsException- Specified by:
getContentBeforein interfaceVcsModificationEx- Throws:
VcsException
-
getContentAfter
@NotNull public byte[] getContentAfter(@NotNull VcsChangeInfo change) throws VcsException- Specified by:
getContentAfterin interfaceVcsModificationEx- Throws:
VcsException
-
getRelatedConfigurationIds
@NotNull public List<String> getRelatedConfigurationIds(boolean ignoreOverridden)
Description copied from interface:VcsModificationExReturns configurations ids this modification is related to.- Specified by:
getRelatedConfigurationIdsin interfaceVcsModificationEx- Parameters:
ignoreOverridden- if true does not return configurations where this modification was attached via overridden root- Returns:
- sorted list of build configuration ids
-
isRelatedTo
public boolean isRelatedTo(@NotNull SBuildType buildType, boolean ignoreOverridden)- Specified by:
isRelatedToin interfaceVcsModificationEx
-
isRelatedTo
public boolean isRelatedTo(@NotNull SBuildType buildType, @NotNull Predicate<RelationType> relationPredicate)Description copied from interface:VcsModificationExReturns true if this modification has a relation accepted by the specified relation predicate to the given buildType- Specified by:
isRelatedToin interfaceVcsModificationEx- Parameters:
buildType- buildType of interestrelationPredicate- relation predicate- Returns:
- see above
-
isRelatedTo
public boolean isRelatedTo(@NotNull String buildTypeId, @NotNull Predicate<RelationType> relationPredicate)- Specified by:
isRelatedToin interfaceVcsModificationEx
-
getRelationTypes
@NotNull public List<RelationType> getRelationTypes()
- Specified by:
getRelationTypesin interfaceVcsModificationEx- Returns:
- all types of relations of build configurations associated with this change
-
isRelatedTo
public boolean isRelatedTo(int parentNum, @NotNull SBuildType buildType, @NotNull Predicate<RelationType> relationPredicate)Description copied from interface:VcsModificationExReturns true if the edge from the parentNum-th parent to this commit has a relation to the specified buildType accepted by the given predicate- Specified by:
isRelatedToin interfaceVcsModificationEx
-
hasRelation
public boolean hasRelation(@NotNull SBuildType buildType, @NotNull RelationType relation)Description copied from interface:SVcsModificationReturns true if the given buildType has relation of the specified type- Specified by:
hasRelationin interfaceSVcsModification- Parameters:
buildType- buildType of interestrelation- relation of interest- Returns:
- see above
-
isRelatedTo
public boolean isRelatedTo(@NotNull SBuildType buildType)- Specified by:
isRelatedToin interfaceVcsModificationEx- Parameters:
buildType- build configuration- Returns:
- true if this modification is attached to specified build configuration.
-
resetRelatedConfigurations
public void resetRelatedConfigurations()
- Specified by:
resetRelatedConfigurationsin interfaceVcsModificationEx
-
resetEdgeRelations
public void resetEdgeRelations()
Description copied from interface:VcsModificationExResets edge relations of this modification. Next call toVcsModificationEx.isRelatedTo(int, SBuildType, Predicate)will load them from db.- Specified by:
resetEdgeRelationsin interfaceVcsModificationEx
-
detachedFromConfigurations
public void detachedFromConfigurations(@NotNull Collection<String> btIds)- Specified by:
detachedFromConfigurationsin interfaceVcsModificationEx
-
getFilteredChanges
@NotNull public List<FilteredVcsChange> getFilteredChanges(@NotNull CheckoutRules rules)
Description copied from interface:VcsModificationExReturns list of changed files filtered according to given checkout rules.- Specified by:
getFilteredChangesin interfaceVcsModificationEx- Parameters:
rules- checkout rules to filter by.- Returns:
- list of filtered changed files.
-
getReachableVcsBranches
@NotNull public Set<String> getReachableVcsBranches()
- Specified by:
getReachableVcsBranchesin interfaceVcsModificationEx
-
consumeRelations
public void consumeRelations(@NotNull BiConsumer<String,RelationType> consumer)Description copied from interface:VcsModificationExCalls the specified consumer, pass it buildType internalId and relation as arguments- Specified by:
consumeRelationsin interfaceVcsModificationEx- Parameters:
consumer- consumer to call
-
consumeRelations
public void consumeRelations(@NotNull BuildTypeIds btIds, @NotNull BiConsumer<String,RelationType> consumer)Description copied from interface:VcsModificationExSame asVcsModificationEx.consumeRelations(BiConsumer)but calls the consumer only if a build type id belogs to the ids specified as the first argumentBuildTypeIds- Specified by:
consumeRelationsin interfaceVcsModificationExconsumer- consumer to call
-
processRelations
public void processRelations(@NotNull BiProcessor<String,RelationType> processor)Description copied from interface:VcsModificationExSame asVcsModificationEx.consumeRelations(BiConsumer)but allows to stop processing at any point of time.- Specified by:
processRelationsin interfaceVcsModificationEx
-
getRelation
@Nullable public RelationType getRelation(@NotNull String buildTypeId)
- Specified by:
getRelationin interfaceVcsModificationEx
-
consumeEdgeRelations
public void consumeEdgeRelations(@NotNull BiConsumer<Integer,RelatedConfigurations> consumer)- Specified by:
consumeEdgeRelationsin interfaceVcsModificationEx
-
relatedConfigurationsLoaded
public boolean relatedConfigurationsLoaded()
- Specified by:
relatedConfigurationsLoadedin interfaceVcsModificationEx- Returns:
- true if build configurations related to this change are loaded into the change internal cache
-
getRelatedBuildTypeIds
public BuildTypeIds getRelatedBuildTypeIds()
- Specified by:
getRelatedBuildTypeIdsin interfaceVcsModificationEx
-
isDuplicateOf
public boolean isDuplicateOf(@NotNull SVcsModification modification)- Specified by:
isDuplicateOfin interfaceVcsModificationEx- Returns:
- true if this modification is a duplicate of another one
-
getProject
public SProject getProject()
-
getId
public long getId()
Description copied from interface:VcsModificationUnique identifier for the modification- Specified by:
getIdin interfaceVcsModification- Returns:
- unique identifier of the modification
-
getVersion
@NotNull public String getVersion()
- Specified by:
getVersionin interfaceVcsModification
-
getDisplayVersion
public String getDisplayVersion()
- Specified by:
getDisplayVersionin interfaceVcsModification
-
addChange
public void addChange(VcsChange vcsChange)
-
isPersonal
public boolean isPersonal()
Description copied from interface:VcsModificationReturn true if this modification corresponds to personal change of personal build or pre-tested commit- Specified by:
isPersonalin interfaceVcsModification- Returns:
- true if this modification corresponds to personal change of personal build or pre-tested commit
-
getCommitterIds
@NotNull public List<Long> getCommitterIds()
Description copied from interface:SVcsModificationReturns ids of TeamCity users mapped to this VCS modification by VCS username.- Specified by:
getCommitterIdsin interfaceSVcsModification- Returns:
- ids of the committers to this change.
-
getCommitters
@NotNull public Collection<SUser> getCommitters()
- Specified by:
getCommittersin interfaceSVcsModification- Returns:
- collection of TeamCity users mapped to this VCS modification by VCS username.
-
getRelatedConfigurations
@NotNull public Collection<SBuildType> getRelatedConfigurations()
Description copied from interface:SVcsModificationReturns collection of build configurations where this modification appeared.- Specified by:
getRelatedConfigurationsin interfaceSVcsModification- Returns:
- collection of build configurations
-
getBuildTypeRelations
@NotNull public Map<SBuildType,RelationType> getBuildTypeRelations()
- Specified by:
getBuildTypeRelationsin interfaceSVcsModification- Returns:
- relations this modification has to build configurations
-
getRelatedProjects
@NotNull public Collection<SProject> getRelatedProjects()
- Specified by:
getRelatedProjectsin interfaceSVcsModification- Returns:
- returns collection of projects where this modification appeared.
-
getNumberOfRelatedConfigurations
public int getNumberOfRelatedConfigurations()
Description copied from interface:SVcsModificationReturns number of build configurations where this modification appeared.- Specified by:
getNumberOfRelatedConfigurationsin interfaceSVcsModification- Returns:
- number of build configurations where this modification appeared.
-
getFilteredChanges
@NotNull public List<FilteredVcsChange> getFilteredChanges(@NotNull SBuildType buildType)
Description copied from interface:SVcsModificationReturns list of changed files filtered according to checkout rules of the specified build configuration- Specified by:
getFilteredChangesin interfaceSVcsModification- Parameters:
buildType- build configuration- Returns:
- list of filtered changed files
-
getFilteredChanges
@NotNull public List<FilteredVcsChange> getFilteredChanges(@NotNull SBuild build)
Description copied from interface:SVcsModificationReturns list of changed files filtered according to checkout rules of the specified build- Specified by:
getFilteredChangesin interfaceSVcsModification- Parameters:
build- build- Returns:
- list of filtered changed files
-
getFilteredChanges
@NotNull public List<FilteredVcsChange> getFilteredChanges(@NotNull BuildPromotion buildPromotion)
Description copied from interface:SVcsModificationReturns list of changed files filtered according to checkout rules of the specified build promotion- Specified by:
getFilteredChangesin interfaceSVcsModification- Parameters:
buildPromotion- build promotion- Returns:
- list of filtered changed files
-
isCommitter
public boolean isCommitter(@NotNull User user)Description copied from interface:SVcsModificationReturns if the specified user is committer for the modification.- Specified by:
isCommitterin interfaceSVcsModification- Parameters:
user- specified user.- Returns:
- if the specified user is committer for the modification.
-
getVersionControlName
public String getVersionControlName()
Description copied from interface:VcsModificationReturn version control name as returned byVcsSupportConfig.getDisplayName(); for personal builds "Remote Run" string is returned.- Specified by:
getVersionControlNamein interfaceVcsModification- Returns:
- version control name
-
getRelatedIssues
@NotNull public Collection<Issue> getRelatedIssues()
Description copied from interface:SVcsModificationReturns the collection of issues related to this modification (fixed bugs, introduced features, etc).- Specified by:
getRelatedIssuesin interfaceSVcsModification- Returns:
- related issues
- See Also:
SVcsModification.isHasRelatedIssues()
-
isHasRelatedIssues
public boolean isHasRelatedIssues()
Description copied from interface:SVcsModificationReturns whether the modification has related issues (fixed bugs, introduced features, etc).- Specified by:
isHasRelatedIssuesin interfaceSVcsModification- Returns:
- true if the modification has related issues
- See Also:
SVcsModification.getRelatedIssues()
-
compareTo
public int compareTo(VcsModification o)
- Specified by:
compareToin interfaceComparable<VcsModification>
-
setRoot
public MockVcsModification setRoot(VcsRootInstance root)
-
setVersion
public void setVersion(String version)
-
setPesonal
public void setPesonal(boolean personal)
-
isCanBeIgnored
public boolean isCanBeIgnored()
-
setCanBeIgnored
public void setCanBeIgnored(boolean canBeIgnored)
-
getPersonalChangeInfo
@NotNull public PersonalChangeDescriptor getPersonalChangeInfo()
Description copied from interface:SVcsModificationFor personal changes, returns personal change information details. For non-personal builds, throws exception- Specified by:
getPersonalChangeInfoin interfaceSVcsModification- Returns:
- see above
- See Also:
VcsModification.isPersonal()
-
getRegistrationDate
@NotNull public Date getRegistrationDate()
Description copied from interface:SVcsModificationReturns date of this VCS modification registration in the TeamCity server database.- Specified by:
getRegistrationDatein interfaceSVcsModification- Returns:
- date of VCS modification registration
-
getDuplicates
@NotNull public Collection<SVcsModification> getDuplicates()
Description copied from interface:SVcsModificationReturns duplicates of this VCS modification, (the given modification is not included)- Specified by:
getDuplicatesin interfaceSVcsModification- Returns:
- duplicates of this VCS modification
-
getParentModifications
@NotNull public Collection<SVcsModification> getParentModifications()
Description copied from interface:SVcsModificationReturns parent modifications of this VCS modification. Returns an empty list if VCS does not provide an information about parents or parents could not be found.- Specified by:
getParentModificationsin interfaceSVcsModification- Returns:
- see above
-
getParentRevisions
@NotNull public Collection<String> getParentRevisions()
Description copied from interface:SVcsModificationReturns parent revisions for modifications from dag-based VCSes as they were reported by a VCS plugin. For modifications from non-dag-based VCSes returns an empty collection.- Specified by:
getParentRevisionsin interfaceSVcsModification- Returns:
- see above
-
getAttributes
@NotNull public Map<String,String> getAttributes()
Description copied from interface:SVcsModificationReturns modification's attributes or empty map if modification doesn't have any.- Specified by:
getAttributesin interfaceSVcsModification- Returns:
- see above
-
getType
@NotNull public String getType()
- Specified by:
getTypein interfaceChangeDescriptor
-
getRelatedVcsChange
@Nullable public SVcsModification getRelatedVcsChange()
- Specified by:
getRelatedVcsChangein interfaceChangeDescriptor
-
getDate
@NotNull public Date getDate()
- Specified by:
getDatein interfaceChangeDescriptor
-
setDescription
public void setDescription(@NotNull String newDescription)Description copied from interface:SVcsModificationSet and store new description for the modification in the database. This action is logged to audit, if current user is set in the authentication context. Empty descriptions are not allowed and ignored.- Specified by:
setDescriptionin interfaceSVcsModification- Parameters:
newDescription- new description for the modification
-
relatedToBuildConfigurationsAccessibleTo
public boolean relatedToBuildConfigurationsAccessibleTo(@NotNull AuthorityHolder authorityHolder)Description copied from interface:SVcsModificationReturns true if the specified authority holder has read access to at least one build configuration where this VCS modification was detected. Method can return false if all build configurations are not accessible to the current authority holder or this VCS modification is not related to any existing build configurations.- Specified by:
relatedToBuildConfigurationsAccessibleToin interfaceSVcsModification
-
getAssociatedData
@NotNull public Map<String,Object> getAssociatedData()
- Specified by:
getAssociatedDatain interfaceChangeDescriptor
-
-