Class FakeAgentTypeManager
- java.lang.Object
-
- jetbrains.buildServer.serverSide.fakes.FakeAgentTypeManager
-
- All Implemented Interfaces:
AgentTypeFinder,AgentTypeManager,AgentTypeStorage
public class FakeAgentTypeManager extends Object implements AgentTypeManager, AgentTypeStorage, AgentTypeFinder
Fake agent type manager. For testing purpose.- Author:
- Leonid Bushuev from JetBrains
-
-
Constructor Summary
Constructors Constructor Description FakeAgentTypeManager(FakeAgentPoolManager poolManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intassignAgentType(BuildAgentEx agent)Creates agent type for specified agent if agent does not have one and assigns it to the agent.voidcopyAgentTypeRestrictions(String originalBuildTypeId, String newBuildTypeId)voidcopyAgentTypeRestrictions(BuildTypeDescriptor originalBuildType, BuildTypeDescriptor newBuildType)SAgentTypecreateAgentTypeFromKey(AgentTypeKey key, int poolId)SAgentTypecreateCloudAgentType(String name, String osName)SAgentTypecreateNormalAgentType(String name, String osName)voiddeleteAgentType(int agentTypeId)voidexcludeBuildTypesFromAllowed(int agentTypeId, Set<String> buildTypeIds)Removes the given build configurations from the list of allowed ones.voidexcludeRunConfigurationsFromAllowed(int agentTypeId, String[] buildTypeIds)SAgentTypefindAgentType(int agentTypeId)AgentTypefindAgentTypeById(int agentTypeId)Finds agent type in agent type id.AgentTypefindAgentTypeByKey(AgentTypeKey agentTypeKey)Finds agent type in database by specified key.Map<Integer,AgentType>findAgentTypesByIds(Collection<Integer> agentTypeIds)Returns map of agent types corresponding to the specified agent type idsCollection<SAgentType>getActiveAgentTypes()Collection<SAgentType>getActiveCloudAgentTypes()List<AgentCompatibility>getAgentTypeCompatibilities(SAgentType agentType)Set<Integer>getAgentTypeIds()Returns all known agent type identifiers.Collection<Integer>getAgentTypeIdsByPool(int agentPoolId)Map<Integer,AgentTypeKey>getAgentTypePairs()Collection<SAgentType>getAgentTypesByPool(int agentPoolId)Set<String>getCanRunConfigurations(int agentTypeId)intgetNumberOfCompatibleConfigurations(SAgentType agentType)intgetNumberOfIncompatibleConfigurations(SAgentType agentType)intgetOrCreateAgentTypeId(AgentTypeKey key)similar toAgentTypeManager.getOrCreateAgentTypeId(jetbrains.buildServer.serverSide.agentTypes.AgentTypeKey, int), puts agentType to the "Default" pool, if it doesn't existintgetOrCreateAgentTypeId(AgentTypeKey key, int defaultRawPoolId)Maps created agent type key into agentTypeId.AgentTypePolicygetPolicy(int agentTypeId)Loades the policy from database (if not loaded yet) and returns it.BuildAgentManager.RunConfigurationPolicygetRunConfigurationPolicy(int agentTypeId)voidincludeBuildTypesToAllowed(int agentTypeId, Set<String> buildTypeIds)Adds the given build configurations to the list of allowed ones.voidincludeRunConfigurationsToAllowed(int agentTypeId, String[] buildTypeIds)voidinvalidateCacheForAgentTypesFromPools(Set<Integer> agentPoolIds, CacheClearPolicy policy)voidinvalidateCacheForAllAgentTypes()voidinvalidateCacheForOneAgentType(int agentTypeId, CacheClearPolicy policy)booleanisAllowedToRun(int agentTypeId, String projectId, String buildTypeId)Checks whether the given build configuration (buildTypeId) is allowed to run on the specified agent type (agentTypeId).booleanisCanRunConfiguration(int agentTypeId, BuildTypeDescriptor buildType)voidmigrateAgentTypeKey(AgentTypeKey currentKey, AgentTypeKey newKey)voidremoveBuildTypeFromAllLists(String buildTypeId)Removes the specified build configuration from all allowed configurations lists, and invalidates internal cache.voidsetPolicyKind(int agentTypeId, int newPolicyKind)Changes policy kind for the specified agent.voidsetRunConfigurationPolicy(int agentTypeId, BuildAgentManager.RunConfigurationPolicy policy)voidupdateAgentType(int agentTypeId, AgentDescription agentDescription, boolean allowDeleteParams)updates agent type parameters from the agent's parametersvoidupdateAgentType(BuildAgentEx agent, boolean allowDeleteParams)updates agent type parameters from the agent's parametersvoidupdateAgentTypeFromDB(int agentTypeId)
-
-
-
Constructor Detail
-
FakeAgentTypeManager
public FakeAgentTypeManager(@NotNull FakeAgentPoolManager poolManager)
-
-
Method Detail
-
createNormalAgentType
public SAgentType createNormalAgentType(String name, String osName)
-
createCloudAgentType
public SAgentType createCloudAgentType(String name, String osName)
-
createAgentTypeFromKey
public SAgentType createAgentTypeFromKey(@NotNull AgentTypeKey key, int poolId)
-
getActiveAgentTypes
@NotNull public Collection<SAgentType> getActiveAgentTypes()
- Specified by:
getActiveAgentTypesin interfaceAgentTypeFinder
-
getActiveCloudAgentTypes
@NotNull public Collection<SAgentType> getActiveCloudAgentTypes()
- Specified by:
getActiveCloudAgentTypesin interfaceAgentTypeFinder
-
getAgentTypesByPool
@NotNull public Collection<SAgentType> getAgentTypesByPool(int agentPoolId)
- Specified by:
getAgentTypesByPoolin interfaceAgentTypeFinder
-
findAgentType
public SAgentType findAgentType(int agentTypeId)
- Specified by:
findAgentTypein interfaceAgentTypeFinder
-
setRunConfigurationPolicy
public void setRunConfigurationPolicy(int agentTypeId, @NotNull BuildAgentManager.RunConfigurationPolicy policy)- Specified by:
setRunConfigurationPolicyin interfaceAgentTypeManager
-
getRunConfigurationPolicy
@NotNull public BuildAgentManager.RunConfigurationPolicy getRunConfigurationPolicy(int agentTypeId)
- Specified by:
getRunConfigurationPolicyin interfaceAgentTypeManager
-
findAgentTypeById
public AgentType findAgentTypeById(int agentTypeId)
Description copied from interface:AgentTypeStorageFinds agent type in agent type id.- Specified by:
findAgentTypeByIdin interfaceAgentTypeStorage- Parameters:
agentTypeId- agent type id.- Returns:
- loaded
AgentTypeor null if agent type not found.
-
findAgentTypesByIds
@NotNull public Map<Integer,AgentType> findAgentTypesByIds(@NotNull Collection<Integer> agentTypeIds)
Description copied from interface:AgentTypeStorageReturns map of agent types corresponding to the specified agent type ids- Specified by:
findAgentTypesByIdsin interfaceAgentTypeStorage- Parameters:
agentTypeIds- ids of agent types- Returns:
- see above
-
findAgentTypeByKey
@Nullable public AgentType findAgentTypeByKey(@NotNull AgentTypeKey agentTypeKey)
Description copied from interface:AgentTypeStorageFinds agent type in database by specified key.- Specified by:
findAgentTypeByKeyin interfaceAgentTypeStorage- Parameters:
agentTypeKey- agent type key.- Returns:
- loaded
AgentTypeor null if agent type not found.
-
getAgentTypeIds
@NotNull public Set<Integer> getAgentTypeIds()
Description copied from interface:AgentTypeStorageReturns all known agent type identifiers.- Specified by:
getAgentTypeIdsin interfaceAgentTypeStorage- Returns:
- set of agent type identifiers.
-
getAgentTypePairs
public Map<Integer,AgentTypeKey> getAgentTypePairs()
- Specified by:
getAgentTypePairsin interfaceAgentTypeStorage
-
getAgentTypeIdsByPool
@NotNull public Collection<Integer> getAgentTypeIdsByPool(int agentPoolId)
- Specified by:
getAgentTypeIdsByPoolin interfaceAgentTypeStorage
-
getPolicy
@NotNull public AgentTypePolicy getPolicy(int agentTypeId)
Description copied from interface:AgentTypeStorageLoades the policy from database (if not loaded yet) and returns it.- Specified by:
getPolicyin interfaceAgentTypeStorage- Parameters:
agentTypeId- agent type.- Returns:
- policy.
-
setPolicyKind
public void setPolicyKind(int agentTypeId, int newPolicyKind)Description copied from interface:AgentTypeStorageChanges policy kind for the specified agent.- Specified by:
setPolicyKindin interfaceAgentTypeStorage- Parameters:
agentTypeId- agent which policy to change.newPolicyKind- new policy kind.
-
includeBuildTypesToAllowed
public void includeBuildTypesToAllowed(int agentTypeId, @NotNull Set<String> buildTypeIds)Description copied from interface:AgentTypeStorageAdds the given build configurations to the list of allowed ones.- Specified by:
includeBuildTypesToAllowedin interfaceAgentTypeStorage- Parameters:
agentTypeId- agent type.buildTypeIds- build configurations to add to the list of allowed.
-
excludeBuildTypesFromAllowed
public void excludeBuildTypesFromAllowed(int agentTypeId, @NotNull Set<String> buildTypeIds)Description copied from interface:AgentTypeStorageRemoves the given build configurations from the list of allowed ones.- Specified by:
excludeBuildTypesFromAllowedin interfaceAgentTypeStorage- Parameters:
agentTypeId- agent type.buildTypeIds- build configurations to remove from the list of allowed.
-
isAllowedToRun
public boolean isAllowedToRun(int agentTypeId, @NotNull String projectId, @NotNull String buildTypeId)Description copied from interface:AgentTypeStorageChecks whether the given build configuration (buildTypeId) is allowed to run on the specified agent type (agentTypeId).- Specified by:
isAllowedToRunin interfaceAgentTypeStorage- Parameters:
agentTypeId- agent type.buildTypeId- build configuration. @return true if allowed.
-
removeBuildTypeFromAllLists
public void removeBuildTypeFromAllLists(@NotNull String buildTypeId)Description copied from interface:AgentTypeStorageRemoves the specified build configuration from all allowed configurations lists, and invalidates internal cache. This method is designed to call it when a build configuration is being deleted.- Specified by:
removeBuildTypeFromAllListsin interfaceAgentTypeStorage- Parameters:
buildTypeId- build configuration identifier.
-
copyAgentTypeRestrictions
public void copyAgentTypeRestrictions(@NotNull String originalBuildTypeId, @NotNull String newBuildTypeId)- Specified by:
copyAgentTypeRestrictionsin interfaceAgentTypeStorage
-
invalidateCacheForAllAgentTypes
public void invalidateCacheForAllAgentTypes()
- Specified by:
invalidateCacheForAllAgentTypesin interfaceAgentTypeStorage
-
invalidateCacheForAgentTypesFromPools
public void invalidateCacheForAgentTypesFromPools(@NotNull Set<Integer> agentPoolIds, @NotNull CacheClearPolicy policy)- Specified by:
invalidateCacheForAgentTypesFromPoolsin interfaceAgentTypeStorage
-
invalidateCacheForOneAgentType
public void invalidateCacheForOneAgentType(int agentTypeId, @NotNull CacheClearPolicy policy)- Specified by:
invalidateCacheForOneAgentTypein interfaceAgentTypeStorage
-
updateAgentTypeFromDB
public void updateAgentTypeFromDB(int agentTypeId)
- Specified by:
updateAgentTypeFromDBin interfaceAgentTypeStorage
-
deleteAgentType
public void deleteAgentType(int agentTypeId)
- Specified by:
deleteAgentTypein interfaceAgentTypeStorage
-
updateAgentType
public void updateAgentType(@NotNull BuildAgentEx agent, boolean allowDeleteParams)Description copied from interface:AgentTypeManagerupdates agent type parameters from the agent's parameters- Specified by:
updateAgentTypein interfaceAgentTypeManager- Parameters:
agent- the agentallowDeleteParams- if then this is the update of agent type parameters when the agent is first registered, if false then this is a periodical update which happens while the agent is already registered and runs some builds
-
updateAgentType
public void updateAgentType(int agentTypeId, @NotNull AgentDescription agentDescription, boolean allowDeleteParams)Description copied from interface:AgentTypeManagerupdates agent type parameters from the agent's parameters- Specified by:
updateAgentTypein interfaceAgentTypeManager- Parameters:
agentTypeId- agent type idagentDescription- agent description
-
assignAgentType
public int assignAgentType(@NotNull BuildAgentEx agent)Description copied from interface:AgentTypeManagerCreates agent type for specified agent if agent does not have one and assigns it to the agent.- Specified by:
assignAgentTypein interfaceAgentTypeManager- Returns:
- id of new agent type
-
getOrCreateAgentTypeId
public int getOrCreateAgentTypeId(@NotNull AgentTypeKey key)Description copied from interface:AgentTypeManagersimilar toAgentTypeManager.getOrCreateAgentTypeId(jetbrains.buildServer.serverSide.agentTypes.AgentTypeKey, int), puts agentType to the "Default" pool, if it doesn't exist- Specified by:
getOrCreateAgentTypeIdin interfaceAgentTypeManager- Specified by:
getOrCreateAgentTypeIdin interfaceAgentTypeStorage- Parameters:
key- agent type key which identifier is requested.- Returns:
- agent type identifier.
-
getOrCreateAgentTypeId
public int getOrCreateAgentTypeId(@NotNull AgentTypeKey key, int defaultRawPoolId)Description copied from interface:AgentTypeManagerMaps created agent type key into agentTypeId. This method should lookup to the storage or allocate new item.- Specified by:
getOrCreateAgentTypeIdin interfaceAgentTypeManager- Specified by:
getOrCreateAgentTypeIdin interfaceAgentTypeStorage- Parameters:
key- agent type key received from plugindefaultRawPoolId- raw pool id to assign agent type to, if one doesn't exist.- Returns:
- agent type id
-
includeRunConfigurationsToAllowed
public void includeRunConfigurationsToAllowed(int agentTypeId, @NotNull String[] buildTypeIds)- Specified by:
includeRunConfigurationsToAllowedin interfaceAgentTypeManager
-
excludeRunConfigurationsFromAllowed
public void excludeRunConfigurationsFromAllowed(int agentTypeId, @NotNull String[] buildTypeIds)- Specified by:
excludeRunConfigurationsFromAllowedin interfaceAgentTypeManager
-
getCanRunConfigurations
@NotNull public Set<String> getCanRunConfigurations(int agentTypeId)
- Specified by:
getCanRunConfigurationsin interfaceAgentTypeManager
-
isCanRunConfiguration
public boolean isCanRunConfiguration(int agentTypeId, @NotNull BuildTypeDescriptor buildType)- Specified by:
isCanRunConfigurationin interfaceAgentTypeManager
-
getNumberOfCompatibleConfigurations
public int getNumberOfCompatibleConfigurations(@NotNull SAgentType agentType)- Specified by:
getNumberOfCompatibleConfigurationsin interfaceAgentTypeManager
-
getNumberOfIncompatibleConfigurations
public int getNumberOfIncompatibleConfigurations(@NotNull SAgentType agentType)- Specified by:
getNumberOfIncompatibleConfigurationsin interfaceAgentTypeManager
-
getAgentTypeCompatibilities
@NotNull public List<AgentCompatibility> getAgentTypeCompatibilities(@NotNull SAgentType agentType)
- Specified by:
getAgentTypeCompatibilitiesin interfaceAgentTypeManager
-
copyAgentTypeRestrictions
public void copyAgentTypeRestrictions(@NotNull BuildTypeDescriptor originalBuildType, @NotNull BuildTypeDescriptor newBuildType)- Specified by:
copyAgentTypeRestrictionsin interfaceAgentTypeManager
-
migrateAgentTypeKey
public void migrateAgentTypeKey(@NotNull AgentTypeKey currentKey, @NotNull AgentTypeKey newKey)- Specified by:
migrateAgentTypeKeyin interfaceAgentTypeManager
-
-