Search in sources :

Example 1 with DocString

use of gherkin.ast.DocString in project cucable-plugin by trivago.

the class GherkinToCucableConverter method convertGherkinStepsToCucableSteps.

/**
 * Converts a list of Gherkin steps to Cucable steps including data tables.
 *
 * @param gherkinSteps a {@link Step} list.
 * @return a {@link com.trivago.rta.vo.Step} list.
 */
List<com.trivago.rta.vo.Step> convertGherkinStepsToCucableSteps(final List<Step> gherkinSteps) {
    List<com.trivago.rta.vo.Step> steps = new ArrayList<>();
    for (Step gherkinStep : gherkinSteps) {
        com.trivago.rta.vo.Step step;
        com.trivago.rta.vo.DataTable dataTable = null;
        String docString = null;
        Node argument = gherkinStep.getArgument();
        if (argument instanceof DataTable) {
            dataTable = convertGherkinDataTableToCucumberDataTable((DataTable) argument);
        } else if (argument instanceof DocString) {
            docString = ((DocString) argument).getContent();
        }
        String keywordAndName = gherkinStep.getKeyword().concat(gherkinStep.getText());
        step = new com.trivago.rta.vo.Step(keywordAndName, dataTable, docString);
        steps.add(step);
    }
    return steps;
}
Also used : DataTable(gherkin.ast.DataTable) Node(gherkin.ast.Node) ArrayList(java.util.ArrayList) Step(gherkin.ast.Step) DocString(gherkin.ast.DocString) DocString(gherkin.ast.DocString)

Example 2 with DocString

use of gherkin.ast.DocString in project page-factory-2 by sbtqa.

the class GherkinSerializer method buildStep.

private void buildStep(Step step) {
    tab(2);
    builder.append(step.getKeyword()).append(SPACE).append(step.getText());
    if (step.getArgument() != null) {
        nl(1);
        if (step.getArgument() instanceof DataTable) {
            DataTable table = (DataTable) step.getArgument();
            table.getRows().forEach(this::buildTableRow);
        } else if (step.getArgument() instanceof DocString) {
            tab(2);
            builder.append("\"\"\"");
            nl(1);
            DocString docString = (DocString) step.getArgument();
            tab(2);
            builder.append(docString.getContent());
            nl(1);
            tab(2);
            builder.append("\"\"\"");
            nl(1);
        }
    } else {
        builder.append("\n");
    }
}
Also used : DataTable(gherkin.ast.DataTable) DocString(gherkin.ast.DocString)

Example 3 with DocString

use of gherkin.ast.DocString in project cucable-plugin by trivago.

the class GherkinToCucableConverter method convertGherkinStepsToCucableSteps.

/**
 * Converts a list of Gherkin steps to Cucable steps including data tables.
 *
 * @param gherkinSteps a {@link Step} list.
 * @return a {@link com.trivago.vo.Step} list.
 */
List<com.trivago.vo.Step> convertGherkinStepsToCucableSteps(final List<Step> gherkinSteps) {
    List<com.trivago.vo.Step> steps = new ArrayList<>();
    for (Step gherkinStep : gherkinSteps) {
        com.trivago.vo.Step step;
        com.trivago.vo.DataTable dataTable = null;
        String docString = null;
        Node argument = gherkinStep.getArgument();
        if (argument instanceof DataTable) {
            dataTable = convertGherkinDataTableToCucableDataTable((DataTable) argument);
        } else if (argument instanceof DocString) {
            docString = ((DocString) argument).getContent();
        }
        String keywordAndName = gherkinStep.getKeyword().concat(gherkinStep.getText());
        step = new com.trivago.vo.Step(keywordAndName, dataTable, docString);
        steps.add(step);
    }
    return steps;
}
Also used : DataTable(gherkin.ast.DataTable) Node(gherkin.ast.Node) ArrayList(java.util.ArrayList) DocString(gherkin.ast.DocString) Step(gherkin.ast.Step) DocString(gherkin.ast.DocString)

Aggregations

DataTable (gherkin.ast.DataTable)3 DocString (gherkin.ast.DocString)3 Node (gherkin.ast.Node)2 Step (gherkin.ast.Step)2 ArrayList (java.util.ArrayList)2