Search in sources :

Example 6 with DataTable

use of gherkin.ast.DataTable 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 7 with DataTable

use of gherkin.ast.DataTable 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)7 ArrayList (java.util.ArrayList)5 DocString (gherkin.ast.DocString)4 Node (gherkin.ast.Node)3 Step (gherkin.ast.Step)3 TableCell (gherkin.ast.TableCell)3 TableRow (gherkin.ast.TableRow)3 Map (java.util.Map)2 HashMap (java.util.HashMap)1