org.specrunner.plugins.core.flow
Class PluginIf

java.lang.Object
  extended by org.specrunner.parameters.core.ParameterHolder
      extended by org.specrunner.plugins.core.AbstractPlugin
          extended by org.specrunner.plugins.core.AbstractPluginNamed
              extended by org.specrunner.plugins.core.AbstractPluginScoped
                  extended by org.specrunner.plugins.core.AbstractPluginValue
                      extended by org.specrunner.plugins.core.flow.PluginIf
All Implemented Interfaces:
IParameterHolder, IActionType, IParalelPlugin, IPlugin, ISleepPlugin, ITestPlugin, ITimedPlugin, IWaitPlugin

public class PluginIf
extends AbstractPluginValue

Create a condition execution.

Example of condition:

  Consider x is positive the message is "Positive" 
      else something different happens and the message is "Negative".
 

With CSS annotations could be:

  Consider <span class="if" value="${x > 0}">x is positive<span> 
      the message is "<span class="then">Positive<span>" 
      else something different happens and the message is "<span class="else">Negative<span>".
 
With complex descriptions, the order can be different and the group of 'if'/'then'/'else' can be named to avoid interferences of others if/then/else.

Example1:

  Consider <span class="if" value="${x > 0}" name="test1">x is positive<span> 
      the message is "<span class="then" name="test1">Positive<span>" 
      else something different happens and the message is "<span class="else" name="test1">Negative<span>".
 
Example2:
  Consider <span class="if" value="${x > 0}" >x is positive<span> 
  Consider <span class="if" value="${y > 0}" name="testY">y is negative<span>
      
  the message for x is "<span class="then" name="test1">Positive<span>" 
  the message for y is "<span class="then" name="testY">Positive<span>" 
  else something different happens and the message for x is "<span class="else">Negative<span>".
  else something different happens and the message for y is "<span class="else" name="testY">Negative<span>".
 

Author:
Thiago Santos

Field Summary
static String TEST_NAME
          The conditional default name.
 
Fields inherited from class org.specrunner.plugins.core.AbstractPlugin
FEATURE_CONDITION, FEATURE_NORMALIZED, FEATURE_SLEEP, FEATURE_THREADSAFE, FEATURE_TIMEOUT, FEATURE_WAIT
 
Constructor Summary
PluginIf()
           
 
Method Summary
 ENext doStart(IContext context, IResultSet result)
          Performs the start action. i.e. create a database schema.
 ActionType getActionType()
          Get the plugin type.
static Boolean getTest(IContext context, String name)
          Gets the previously calculated condition with the given name.
 
Methods inherited from class org.specrunner.plugins.core.AbstractPluginValue
getValue, getValue, isEval, setEval, setValue
 
Methods inherited from class org.specrunner.plugins.core.AbstractPluginScoped
getScope, saveGlobal, saveLocal, saveStrict, setScope
 
Methods inherited from class org.specrunner.plugins.core.AbstractPluginNamed
getName, setName
 
Methods inherited from class org.specrunner.plugins.core.AbstractPlugin
copy, doEnd, getCondition, getConditionModel, getNormalized, getNormalized, getParent, getSleep, getSleepModel, getThreadsafe, getTimeout, getTimeoutModel, getWait, getWaitModel, initialize, setCondition, setConditionModel, setNormalized, setParent, setSleep, setSleepModel, setThreadsafe, setTimeout, setTimeoutModel, setWait, setWaitModel, toString
 
Methods inherited from class org.specrunner.parameters.core.ParameterHolder
getParameters, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.specrunner.parameters.IParameterHolder
getParameters, setParameters
 

Field Detail

TEST_NAME

public static final String TEST_NAME
The conditional default name. To use another name use 'name' attribute.

See Also:
Constant Field Values
Constructor Detail

PluginIf

public PluginIf()
Method Detail

getActionType

public ActionType getActionType()
Description copied from interface: IActionType
Get the plugin type.

Returns:
The type.

doStart

public ENext doStart(IContext context,
                     IResultSet result)
              throws PluginException
Description copied from interface: IPlugin
Performs the start action. i.e. create a database schema. Performed after initialization.

Specified by:
doStart in interface IPlugin
Overrides:
doStart in class AbstractPlugin
Parameters:
context - The context.
result - The result set.
Returns:
SKIP, to skip node, DEEP, to go deep into the node.
Throws:
PluginException - On execution errors.

getTest

public static Boolean getTest(IContext context,
                              String name)
                       throws PluginException
Gets the previously calculated condition with the given name.

Parameters:
context - The context.
name - The test name.
Returns:
true, if test passed, false, otherwise.
Throws:
PluginException - On lookup errors.


Copyright © 2014. All rights reserved.