gherkin.ast.Node Java Examples

The following examples show how to use gherkin.ast.Node. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestSourcesModel.java    From extentreports-cucumber4-adapter with Apache License 2.0 6 votes vote down vote up
static String calculateId(AstNode astNode) {
    Node node = astNode.node;
    if (node instanceof ScenarioDefinition) {
        return calculateId(astNode.parent) + ";" + convertToId(((ScenarioDefinition) node).getName());
    }
    if (node instanceof ExamplesRowWrapperNode) {
        return calculateId(astNode.parent) + ";" + Integer.toString(((ExamplesRowWrapperNode) node).bodyRowIndex + 2);
    }
    if (node instanceof TableRow) {
        return calculateId(astNode.parent) + ";" + Integer.toString(1);
    }
    if (node instanceof Examples) {
        return calculateId(astNode.parent) + ";" + convertToId(((Examples) node).getName());
    }
    if (node instanceof Feature) {
        return convertToId(((Feature) node).getName());
    }
    return "";
}
 
Example #2
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 6 votes vote down vote up
private void processScenarioOutlineExamples(
        final Map<Integer, AstNode> nodeMap, final ScenarioOutline scenarioOutline, final AstNode childNode
) {
    scenarioOutline.getExamples().forEach(examples -> {
        final AstNode examplesNode = new AstNode(examples, childNode);
        final TableRow headerRow = examples.getTableHeader();
        final AstNode headerNode = new AstNode(headerRow, examplesNode);
        nodeMap.put(headerRow.getLocation().getLine(), headerNode);
        IntStream.range(0, examples.getTableBody().size()).forEach(i -> {
            final TableRow examplesRow = examples.getTableBody().get(i);
            final Node rowNode = new CucumberSourceUtils.ExamplesRowWrapperNode(examplesRow, i);
            final AstNode expandedScenarioNode = new AstNode(rowNode, examplesNode);
            nodeMap.put(examplesRow.getLocation().getLine(), expandedScenarioNode);
        });
    });
}
 
Example #3
Source File: TestSourcesModel.java    From allure-java with Apache License 2.0 6 votes vote down vote up
private void processScenarioOutlineExamples(final Map<Integer, AstNode> nodeMap,
                                            final ScenarioOutline scenarioOutline,
                                            final AstNode childNode) {
    for (Examples examples : scenarioOutline.getExamples()) {
        final AstNode examplesNode = createAstNode(examples, childNode);
        final TableRow headerRow = examples.getTableHeader();
        final AstNode headerNode = createAstNode(headerRow, examplesNode);
        nodeMap.put(headerRow.getLocation().getLine(), headerNode);
        for (int i = 0; i < examples.getTableBody().size(); ++i) {
            final TableRow examplesRow = examples.getTableBody().get(i);
            final Node rowNode = createExamplesRowWrapperNode(examplesRow, i);
            final AstNode expandedScenarioNode = createAstNode(rowNode, examplesNode);
            nodeMap.put(examplesRow.getLocation().getLine(), expandedScenarioNode);
        }
    }
}
 
Example #4
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 6 votes vote down vote up
private void processScenarioOutlineExamples(
        final Map<Integer, AstNode> nodeMap, final ScenarioOutline scenarioOutline, final AstNode childNode
) {
    scenarioOutline.getExamples().forEach(examples -> {
        final AstNode examplesNode = new AstNode(examples, childNode);
        final TableRow headerRow = examples.getTableHeader();
        final AstNode headerNode = new AstNode(headerRow, examplesNode);
        nodeMap.put(headerRow.getLocation().getLine(), headerNode);
        IntStream.range(0, examples.getTableBody().size()).forEach(i -> {
            final TableRow examplesRow = examples.getTableBody().get(i);
            final Node rowNode = new CucumberSourceUtils.ExamplesRowWrapperNode(examplesRow, i);
            final AstNode expandedScenarioNode = new AstNode(rowNode, examplesNode);
            nodeMap.put(examplesRow.getLocation().getLine(), expandedScenarioNode);
        });
    });
}
 
Example #5
Source File: TestSourcesModel.java    From extentreports-cucumber4-adapter with Apache License 2.0 5 votes vote down vote up
private void processScenarioOutlineExamples(Map<Integer, AstNode> nodeMap, ScenarioOutline scenarioOutline, AstNode childNode) {
    for (Examples examples : scenarioOutline.getExamples()) {
        AstNode examplesNode = new AstNode(examples, childNode);
        TableRow headerRow = examples.getTableHeader();
        AstNode headerNode = new AstNode(headerRow, examplesNode);
        nodeMap.put(headerRow.getLocation().getLine(), headerNode);
        for (int i = 0; i < examples.getTableBody().size(); ++i) {
            TableRow examplesRow = examples.getTableBody().get(i);
            Node rowNode = new ExamplesRowWrapperNode(examplesRow, i);
            AstNode expandedScenarioNode = new AstNode(rowNode, examplesNode);
            nodeMap.put(examplesRow.getLocation().getLine(), expandedScenarioNode);
        }
    }
}
 
Example #6
Source File: ExtentCucumberAdapter.java    From extentreports-cucumber4-adapter with Apache License 2.0 5 votes vote down vote up
private synchronized void addOutlineStepsToReport(ScenarioOutline scenarioOutline) {
    for (Step step : scenarioOutline.getSteps()) {
        if (step.getArgument() != null) {
            Node argument = step.getArgument();
            if (argument instanceof DocString) {
                createDocStringMap((DocString)argument);
            } else if (argument instanceof DataTable) {
                
            }
        }
    }
}
 
Example #7
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 4 votes vote down vote up
ExamplesRowWrapperNode(final Node examplesRow, final int bodyRowIndex) {
    super(examplesRow.getLocation());
    this.bodyRowIndex = bodyRowIndex;
}
 
Example #8
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 4 votes vote down vote up
AstNode(final Node node, final AstNode parent) {
    this.node = node;
    this.parent = parent;
}
 
Example #9
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 4 votes vote down vote up
public Node getNode() {
    return node;
}
 
Example #10
Source File: TestSourcesModel.java    From extentreports-cucumber4-adapter with Apache License 2.0 4 votes vote down vote up
AstNode(Node node, AstNode parent) {
    this.node = node;
    this.parent = parent;
}
 
Example #11
Source File: TestSourcesModel.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private static ExamplesRowWrapperNode createExamplesRowWrapperNode(final Node examplesRow, final int bodyRowIndex) {
    return new ExamplesRowWrapperNode(examplesRow, bodyRowIndex);
}
 
Example #12
Source File: TestSourcesModel.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private static AstNode createAstNode(final Node node, final AstNode astNode) {
    return new AstNode(node, astNode);
}
 
Example #13
Source File: TestSourcesModel.java    From allure-java with Apache License 2.0 4 votes vote down vote up
ExamplesRowWrapperNode(final Node examplesRow, final int bodyRowIndex) {
    super(examplesRow.getLocation());
    this.bodyRowIndex = bodyRowIndex;
}
 
Example #14
Source File: TestSourcesModel.java    From allure-java with Apache License 2.0 4 votes vote down vote up
public Node getNode() {
    return node;
}
 
Example #15
Source File: TestSourcesModel.java    From allure-java with Apache License 2.0 4 votes vote down vote up
AstNode(final Node node, final AstNode parent) {
    this.node = node;
    this.parent = parent;
}
 
Example #16
Source File: TestSourcesModel.java    From extentreports-cucumber4-adapter with Apache License 2.0 4 votes vote down vote up
ExamplesRowWrapperNode(Node examplesRow, int bodyRowIndex) {
    super(examplesRow.getLocation());
    this.bodyRowIndex = bodyRowIndex;
}
 
Example #17
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 4 votes vote down vote up
ExamplesRowWrapperNode(final Node examplesRow, final int bodyRowIndex) {
    super(examplesRow.getLocation());
    this.bodyRowIndex = bodyRowIndex;
}
 
Example #18
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 4 votes vote down vote up
AstNode(final Node node, final AstNode parent) {
    this.node = node;
    this.parent = parent;
}
 
Example #19
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 4 votes vote down vote up
public Node getNode() {
    return node;
}