Class FakeBuildHistory
- java.lang.Object
-
- jetbrains.buildServer.serverSide.fakes.FakeBuildHistory
-
- All Implemented Interfaces:
BuildHistory,BuildHistoryEx
public class FakeBuildHistory extends Object implements BuildHistoryEx
- Author:
- Leonid Bushuev from JetBrains
-
-
Constructor Summary
Constructors Constructor Description FakeBuildHistory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildsRemoved(String buildTypeId, BuildTypeRemovedBuilds predicate)Accepts a build configuration id and a collection of removed finished builds ids.voidclearCache()voidcreateEntry(HistoryBuild build, Date finishTime)voidcreateEntryForNotStartedBuild(HistoryBuild build, Date finishTime)HistoryQueryRunnercreateHistoryQueryRunner(User user, boolean includePersonalBuildsIfUserNotSpecified, boolean includeCanceled, boolean orderByChanges)List<SFinishedBuild>findEntries(String buildTypeId, String buildNumber)Returns list of finished builds with specified build number belonging to specified build configuration ordered by changes (the most recent first).Collection<SFinishedBuild>findEntries(Collection<Long> buildIds)Returns collection of finished builds corresponding to the specified build ids.Collection<SFinishedBuild>findEntries(Collection<Long> buildIds, boolean addToCache)Same asBuildHistory.findEntries(Collection)but with additional parameter which controls whether the found builds should be cached or not.SFinishedBuildfindEntry(long buildId)Finds entry with the specified id and cache the data internally.SFinishedBuildfindEntry(long buildId, boolean addToCache)Finds entry with the specified id and optionally cache it.SFinishedBuildfindEntry(String buildTypeId, String buildNumber)Finds the most recent by changes entry inside specified configuration with specified build number.Collection<SBuildType>getActiveBuildTypes(Date sinceDate)Return a list of build configurations that have been active (i.e.Map<Long,String>getBuildNumbers(Collection<Long> buildIds)Returns build numbers of the specified buildsCollection<SBuildType>getBuildTypesWithTest(SProject project, long testNameId)Collection<SFinishedBuild>getCachedEntries(Collection<Long> buildIds)Same asBuildHistory.findEntries(Collection)but returns only currently cached builds (does not attempt to load anything from database).List<SFinishedBuild>getEntries(boolean includeCanceled)Return whole build history for all build configurations of all projects.List<SFinishedBuild>getEntriesBefore(SBuild beforeThisBuild, boolean successfulOnly)Returns builds of the specified configuration started before the specified build (excluding the specified build).List<SFinishedBuild>getEntriesBetween(long from, long to, boolean includeCanceled)List<SFinishedBuild>getEntriesSince(SBuild sinceBuildInclusive, BuildType buildType)Returns builds of the specified configuration started after the specified build (including the specified build), ordered by changes.List<SFinishedBuild>getHistoryByAgent(SBuildAgent agent, User user, boolean includeCanceled)Returns the build history filtered by theagent.List<SFinishedBuild>getHistoryByAgentType(AgentType agent, User user, boolean includeCanceled)Returns the build history filtered by theagent type.SFinishedBuildgetLastChangesBuild(String buildTypeId)Returns last finished build with last changes in the specified configuration, excluding personal and canceled builds.longgetLastEntryId(boolean includeCanceled)DategetLastFinishedBuildDateOnAgent(SBuildAgent agent, Date finishTimeAfter)Return last finished build that was started on the agent.SFinishedBuildgetLastSuccessfulChangesBuild(String buildTypeId)Returns last successfully finished build with last changes in the specified configuration, personal and canceled builds are not consideredintgetNumberOfBuildsInBuildType(SBuildType buildType)Return the number of all builds for this build configuration, including personal and canceled onesintgetNumberOfPinnedBuildsInBuildType(SBuildType buildType)Return the number of pinned builds for this build configurationSet<Long>getPinnedBuildsIds(Collection<Long> buildIds)Accepts a collection of build ids and returns those which are pinned.List<STestRun>getTestHistory(long testNameId, String buildTypeId, long userId, String branchName)Order of the returned TestRuns is recent runs first, according to the starting order of the builds.List<STestRun>getTestHistory(long testNameId, String buildTypeId, Filter<STestRun> filter)Order of the returned TestRuns is recent runs first, according to the starting order of the builds.List<STestRun>getTestHistory(long testNameId, SProject project, long userId, String branchName)Order of the returned TestRuns is recent runs first, according to the starting order of the builds.List<STestRun>getTestHistory(long testNameId, SProject project, Filter<STestRun> filter)Order of the returned TestRuns is recent runs first, according to the starting order of the builds.voidprocessEntries(String buildTypeId, User user, boolean includePersonalBuildsIfUserNotSpecified, boolean includeCanceled, boolean orderByChanges, ItemProcessor<SFinishedBuild> processor)Process build history for the specified build configuration.voidprocessEntries(ItemProcessor<SFinishedBuild> itemProcessor)Invokes the given ItemProcessor for all history records existing in the system.voidremoveCachedEntry(long buildId)Removes a single cached build from builds history cachebooleanremoveEntry(long buildId)Removes finished build from the history.booleanremoveEntry(long buildId, String comment)Removes finished build from the history with specified reason.voidremoveEntry(SFinishedBuild finishedBuild)Removes finished build from build history.voidremoveEntry(SFinishedBuild finishedBuild, String comment)Removes finished build from build history.voidremoveEntry(SFinishedBuild finishedBuild, String comment, CleanupLevel cleanupLevel)Removes finished build from build history.
-
-
-
Method Detail
-
getHistoryByAgentType
@NotNull public List<SFinishedBuild> getHistoryByAgentType(@NotNull AgentType agent, @Nullable User user, boolean includeCanceled)
Description copied from interface:BuildHistoryExReturns the build history filtered by theagent type.- Specified by:
getHistoryByAgentTypein interfaceBuildHistoryEx- Parameters:
agent- the build agent typeuser- if set the result will contain only builds byuserincludeCanceled- if set the result will include calceled builds as well- Returns:
- build history
-
getLastChangesBuild
public SFinishedBuild getLastChangesBuild(String buildTypeId)
Description copied from interface:BuildHistoryExReturns last finished build with last changes in the specified configuration, excluding personal and canceled builds.- Specified by:
getLastChangesBuildin interfaceBuildHistoryEx- Parameters:
buildTypeId- specified configuration id.- Returns:
- last finished build in the specified configuration or
nullif there are no finished builds.
-
getLastSuccessfulChangesBuild
public SFinishedBuild getLastSuccessfulChangesBuild(String buildTypeId)
Description copied from interface:BuildHistoryExReturns last successfully finished build with last changes in the specified configuration, personal and canceled builds are not considered- Specified by:
getLastSuccessfulChangesBuildin interfaceBuildHistoryEx- Parameters:
buildTypeId- specified configuration id.- Returns:
- last successfully finished build in the specified configuration (excluding personal) or
nullif there are no successfully finished builds.
-
createEntry
public void createEntry(@NotNull HistoryBuild build, @NotNull Date finishTime)- Specified by:
createEntryin interfaceBuildHistoryEx
-
createEntryForNotStartedBuild
public void createEntryForNotStartedBuild(@NotNull HistoryBuild build, @NotNull Date finishTime)- Specified by:
createEntryForNotStartedBuildin interfaceBuildHistoryEx
-
getLastEntryId
public long getLastEntryId(boolean includeCanceled)
- Specified by:
getLastEntryIdin interfaceBuildHistoryEx
-
getEntriesBetween
@NotNull public List<SFinishedBuild> getEntriesBetween(long from, long to, boolean includeCanceled)
- Specified by:
getEntriesBetweenin interfaceBuildHistoryEx
-
clearCache
public void clearCache()
- Specified by:
clearCachein interfaceBuildHistoryEx
-
removeCachedEntry
public void removeCachedEntry(long buildId)
Description copied from interface:BuildHistoryExRemoves a single cached build from builds history cache- Specified by:
removeCachedEntryin interfaceBuildHistoryEx- Parameters:
buildId- build id
-
buildsRemoved
public void buildsRemoved(@NotNull String buildTypeId, @NotNull BuildTypeRemovedBuilds predicate)Description copied from interface:BuildHistoryExAccepts a build configuration id and a collection of removed finished builds ids. Cleans internal caches for builds in this collection.- Specified by:
buildsRemovedin interfaceBuildHistoryEx
-
createHistoryQueryRunner
@NotNull public HistoryQueryRunner createHistoryQueryRunner(@Nullable User user, boolean includePersonalBuildsIfUserNotSpecified, boolean includeCanceled, boolean orderByChanges)
- Specified by:
createHistoryQueryRunnerin interfaceBuildHistoryEx
-
getTestHistory
@NotNull public List<STestRun> getTestHistory(long testNameId, @NotNull String buildTypeId, long userId, String branchName)
Description copied from interface:BuildHistoryExOrder of the returned TestRuns is recent runs first, according to the starting order of the builds. Multiple test runs in the build are NOT wrapped into MultiRun class, i.e. each test run is returned independently- Specified by:
getTestHistoryin interfaceBuildHistoryExbuildTypeId- required to set the build configuration for the test historyuserId- if > 0, includes personal builds of the given userbranchName- if not null, returns only builds which match given branchName- Returns:
- Test run objects for given test, recent builds go first
- See Also:
TestHistory
-
getTestHistory
@NotNull public List<STestRun> getTestHistory(long testNameId, @NotNull SProject project, long userId, String branchName)
Description copied from interface:BuildHistoryExOrder of the returned TestRuns is recent runs first, according to the starting order of the builds. Multiple test runs in the build are NOT wrapped into MultiRun class, i.e. each test run is returned independently- Specified by:
getTestHistoryin interfaceBuildHistoryExproject- required to set the parent project, all returned test runs will belong to build configurations under this project and its subprojectsuserId- if > 0, includes personal builds of the given userbranchName- if not null, returns only builds which match given branchName- Returns:
- Test run objects for given test, recent builds go first
- See Also:
TestHistory
-
getTestHistory
@NotNull public List<STestRun> getTestHistory(long testNameId, @NotNull SProject project, Filter<STestRun> filter)
Description copied from interface:BuildHistoryExOrder of the returned TestRuns is recent runs first, according to the starting order of the builds. Multiple test runs in the build are NOT wrapped into MultiRun class, i.e. each test run is returned independently- Specified by:
getTestHistoryin interfaceBuildHistoryExproject- required to set the parent project, all returned test runs will belong to build configurations under this project and its subprojectsfilter- additional filter for the returned test runs- Returns:
- Test run objects for given test, recent builds go first
- See Also:
TestHistory
-
getTestHistory
@NotNull public List<STestRun> getTestHistory(long testNameId, @NotNull String buildTypeId, Filter<STestRun> filter)
Description copied from interface:BuildHistoryExOrder of the returned TestRuns is recent runs first, according to the starting order of the builds. Multiple test runs in the build are NOT wrapped into MultiRun class, i.e. each test run is returned independently- Specified by:
getTestHistoryin interfaceBuildHistoryExbuildTypeId- required to set the build configuration for the test historyfilter- additional filter for the returned test runs- Returns:
- Test run objects for given test, recent builds go first
- See Also:
TestHistory
-
getBuildTypesWithTest
@NotNull public Collection<SBuildType> getBuildTypesWithTest(@NotNull SProject project, long testNameId)
- Specified by:
getBuildTypesWithTestin interfaceBuildHistoryEx- See Also:
TestHistory
-
removeEntry
public boolean removeEntry(long buildId, @Nullable String comment)Description copied from interface:BuildHistoryExRemoves finished build from the history with specified reason.- Specified by:
removeEntryin interfaceBuildHistoryEx- Parameters:
buildId- build identifier of the finished build.comment- reason for audit why build is removed- Returns:
- true if the build was successfully removed
-
getCachedEntries
@NotNull public Collection<SFinishedBuild> getCachedEntries(@NotNull Collection<Long> buildIds)
Description copied from interface:BuildHistoryExSame asBuildHistory.findEntries(Collection)but returns only currently cached builds (does not attempt to load anything from database).- Specified by:
getCachedEntriesin interfaceBuildHistoryEx- Parameters:
buildIds- id list to find builds with these ids.
-
getEntries
@NotNull public List<SFinishedBuild> getEntries(boolean includeCanceled)
Description copied from interface:BuildHistoryReturn whole build history for all build configurations of all projects. Personal builds are not included. Build ordering is by start time.- Specified by:
getEntriesin interfaceBuildHistory- Parameters:
includeCanceled- true if cancelled builds should be included into result- Returns:
- list of builds, most recent first
-
processEntries
public void processEntries(String buildTypeId, @Nullable User user, boolean includePersonalBuildsIfUserNotSpecified, boolean includeCanceled, boolean orderByChanges, @NotNull ItemProcessor<SFinishedBuild> processor)
Description copied from interface:BuildHistoryProcess build history for the specified build configuration. Personal builds are included if user is specified. Builds are processed using given processor.- Specified by:
processEntriesin interfaceBuildHistory- Parameters:
buildTypeId- internal id of build configurationuser- if not null, personal builds of this user will be included into resultincludePersonalBuildsIfUserNotSpecified- if true and user==null, all personal builds will be included into resultsincludeCanceled- true if cancelled builds should be included into resultorderByChanges- if true, builds are ordered by changes, i.e. most recent build with recent changes goes first; if false, most recent builds go first, regardless change orderprocessor- processor for builds
-
getEntriesSince
@NotNull public List<SFinishedBuild> getEntriesSince(@Nullable SBuild sinceBuildInclusive, @NotNull BuildType buildType)
Description copied from interface:BuildHistoryReturns builds of the specified configuration started after the specified build (including the specified build), ordered by changes. History builds which contain changes older than in sinceBuildInclusive are not included.- Specified by:
getEntriesSincein interfaceBuildHistory- Parameters:
sinceBuildInclusive- boundary for returning builds (inclusive), may be null - in this case all builds are returnedbuildType- specified configuration.- Returns:
- see above
-
getEntriesBefore
@NotNull public List<SFinishedBuild> getEntriesBefore(@NotNull SBuild beforeThisBuild, boolean successfulOnly)
Description copied from interface:BuildHistoryReturns builds of the specified configuration started before the specified build (excluding the specified build). Personal builds are included, canceled builds are excluded. Returned builds are sorted by containing changes and than by build start time (if contain same changes). Recent builds go first.- Specified by:
getEntriesBeforein interfaceBuildHistory- Parameters:
beforeThisBuild- returns build before this onesuccessfulOnly- if only successful builds should be included.- Returns:
- see above
-
findEntries
@NotNull public Collection<SFinishedBuild> findEntries(@NotNull Collection<Long> buildIds)
Description copied from interface:BuildHistoryReturns collection of finished builds corresponding to the specified build ids. The collection will contain existing builds only. NOTE: RETURNED COLLECTION WILL NOT MAINTAIN REQUESTED ORDER!- Specified by:
findEntriesin interfaceBuildHistory- Parameters:
buildIds- id list to find builds with these ids.- Returns:
- collection of finished builds corresponding to the specified build ids.
-
findEntries
@NotNull public Collection<SFinishedBuild> findEntries(@NotNull Collection<Long> buildIds, boolean addToCache)
Description copied from interface:BuildHistorySame asBuildHistory.findEntries(Collection)but with additional parameter which controls whether the found builds should be cached or not.- Specified by:
findEntriesin interfaceBuildHistory- Parameters:
buildIds- id list to find builds with these ids.addToCache- whether to put found builds in cache or not- Returns:
- collection of finished builds corresponding to the specified build ids.
-
findEntry
public SFinishedBuild findEntry(long buildId)
Description copied from interface:BuildHistoryFinds entry with the specified id and cache the data internally. Same as findEntry(buildId, true).- Specified by:
findEntryin interfaceBuildHistory- Parameters:
buildId- specified build id.- Returns:
- entry with the specified id,
nullif it does not exist or invisible for the current user.
-
findEntry
@Nullable public SFinishedBuild findEntry(long buildId, boolean addToCache)
Description copied from interface:BuildHistoryFinds entry with the specified id and optionally cache it.- Specified by:
findEntryin interfaceBuildHistory- Parameters:
buildId- specified build id.addToCache- if true, the build will be added to internal caches- Returns:
- entry with the specified id,
nullif it does not exist or invisible for the current user.
-
findEntry
public SFinishedBuild findEntry(@NotNull String buildTypeId, @NotNull String buildNumber)
Description copied from interface:BuildHistoryFinds the most recent by changes entry inside specified configuration with specified build number.- Specified by:
findEntryin interfaceBuildHistory- Parameters:
buildTypeId- specified build configuration id.buildNumber- specified build number.- Returns:
- entry with the specified number in the specified configuration,
nullif it does not exist or invisible for the current user.
-
findEntries
@NotNull public List<SFinishedBuild> findEntries(@NotNull String buildTypeId, @NotNull String buildNumber)
Description copied from interface:BuildHistoryReturns list of finished builds with specified build number belonging to specified build configuration ordered by changes (the most recent first).- Specified by:
findEntriesin interfaceBuildHistory- Parameters:
buildTypeId- build configuration idbuildNumber- build number- Returns:
- collection of found builds
-
removeEntry
public void removeEntry(@NotNull SFinishedBuild finishedBuild, @Nullable String comment, @NotNull CleanupLevel cleanupLevel)Description copied from interface:BuildHistoryRemoves finished build from build history. If action is performed by authenticated user, provided comment will be written in audit. CleanupLevel could be used to specify action strictness. SeeCleanupLevelfor more details.- Specified by:
removeEntryin interfaceBuildHistory
-
removeEntry
public void removeEntry(@NotNull SFinishedBuild finishedBuild, @Nullable String comment)Description copied from interface:BuildHistoryRemoves finished build from build history. If action is performed by authenticated user, provided comment will be written in audit.- Specified by:
removeEntryin interfaceBuildHistory
-
removeEntry
public void removeEntry(@NotNull SFinishedBuild finishedBuild)Description copied from interface:BuildHistoryRemoves finished build from build history.- Specified by:
removeEntryin interfaceBuildHistory
-
removeEntry
public boolean removeEntry(long buildId)
Description copied from interface:BuildHistoryRemoves finished build from the history.The removing build must be an instance of
SFinishedBuild.- Specified by:
removeEntryin interfaceBuildHistory- Parameters:
buildId- build identifier of the finished build.- Returns:
- true if the build was successfully removed
-
processEntries
public void processEntries(@NotNull ItemProcessor<SFinishedBuild> itemProcessor)Description copied from interface:BuildHistoryInvokes the given ItemProcessor for all history records existing in the system. Entries are pushed into the processor in the most-recent-first order.- Specified by:
processEntriesin interfaceBuildHistory- Parameters:
itemProcessor- processor for history entries
-
getHistoryByAgent
@NotNull public List<SFinishedBuild> getHistoryByAgent(@NotNull SBuildAgent agent, @Nullable User user, boolean includeCanceled)
Description copied from interface:BuildHistoryReturns the build history filtered by theagent.- Specified by:
getHistoryByAgentin interfaceBuildHistory- Parameters:
agent- the build agentuser- if set the result will contain only builds byuserincludeCanceled- if set the result will include canceled builds as well- Returns:
- build history
-
getLastFinishedBuildDateOnAgent
public Date getLastFinishedBuildDateOnAgent(@NotNull SBuildAgent agent, @NotNull Date finishTimeAfter)
Description copied from interface:BuildHistoryReturn last finished build that was started on the agent.- Specified by:
getLastFinishedBuildDateOnAgentin interfaceBuildHistory- Parameters:
agent- agentfinishTimeAfter- finish time lower bound- Returns:
- found build or null
-
getActiveBuildTypes
@NotNull public Collection<SBuildType> getActiveBuildTypes(@NotNull Date sinceDate)
Description copied from interface:BuildHistoryReturn a list of build configurations that have been active (i.e. have any kind of finished/canceled/personal/etc. builds) since the specified date.- Specified by:
getActiveBuildTypesin interfaceBuildHistory- Returns:
- see above
-
getNumberOfBuildsInBuildType
public int getNumberOfBuildsInBuildType(@NotNull SBuildType buildType)Description copied from interface:BuildHistoryExReturn the number of all builds for this build configuration, including personal and canceled ones- Specified by:
getNumberOfBuildsInBuildTypein interfaceBuildHistoryEx
-
getNumberOfPinnedBuildsInBuildType
public int getNumberOfPinnedBuildsInBuildType(@NotNull SBuildType buildType)Description copied from interface:BuildHistoryExReturn the number of pinned builds for this build configuration- Specified by:
getNumberOfPinnedBuildsInBuildTypein interfaceBuildHistoryEx
-
getPinnedBuildsIds
@NotNull public Set<Long> getPinnedBuildsIds(@NotNull Collection<Long> buildIds)
Description copied from interface:BuildHistoryExAccepts a collection of build ids and returns those which are pinned.- Specified by:
getPinnedBuildsIdsin interfaceBuildHistoryEx- Returns:
-
getBuildNumbers
@NotNull public Map<Long,String> getBuildNumbers(@NotNull Collection<Long> buildIds)
Description copied from interface:BuildHistoryExReturns build numbers of the specified builds- Specified by:
getBuildNumbersin interfaceBuildHistoryEx- Returns:
-
-