com.atlassian.bamboo.build
Class MockBuildManager

java.lang.Object
  extended by com.atlassian.bamboo.build.MockBuildManager
All Implemented Interfaces:
BuildManager, PlanManager

public class MockBuildManager
extends java.lang.Object
implements BuildManager, PlanManager


Constructor Summary
MockBuildManager()
           
 
Method Summary
 void addBuildResults(Build build, BuildResults buildResults)
           
 void addChildBuild(Build build, java.lang.String childBuildKey)
           
 void createBuild(Build build, BuildConfiguration buildConfiguration, HibernateAcl acl)
          Save a new build object with the passed buildConfiguration
 void deleteBuild(java.lang.String buildKey)
          Removes the build from system
 boolean exists(java.lang.String key)
          Returns true if build exists with the provided key (eg.
 java.util.Set<Build> filterFavouritedBuilds(java.util.Collection<Build> builds, com.atlassian.user.User user)
          Return a set of Builds that are a subset of the given Builds collection that are favourited by the User
 int generateBuildNumber(java.lang.String planKey)
           
 java.util.Collection<Build> getAllBuilds()
          Returns a collection of all Build objects
 java.util.Collection<Build> getAllBuildsForClone()
           
 java.util.Collection<Build> getAllBuildsForEdit()
           
 java.util.Collection<Build> getAllBuildsForRead()
           
 java.util.Collection<Plan> getAllPlans()
          Returns all Plan's
 Build getBuildById(long id)
          Returns the build given the id
 Build getBuildByKey(java.lang.String key)
          Returns the build given a key
 Build getBuildByProjectAndName(java.lang.String projectKey, java.lang.String buildName)
           
 BuildResults getBuildResults(Build build, java.lang.Integer buildNumber)
          Return BuildResults for the given Build and buildNumber
 BuildResults getBuildResults(java.lang.String planKey, java.lang.Integer buildNumber)
          Return BuildResults for the given planKey and buildNumber
 java.util.Collection<Build> getBuildsByProjectForRead(Project project)
          This is the manager equivalent of a project.getBuilds.
 java.util.Collection<Build> getBuildsForDeletion()
           
 java.util.Collection getFavouriteBuildsByProjectForRead(Project project, com.atlassian.user.User user)
          Return a set of favourited builds Builds that belong to Project and @{link User}
 java.util.Collection getFavouriteBuildsForRead(com.atlassian.user.User user)
           
 Plan getPlanById(long id)
          Returns a Plan by its id
 Plan getPlanByKey(java.lang.String planKey)
          Returns a Plan by its planKey
 int getPlanCount()
          How many plans currently exist
 java.util.Map<Project,java.util.Collection<Build>> getProjectBuilds(boolean includeEmptyProjects)
          Return a map of Build collections which belong to a Project
 boolean isAllowBuilding(java.lang.String planKey)
          Checks if a particular build is allowed to be built.
 boolean isBuildingSuspended()
          Checks whether or not bamboo is currently suspended from building due to license reasons.
 boolean isExistingBuildKey(java.lang.String projectKey, java.lang.String buildKey)
          Returns true if the build key already exists within the given project key
 boolean isExistingBuildName(java.lang.String projectKey, java.lang.String buildName)
          Returns true if the build name already exists within the given project key
 boolean isPlanCreationAllowed()
          Check whether or not a plan can be created or not (based on licensing etc) USE SPARINGLY!
 boolean recheckBuildingSuspended()
          Force the build manager to double check if building should be suspended or not.
 void recordLastBuildNumber(BuildResultsSummary summary, BuildContext buildContext)
           
 void removeDependencies(Build dependentBuild)
           
 java.util.Collection<Build> retreiveAllBuilds()
           
 java.lang.String revertVcsRevisionKey(java.lang.String buildKey, java.lang.String revisionForBuild, java.lang.String previousRevision)
          Revert lastVcsRevisionKey in build based on previous build revision contained in BuildContext.
 void saveBuild(Build build)
          Persists a build
 void saveBuildAndDefinition(Build build)
           
 void saveBuildConfig(Build build, BuildConfiguration buildConfiguration)
           
 void savePlan(Plan plan)
          Saves the Plan
 void saveSuspendBuild(java.lang.String buildKey, boolean setSuspendBuild)
          Persists a build for enable/disable
 void updateLatestVcsKey(Plan plan, java.lang.String vcsRevisionKey)
          Updates the build to the latest passed revision key
 void updateNames(java.lang.String projectName, java.lang.String buildName, Build build)
          Updates project and plan names.
 void updateNamesAndDescription(java.lang.String projectName, java.lang.String buildName, java.lang.String buildDescription, Build build)
          Updates project and plan names and plan description.
 java.lang.String updateVcsRevisionKey(BuildContext buildContext)
          Updates lastVcsRevisionKey in build based on revision contained in BuildContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockBuildManager

public MockBuildManager()
Method Detail

removeDependencies

public void removeDependencies(Build dependentBuild)

saveSuspendBuild

public void saveSuspendBuild(java.lang.String buildKey,
                             boolean setSuspendBuild)
Description copied from interface: BuildManager
Persists a build for enable/disable

Specified by:
saveSuspendBuild in interface BuildManager
Parameters:
buildKey - of the build to be suspended/resumed
setSuspendBuild - true if the build should be suspended, false if resumed

isPlanCreationAllowed

public boolean isPlanCreationAllowed()
Description copied from interface: BuildManager
Check whether or not a plan can be created or not (based on licensing etc) USE SPARINGLY!

Specified by:
isPlanCreationAllowed in interface BuildManager
Returns:
true if a plan can be created otherwise false;

isBuildingSuspended

public boolean isBuildingSuspended()
Description copied from interface: BuildManager
Checks whether or not bamboo is currently suspended from building due to license reasons. This value is cached.

Specified by:
isBuildingSuspended in interface BuildManager
Returns:
true if building is suspended.

recheckBuildingSuspended

public boolean recheckBuildingSuspended()
Description copied from interface: BuildManager
Force the build manager to double check if building should be suspended or not. USE SPARINGLY!

Specified by:
recheckBuildingSuspended in interface BuildManager
Returns:
the new value

getPlanCount

public int getPlanCount()
Description copied from interface: BuildManager
How many plans currently exist

Specified by:
getPlanCount in interface BuildManager
Returns:
how many plans exist in the datbase

getBuildByKey

public Build getBuildByKey(java.lang.String key)
Description copied from interface: BuildManager
Returns the build given a key

Specified by:
getBuildByKey in interface BuildManager
Parameters:
key - - full key of the build. eg. BAM-MAIN null safe
Returns:
A Build if the key matches. Otherwise null

filterFavouritedBuilds

public java.util.Set<Build> filterFavouritedBuilds(@NotNull
                                                   java.util.Collection<Build> builds,
                                                   @NotNull
                                                   com.atlassian.user.User user)
Description copied from interface: BuildManager
Return a set of Builds that are a subset of the given Builds collection that are favourited by the User

Specified by:
filterFavouritedBuilds in interface BuildManager
Returns:
favoritedBuilds

getProjectBuilds

@NotNull
public java.util.Map<Project,java.util.Collection<Build>> getProjectBuilds(boolean includeEmptyProjects)
Description copied from interface: BuildManager
Return a map of Build collections which belong to a Project

Specified by:
getProjectBuilds in interface BuildManager
Parameters:
includeEmptyProjects - set to true if you want all of the projects regardless if they have any builds
Returns:
build collection map

updateVcsRevisionKey

public java.lang.String updateVcsRevisionKey(@NotNull
                                             BuildContext buildContext)
Description copied from interface: BuildManager
Updates lastVcsRevisionKey in build based on revision contained in BuildContext

Specified by:
updateVcsRevisionKey in interface BuildManager
Returns:
updated lastVcsRevisionKey

revertVcsRevisionKey

public java.lang.String revertVcsRevisionKey(@NotNull
                                             java.lang.String buildKey,
                                             @NotNull
                                             java.lang.String revisionForBuild,
                                             @Nullable
                                             java.lang.String previousRevision)
Description copied from interface: BuildManager
Revert lastVcsRevisionKey in build based on previous build revision contained in BuildContext. The only reason to revert revision is for the situation, when build is abandoned and no subsequent build has been started. If subsequent build has been already started, there is no effect of reverting vcsRevisionKey

Specified by:
revertVcsRevisionKey in interface BuildManager
Returns:

getBuildById

public Build getBuildById(long id)
Description copied from interface: BuildManager
Returns the build given the id

Specified by:
getBuildById in interface BuildManager
Returns:
A Build. null if not found.

getAllBuilds

public java.util.Collection<Build> getAllBuilds()
Description copied from interface: BuildManager
Returns a collection of all Build objects

Specified by:
getAllBuilds in interface BuildManager
Returns:
all builds in the system, Collections.emptyList() if none exists

getAllBuildsForRead

public java.util.Collection<Build> getAllBuildsForRead()
Specified by:
getAllBuildsForRead in interface BuildManager

retreiveAllBuilds

public java.util.Collection<Build> retreiveAllBuilds()
Specified by:
retreiveAllBuilds in interface BuildManager

getAllBuildsForEdit

public java.util.Collection<Build> getAllBuildsForEdit()
Specified by:
getAllBuildsForEdit in interface BuildManager

getAllBuildsForClone

public java.util.Collection<Build> getAllBuildsForClone()
Specified by:
getAllBuildsForClone in interface BuildManager

getBuildsForDeletion

public java.util.Collection<Build> getBuildsForDeletion()
Specified by:
getBuildsForDeletion in interface BuildManager

getFavouriteBuildsForRead

public java.util.Collection getFavouriteBuildsForRead(com.atlassian.user.User user)
Specified by:
getFavouriteBuildsForRead in interface BuildManager

getFavouriteBuildsByProjectForRead

public java.util.Collection getFavouriteBuildsByProjectForRead(Project project,
                                                               com.atlassian.user.User user)
Description copied from interface: BuildManager
Return a set of favourited builds Builds that belong to Project and @{link User}

Specified by:
getFavouriteBuildsByProjectForRead in interface BuildManager
Returns:
favoritedBuilds

getBuildsByProjectForRead

public java.util.Collection<Build> getBuildsByProjectForRead(Project project)
Description copied from interface: BuildManager
This is the manager equivalent of a project.getBuilds. However, this is permission filtered.

Specified by:
getBuildsByProjectForRead in interface BuildManager
Returns:

isExistingBuildName

public boolean isExistingBuildName(java.lang.String projectKey,
                                   java.lang.String buildName)
Description copied from interface: BuildManager
Returns true if the build name already exists within the given project key

Specified by:
isExistingBuildName in interface BuildManager
Parameters:
projectKey - (doesn't have to exist for this check)
buildName - to check
Returns:
true if build name already exists in that project

isExistingBuildKey

public boolean isExistingBuildKey(java.lang.String projectKey,
                                  java.lang.String buildKey)
Description copied from interface: BuildManager
Returns true if the build key already exists within the given project key

Specified by:
isExistingBuildKey in interface BuildManager
Parameters:
projectKey - (doesn't have to exist for this check)
buildKey - to check
Returns:
true if build name already exists in that project

exists

public boolean exists(java.lang.String key)
Description copied from interface: BuildManager
Returns true if build exists with the provided key (eg. BAM-BOO)

Specified by:
exists in interface BuildManager
Returns:
exists

createBuild

public void createBuild(Build build,
                        BuildConfiguration buildConfiguration,
                        HibernateAcl acl)
Description copied from interface: BuildManager
Save a new build object with the passed buildConfiguration

Specified by:
createBuild in interface BuildManager
Parameters:
build - @NotNull
buildConfiguration - @NotNull

saveBuild

public void saveBuild(Build build)
Description copied from interface: BuildManager
Persists a build

Specified by:
saveBuild in interface BuildManager
Parameters:
build - cannot be null

saveBuildAndDefinition

public void saveBuildAndDefinition(Build build)

saveBuildConfig

public void saveBuildConfig(Build build,
                            BuildConfiguration buildConfiguration)

deleteBuild

public void deleteBuild(java.lang.String buildKey)
Description copied from interface: BuildManager
Removes the build from system

Specified by:
deleteBuild in interface BuildManager
Parameters:
buildKey - String name for build

addBuildResults

public void addBuildResults(Build build,
                            BuildResults buildResults)
Specified by:
addBuildResults in interface BuildManager

getBuildResults

@Nullable
public BuildResults getBuildResults(Build build,
                                             java.lang.Integer buildNumber)
Description copied from interface: BuildManager
Return BuildResults for the given Build and buildNumber

Specified by:
getBuildResults in interface BuildManager
Returns:
buildResults

getBuildResults

public BuildResults getBuildResults(java.lang.String planKey,
                                    java.lang.Integer buildNumber)
Description copied from interface: BuildManager
Return BuildResults for the given planKey and buildNumber

Specified by:
getBuildResults in interface BuildManager
Returns:
buildResults

generateBuildNumber

public int generateBuildNumber(java.lang.String planKey)

recordLastBuildNumber

public void recordLastBuildNumber(BuildResultsSummary summary,
                                  BuildContext buildContext)

addChildBuild

public void addChildBuild(Build build,
                          java.lang.String childBuildKey)

getBuildByProjectAndName

public Build getBuildByProjectAndName(java.lang.String projectKey,
                                      java.lang.String buildName)
Specified by:
getBuildByProjectAndName in interface BuildManager

updateNames

public void updateNames(java.lang.String projectName,
                        java.lang.String buildName,
                        Build build)
Description copied from interface: BuildManager
Updates project and plan names.

Specified by:
updateNames in interface BuildManager
Parameters:
projectName - new name of the project
buildName - new name of the plan
build - build object to be modified and stored.

updateNamesAndDescription

public void updateNamesAndDescription(java.lang.String projectName,
                                      java.lang.String buildName,
                                      java.lang.String buildDescription,
                                      Build build)
Description copied from interface: BuildManager
Updates project and plan names and plan description.

Specified by:
updateNamesAndDescription in interface BuildManager
Parameters:
projectName - new name of the project
buildName - new name of the plan
buildDescription - new plan description
build - build object to be modified and stored.

updateLatestVcsKey

public void updateLatestVcsKey(@NotNull
                               Plan plan,
                               @NotNull
                               java.lang.String vcsRevisionKey)
Description copied from interface: PlanManager
Updates the build to the latest passed revision key

Specified by:
updateLatestVcsKey in interface PlanManager
Parameters:
plan - - Plan key
vcsRevisionKey - - revision key

isAllowBuilding

public boolean isAllowBuilding(@NotNull
                               java.lang.String planKey)
Description copied from interface: BuildManager
Checks if a particular build is allowed to be built. It checks if it exists, not suspened, and that there is no global flag that has stopped building

Specified by:
isAllowBuilding in interface BuildManager
Returns:
true if the planKey is a valid build that is allowed to be built

getPlanById

public Plan getPlanById(long id)
Description copied from interface: PlanManager
Returns a Plan by its id

Specified by:
getPlanById in interface PlanManager
Returns:

getPlanByKey

public Plan getPlanByKey(@NotNull
                         java.lang.String planKey)
Description copied from interface: PlanManager
Returns a Plan by its planKey

Specified by:
getPlanByKey in interface PlanManager
Returns:
plan

getAllPlans

@NotNull
public java.util.Collection<Plan> getAllPlans()
Description copied from interface: PlanManager
Returns all Plan's

Specified by:
getAllPlans in interface PlanManager
Returns:
plans

savePlan

public void savePlan(@NotNull
                     Plan plan)
Description copied from interface: PlanManager
Saves the Plan

Specified by:
savePlan in interface PlanManager


Copyright © 2010 Atlassian. All Rights Reserved.