Search in sources :

Example 1 with PickleString

use of gherkin.pickles.PickleString in project page-factory-2 by sbtqa.

the class DataReplacer method replacePickleArguments.

private void replacePickleArguments(PickleStepTestStep currentStep, boolean isStash) throws IllegalAccessException {
    PickleStepTag pickleStepTag = (PickleStepTag) currentStep.getPickleStep();
    for (gherkin.pickles.Argument argument : currentStep.getPickleStep().getArgument()) {
        if (argument.getClass().equals(PickleTable.class)) {
            replacePickleTable(pickleStepTag, (PickleTable) argument, isStash);
        } else if (argument.getClass().equals(PickleString.class)) {
            String content = replaceData(pickleStepTag, ((PickleString) argument).getContent(), isStash);
            FieldUtils.writeField(argument, "content", content, true);
        }
    }
    Object definitionMatchArguments = FieldUtils.readField(FieldUtils.readField(currentStep, "definitionMatch", true), "arguments", true);
    if (definitionMatchArguments instanceof ArrayList) {
        for (Object definitionMatchArgument : (ArrayList) definitionMatchArguments) {
            if (definitionMatchArgument instanceof DataTableArgument) {
                List<List<String>> newDefinitionMatchArgument = replaceDataTable(definitionMatchArgument, currentStep, isStash);
                FieldUtils.writeField(definitionMatchArgument, "argument", newDefinitionMatchArgument, true);
            } else if (definitionMatchArgument instanceof DocStringArgument) {
                String newDefinitionMatchArgument = replaceData((PickleStepTag) currentStep.getPickleStep(), ((DocStringArgument) definitionMatchArgument).getValue().toString(), isStash);
                FieldUtils.writeField(definitionMatchArgument, "argument", newDefinitionMatchArgument, true);
            }
        }
    }
}
Also used : PickleStepTag(ru.sbtqa.tag.pagefactory.optional.PickleStepTag) ArrayList(java.util.ArrayList) DataTableArgument(io.cucumber.stepexpression.DataTableArgument) ArrayList(java.util.ArrayList) List(java.util.List) PickleString(gherkin.pickles.PickleString) PickleString(gherkin.pickles.PickleString) DocStringArgument(io.cucumber.stepexpression.DocStringArgument)

Aggregations

PickleString (gherkin.pickles.PickleString)1 DataTableArgument (io.cucumber.stepexpression.DataTableArgument)1 DocStringArgument (io.cucumber.stepexpression.DocStringArgument)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 PickleStepTag (ru.sbtqa.tag.pagefactory.optional.PickleStepTag)1