Search in sources :

Example 1 with Argument

use of io.cucumber.stepexpression.Argument in project page-factory-2 by sbtqa.

the class CriticalStepAspect method argumentOffset.

@Around(value = "argumentOffset(arguments, stepDefinition, featurePath, step)", argNames = "joinPoint,arguments,stepDefinition,featurePath,step")
public Object argumentOffset(ProceedingJoinPoint joinPoint, List<Argument> arguments, StepDefinition stepDefinition, String featurePath, PickleStep step) throws Throwable {
    for (Argument argument : arguments) {
        if (argument instanceof ExpressionArgument && hasReplaceableArgument(step, argument)) {
            int start = ((ExpressionArgument) argument).getGroup().getStart();
            int end = ((ExpressionArgument) argument).getGroup().getEnd();
            int offset = NON_CRITICAL.length();
            FieldUtils.writeField(FieldUtils.readField(FieldUtils.readField(argument, "argument", true), "group", true), "start", start + offset, true);
            FieldUtils.writeField(FieldUtils.readField(FieldUtils.readField(argument, "argument", true), "group", true), "end", end + offset, true);
        }
    }
    return joinPoint.proceed();
}
Also used : Argument(io.cucumber.stepexpression.Argument) ExpressionArgument(io.cucumber.stepexpression.ExpressionArgument) ExpressionArgument(io.cucumber.stepexpression.ExpressionArgument) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Around(org.aspectj.lang.annotation.Around)

Aggregations

Argument (io.cucumber.stepexpression.Argument)1 ExpressionArgument (io.cucumber.stepexpression.ExpressionArgument)1 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)1 Around (org.aspectj.lang.annotation.Around)1