Class AbstractManager
- All Implemented Interfaces:
IManager
- Direct Known Subclasses:
AbstractGherkinManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected <T> T
addDependentManager
(@NotNull List<IManager> allManagers, @NotNull List<IManager> activeManagers, @NotNull GalasaTest galasaTest, @NotNull Class<T> dependentInterface) Helper method to find managers that implement an interface and tell them they are requiredShould the test class be run at all? Used to set the Test Class to Ignored.anyReasonTestMethodShouldBeIgnored
(@NotNull GalasaMethod galasaMethod) Should the Test Method be run at all? Used to set the Test Method to Ignored.boolean
areYouProvisionalDependentOn
(@NotNull IManager otherManager) Is this Manager dependent on the other Manager.static String
defaultString
(String value, String defaultValue) boolean
The framework will check each manager during Shared Environment Build to see if they support shared environments.endOfTestClass
(@NotNull Result currentResult, Throwable currentException) Called when the Test Class has finishedendOfTestMethod
(@NotNull GalasaMethod galasaMethod, @NotNull Result currentResult, Throwable currentException) Called when the Test Method has finishedvoid
About to shutdown everythingextraBundles
(@NotNull IFramework framework) Gives the ability for the Manager to request additional bundles to be loaded dependent of CPS Properties.void
fillAnnotatedFields
(Object instanstiatedTestClass) Fill/refill the annotated fields that belong to this Manager.protected List<AnnotatedField>
findAnnotatedFields
(Class<? extends Annotation> managerAnnotation) Helper method to obtain a list of annotated fields this manager is interested in.findProvisionDependentAnnotatedFieldTags
(@NotNull Class<? extends Annotation> managerAnnotation, @NotNull String attributeName) Used to locate the TAG names used in Annotations that indicate a dependency on a Manager.protected void
generateAnnotatedFields
(Class<? extends Annotation> managerAnnotation) Will callGenerateAnnotatedField
methods in the parent class to generate instances for each of the Test Class fields The annotated methods in the parent class must: be public return the interface of the field annotation have 2 parameters ofField
andList
protected Object
getAnnotatedField
(Field field) Retrieve the generated object for an annotated fieldClass<?>
void
initialise
(@NotNull IFramework framework, @NotNull List<IManager> allManagers, @NotNull List<IManager> activeManagers, @NotNull GalasaTest galasaTest) Initialise the Manager, if required.static String
null a String is if it is empty TODO Needs to be moved to a more appropriate place as non managers use this, a stringutils maybevoid
Can be used to perform Failure Analysis at this point and record the results in the RAS.void
Build everything that is needed for this Test Run.void
Discard the provisioned environment.void
Provision resource names, resource pools, settings etc, ready for building.void
Start the provisioned environment.void
Stop the provisioned environment.protected void
registerAnnotatedField
(Field field, Object value) Register an Manager annotated field, for automatic filling during fillAnnotatedFields()void
shutdown()
Gives the Managers the opportunity to close everything down like http clients etc.void
Called when we have instantiated the Test Class and ready to start running it.void
startOfTestMethod
(@NotNull GalasaMethod galasaMethod) Called when we are about to start the Test Method.void
testClassResult
(@NotNull String finalResult, Throwable finalException) Called once the Test Class result is resolved, can be used to emit the result to another server, for examplevoid
testMethodResult
(@NotNull String finalResult, Throwable finalException) Called once the Test Method result is resolved, can be used to emit the result to another server, for examplevoid
youAreRequired
(@NotNull List<IManager> allManagers, @NotNull List<IManager> activeManagers, @NotNull GalasaTest galasaTest) Called if another Manager requires this one.
-
Constructor Details
-
AbstractManager
public AbstractManager()
-
-
Method Details
-
registerAnnotatedField
Register an Manager annotated field, for automatic filling during fillAnnotatedFields()- Parameters:
field
- The field to fillvalue
- The
-
getAnnotatedField
Retrieve the generated object for an annotated field- Parameters:
field
- field to retrieve- Returns:
- the generated object or null if it has not been generated yet
-
findAnnotatedFields
Helper method to obtain a list of annotated fields this manager is interested in.
This method will return a list of fields that has an annotation that is in turn annotated with the managerAnnotation
- Parameters:
managerAnnotation
- - The annotation that other annotations are annotated with.- Returns:
- A list of fields the manager should be interested in
-
generateAnnotatedFields
protected void generateAnnotatedFields(Class<? extends Annotation> managerAnnotation) throws ResourceUnavailableException, ManagerException Will callGenerateAnnotatedField
methods in the parent class to generate instances for each of the Test Class fields The annotated methods in the parent class must:- Parameters:
managerAnnotation
- The Annotation for those annotated fields we are interested in- Throws:
ManagerException
ResourceUnavailableException
-
findProvisionDependentAnnotatedFieldTags
@NotNull protected @NotNull Set<String> findProvisionDependentAnnotatedFieldTags(@NotNull @NotNull Class<? extends Annotation> managerAnnotation, @NotNull @NotNull String attributeName) Used to locate the TAG names used in Annotations that indicate a dependency on a Manager. See ZosImageDependencyField as an example. Where ZosImageDependencyField is annotated on a Manager field annotation, zOS Manager will ask for the imageTag attribute value. zOS Manager will then provision as appropriate for each of the returned tags, which means the means the tester does not need to code a ZosImage for every image the test wants. For example CICSRegion(imageTag="a") will cause the zOS Manager to provision an image for tag "a" without the ZosImage(imageTag="a")- Parameters:
managerAnnotation
- the dependency annotationattributeName
- the name of the attribute on the annotation that returns a String only- Returns:
- the tags found from the dependency annotations and the attribute, uppercased
-
extraBundles
Description copied from interface:IManager
Gives the ability for the Manager to request additional bundles to be loaded dependent of CPS Properties. This can be used to load OSGi fragment bundles for implements of the TPI/SPI this Manager provides.
For example, the zOS Manager provides the zOS Batch Manager TPI. This TPI can be provided via various means, the default being zOS/MF, which is implemented by the zOS Batch zOSMF Manager. The zOS Manager can look at the CPS to determine which "fragment" should used to implement the the TPI
This method is called only once during the lifecycle and should not be dependent on what is in the Test Class
- Specified by:
extraBundles
in interfaceIManager
- Parameters:
framework
- Full initialised Framework- Returns:
- null for no extra bundles, or a
List
contain the symbolic names of the bundles to load - Throws:
ManagerException
-
initialise
public void initialise(@NotNull @NotNull IFramework framework, @NotNull @NotNull List<IManager> allManagers, @NotNull @NotNull List<IManager> activeManagers, @NotNull @NotNull GalasaTest galasaTest) throws ManagerException Description copied from interface:IManager
Initialise the Manager, if required. The Manager should examine the testClass and see if this manager should participate in the Test Run lifecycle. If the Manager needs to take part, it should add itself to the activeManager. A Manager add itself only to the activeManagers.
If a Manager is dependent on another Manager, it should look for implementers in allManager and call the youAreRequired method of the other Manager. If the required Manager has not yet been initialised, it should flag the youAreRequired call for when the Manager is initialised
This will be the only time the testClass is passed to the Manager, so should be preserved
- Specified by:
initialise
in interfaceIManager
- Parameters:
framework
- A fully initialised Framework - preserve it for later useallManagers
- All Managers found in OSGiactiveManagers
- The Manager should add itself to this list if it is to be activated. Do not add other managers.galasaTest
- The Test class the framework will be running- Throws:
ManagerException
- If there is a problem initialising the Manager
-
getFramework
- Returns:
- The Framework
-
getTestClass
- Returns:
- The Test Class
-
youAreRequired
public void youAreRequired(@NotNull @NotNull List<IManager> allManagers, @NotNull @NotNull List<IManager> activeManagers, @NotNull @NotNull GalasaTest galasaTest) throws ManagerException Description copied from interface:IManager
Called if another Manager requires this one. If this Manager has not been initialised yet, this call should be flagged until it the initialise method is called
If the Manager has previously been intialised, but believed it wasn't required, then it should drive the initialise routines now.
- Specified by:
youAreRequired
in interfaceIManager
- Parameters:
allManagers
- All Managers found in OSGiactiveManagers
- The Manager should add itself to this list if it is to be activated. Do not add other managers.galasaTest
- The Test class the framework will be running- Throws:
ManagerException
-
areYouProvisionalDependentOn
Description copied from interface:IManager
Is this Manager dependent on the other Manager. Basically, return true if you require the other Manager at all during the provision* lifecycle methods.- Specified by:
areYouProvisionalDependentOn
in interfaceIManager
- Parameters:
otherManager
- The other Manager- Returns:
- true this Manager is provisionally dependent on the other Manager
-
anyReasonTestClassShouldBeIgnored
Description copied from interface:IManager
Should the test class be run at all? Used to set the Test Class to Ignored. Examples of use would be if the CICS TS Version is too low for the functionality this Test is testing
- Specified by:
anyReasonTestClassShouldBeIgnored
in interfaceIManager
- Returns:
- - Return a descriptive text string for the reason the Test should be ignored
- Throws:
ManagerException
- - Just in case something goes wrong, eg CPS
-
provisionGenerate
Description copied from interface:IManager
Provision resource names, resource pools, settings etc, ready for building.
No building should occur during this process. Only resolution activities should occur so all managers indicate they have all the resources they require before attempting to build anything. If a manager is unable to acquire any resource, it should throw ResourceUnavailableException and the Test Run will be put into Waiting state for a later retry, if in Automation
- Specified by:
provisionGenerate
in interfaceIManager
- Throws:
ManagerException
- If anything goes wrongResourceUnavailableException
- IF resources are unavailable for this run
-
provisionBuild
Description copied from interface:IManager
Build everything that is needed for this Test Run. The Managers will be called in the order resolved by the areYouProvisionalDependentOn method.
If this method fails, the Test Run will fail with Environmental Failure, unless ResourceUnavailableException is thrown, where it is assumed it is a temporary condition and the run will be put into Waiting state if in Automation.
- Specified by:
provisionBuild
in interfaceIManager
- Throws:
ManagerException
- If unable to build the environmentResourceUnavailableException
-
provisionStart
Description copied from interface:IManager
Start the provisioned environment. The Managers will be called in the order resolved by the areYouProvisionalDependentOn method.
If this method fails, the Test Run will fail with Environmental Failure, unless ResourceUnavailableException is thrown, where it is assumed it is a temporary condition and the run will be put into Waiting state if in Automation.
- Specified by:
provisionStart
in interfaceIManager
- Throws:
ManagerException
- If unable to start the environmentResourceUnavailableException
-
startOfTestClass
Description copied from interface:IManager
Called when we have instantiated the Test Class and ready to start running it.
- Specified by:
startOfTestClass
in interfaceIManager
- Throws:
ManagerException
- On the off chance something when wrong
-
fillAnnotatedFields
Description copied from interface:IManager
Fill/refill the annotated fields that belong to this Manager. This is called before the start of every Test Method just incase the tester decided to overwrite the field.- Specified by:
fillAnnotatedFields
in interfaceIManager
- Parameters:
instanstiatedTestClass
- The Instantiated Test class to fill- Throws:
ManagerException
- On the off chance something when wrong
-
anyReasonTestMethodShouldBeIgnored
public String anyReasonTestMethodShouldBeIgnored(@NotNull @NotNull GalasaMethod galasaMethod) throws ManagerException Description copied from interface:IManager
Should the Test Method be run at all? Used to set the Test Method to Ignored. Examples of use would be if the CICS TS version is too low for the functionality this Test Method is testing
- Specified by:
anyReasonTestMethodShouldBeIgnored
in interfaceIManager
- Returns:
- - Return a descriptive text string for the reason the Test Method should be ignored
- Throws:
ManagerException
- - Just in case something goes wrong, eg CPS
-
startOfTestMethod
Description copied from interface:IManager
Called when we are about to start the Test Method.- Specified by:
startOfTestMethod
in interfaceIManager
- Parameters:
galasaMethod
- The current executing method- Throws:
ManagerException
- On the off chance something when wrong
-
endOfTestMethod
public Result endOfTestMethod(@NotNull @NotNull GalasaMethod galasaMethod, @NotNull @NotNull Result currentResult, Throwable currentException) throws ManagerException Description copied from interface:IManager
Called when the Test Method has finished
If the Manager would like to override the result, it can return the result it wishes to be used for the record
- Specified by:
endOfTestMethod
in interfaceIManager
- Parameters:
galasaMethod
- The current test methodcurrentResult
- What the current result is, will not include what the other Managers wish it to be.currentException
- What the current Exception is- Returns:
- Override the test result, or null if ok
- Throws:
ManagerException
- If something went wrong
-
testMethodResult
public void testMethodResult(@NotNull @NotNull String finalResult, Throwable finalException) throws ManagerException Description copied from interface:IManager
Called once the Test Method result is resolved, can be used to emit the result to another server, for example
- Specified by:
testMethodResult
in interfaceIManager
- Parameters:
finalResult
- The final resolved resultfinalException
- The Exception- Throws:
ManagerException
- If something went wrong with recording the result
-
endOfTestClass
public Result endOfTestClass(@NotNull @NotNull Result currentResult, Throwable currentException) throws ManagerException Description copied from interface:IManager
Called when the Test Class has finished
If the Manager would like to override the result, it can return the result it wishes to be used for the record
- Specified by:
endOfTestClass
in interfaceIManager
- Parameters:
currentResult
- What the current result is, will not include what the other Managers wish it to be.currentException
- What the current Exception is- Returns:
- Override the test result, or null if ok
- Throws:
ManagerException
- If something went wrong
-
testClassResult
public void testClassResult(@NotNull @NotNull String finalResult, Throwable finalException) throws ManagerException Description copied from interface:IManager
Called once the Test Class result is resolved, can be used to emit the result to another server, for example
- Specified by:
testClassResult
in interfaceIManager
- Parameters:
finalResult
- The final resolved resultfinalException
- The Exception- Throws:
ManagerException
- If something went wrong with recording the result
-
provisionStop
public void provisionStop()Description copied from interface:IManager
Stop the provisioned environment. Called in reverse provide dependent order.
Called after recording the Test Class result as failure here should not affect the Test result
- Specified by:
provisionStop
in interfaceIManager
-
provisionDiscard
public void provisionDiscard()Description copied from interface:IManager
Discard the provisioned environment. Called in reverse provide dependent order.
The Manager is free to clean up resources at this point, if it is reasonably quick so that it doesn't slow the throughput of Tests through the automation system and can be executed under the Testers credentials if running locally.
- Specified by:
provisionDiscard
in interfaceIManager
-
performFailureAnalysis
public void performFailureAnalysis()Description copied from interface:IManager
Can be used to perform Failure Analysis at this point and record the results in the RAS.
- Specified by:
performFailureAnalysis
in interfaceIManager
-
endOfTestRun
public void endOfTestRun()Description copied from interface:IManager
About to shutdown everything
- Specified by:
endOfTestRun
in interfaceIManager
-
addDependentManager
protected <T> T addDependentManager(@NotNull @NotNull List<IManager> allManagers, @NotNull @NotNull List<IManager> activeManagers, @NotNull @NotNull GalasaTest galasaTest, @NotNull @NotNull Class<T> dependentInterface) throws ManagerException Helper method to find managers that implement an interface and tell them they are required- Parameters:
allManagers
- All available managersactiveManagers
- The currently active managersdependentInterface
- The interface the manager needs to implement- Returns:
- Throws:
ManagerException
- If the required manager can't be added to the active list
-
nulled
null a String is if it is empty TODO Needs to be moved to a more appropriate place as non managers use this, a stringutils maybe- Parameters:
value
-- Returns:
- a trimmed String or a null if emtpy or null
-
split
-
defaultString
-
trim
-
shutdown
public void shutdown()Description copied from interface:IManager
Gives the Managers the opportunity to close everything down like http clients etc. Managers must not call other Managers in this method as they may have shutdown already. Calls to the Framework, CPS, RAS etc will be safe.
-