Package com.privalia.qa.aspects
Class ReplacementAspect
- java.lang.Object
-
- com.privalia.qa.aspects.ReplacementAspect
-
public final class ReplacementAspect extends Object
Aspect to replace variables used in the feature files- Author:
- Jose Fernandez
-
-
Constructor Summary
Constructors Constructor Description ReplacementAspect()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
aroundReplacementArguments(org.aspectj.lang.JoinPoint jp, io.cucumber.core.backend.TestCaseState state)
When a step is about to be executed, the Match#getArguments method is called.static org.apache.commons.text.StringSubstitutor
getInterpolator()
protected void
replacementArguments(io.cucumber.core.backend.TestCaseState state)
static String
replacePlaceholders(String element, boolean setEnableUndefinedVariableException)
Replaces every placeholder element, enclosed in ${} with the corresponding value
-
-
-
Method Detail
-
getInterpolator
public static org.apache.commons.text.StringSubstitutor getInterpolator()
-
replacementArguments
protected void replacementArguments(io.cucumber.core.backend.TestCaseState state)
-
aroundReplacementArguments
public void aroundReplacementArguments(org.aspectj.lang.JoinPoint jp, io.cucumber.core.backend.TestCaseState state) throws NoSuchFieldException, IllegalAccessException, FileNotFoundException, NonReplaceableException, org.apache.commons.configuration2.ex.ConfigurationException, URISyntaxException
When a step is about to be executed, the Match#getArguments method is called. this function retrieves the the arguments that are going to be used when executing the glue method.This method captures this event and replaces the variables with their appropriate value using reflection
- Parameters:
jp
- the jpstate
- the state- Throws:
NoSuchFieldException
- the no such field exceptionIllegalAccessException
- the illegal access exceptionFileNotFoundException
- the file not found exceptionNonReplaceableException
- the non replaceable exceptionorg.apache.commons.configuration2.ex.ConfigurationException
- the configuration exceptionURISyntaxException
- the uri syntax exception
-
replacePlaceholders
public static String replacePlaceholders(String element, boolean setEnableUndefinedVariableException) throws NonReplaceableException
Replaces every placeholder element, enclosed in ${} with the corresponding value- Parameters:
element
- element to be replacedsetEnableUndefinedVariableException
- whether an exception should be thrown is a variable could not be replaced- Returns:
- String
- Throws:
NonReplaceableException
- exception
-
-