Java Code Examples for gherkin.ast.GherkinDocument#getFeature()

The following examples show how to use gherkin.ast.GherkinDocument#getFeature() . 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
private void parseGherkinSource(String path) {
    if (!pathToReadEventMap.containsKey(path)) {
        return;
    }
    Parser<GherkinDocument> parser = new Parser<GherkinDocument>(new AstBuilder());
    TokenMatcher matcher = new TokenMatcher();
    try {
        GherkinDocument gherkinDocument = parser.parse(pathToReadEventMap.get(path).source, matcher);
        pathToAstMap.put(path, gherkinDocument);
        Map<Integer, AstNode> nodeMap = new HashMap<Integer, AstNode>();
        AstNode currentParent = new AstNode(gherkinDocument.getFeature(), null);
        for (ScenarioDefinition child : gherkinDocument.getFeature().getChildren()) {
            processScenarioDefinition(nodeMap, child, currentParent);
        }
        pathToNodeMap.put(path, nodeMap);
    } catch (ParserException e) {
        // Ignore exceptions
    }
}
 
Example 2
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 6 votes vote down vote up
private void parseGherkinSource(final String path) {
    if (!pathToReadEventMap.containsKey(path)) {
        return;
    }
    final Parser<GherkinDocument> parser = new Parser<>(new AstBuilder());
    final TokenMatcher matcher = new TokenMatcher();
    try {
        final GherkinDocument gherkinDocument = parser.parse(pathToReadEventMap.get(path).source, matcher);
        pathToAstMap.put(path, gherkinDocument);
        final Map<Integer, AstNode> nodeMap = new HashMap<>();
        final AstNode currentParent = new AstNode(gherkinDocument.getFeature(), null);
        for (ScenarioDefinition child : gherkinDocument.getFeature().getChildren()) {
            processScenarioDefinition(nodeMap, child, currentParent);
        }
        pathToNodeMap.put(path, nodeMap);
    } catch (ParserException e) {
        LOGGER.trace(e.getMessage(), e);
    }
}
 
Example 3
Source File: TestSourcesModel.java    From allure-java with Apache License 2.0 6 votes vote down vote up
private void parseGherkinSource(final URI path) {
    if (!pathToReadEventMap.containsKey(path)) {
        return;
    }
    final Parser<GherkinDocument> parser = new Parser<>(new AstBuilder());
    final TokenMatcher matcher = new TokenMatcher();
    try {
        final GherkinDocument gherkinDocument = parser.parse(pathToReadEventMap.get(path).getSource(),
                matcher);
        pathToAstMap.put(path, gherkinDocument);
        final Map<Integer, AstNode> nodeMap = new HashMap<>();
        final AstNode currentParent = new AstNode(gherkinDocument.getFeature(), null);
        for (ScenarioDefinition child : gherkinDocument.getFeature().getChildren()) {
            processScenarioDefinition(nodeMap, child, currentParent);
        }
        pathToNodeMap.put(path, nodeMap);
    } catch (ParserException e) {
        throw new IllegalStateException("You are using a plugin that only supports till Gherkin 5.\n"
                + "Please check if the Gherkin provided follows the standard of Gherkin 5\n", e
        );
    }
}
 
Example 4
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 6 votes vote down vote up
private void parseGherkinSource(final String path) {
    if (!pathToReadEventMap.containsKey(path)) {
        return;
    }
    final Parser<GherkinDocument> parser = new Parser<>(new AstBuilder());
    final TokenMatcher matcher = new TokenMatcher();
    try {
        final GherkinDocument gherkinDocument = parser.parse(pathToReadEventMap.get(path).source, matcher);
        pathToAstMap.put(path, gherkinDocument);
        final Map<Integer, AstNode> nodeMap = new HashMap<>();
        final AstNode currentParent = new AstNode(gherkinDocument.getFeature(), null);
        for (ScenarioDefinition child : gherkinDocument.getFeature().getChildren()) {
            processScenarioDefinition(nodeMap, child, currentParent);
        }
        pathToNodeMap.put(path, nodeMap);
    } catch (ParserException e) {
        LOGGER.trace(e.getMessage(), e);
    }
}
 
Example 5
Source File: AllureCucumber4JvmTest.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private static List<PickleEvent> compilePickles(GherkinDocument gherkinDocument, String resource) {
    if (gherkinDocument.getFeature() == null) {
        return Collections.emptyList();
    }
    List<PickleEvent> pickleEvents = new ArrayList<>();
    for (Pickle pickle : new Compiler().compile(gherkinDocument)) {
        pickleEvents.add(new PickleEvent(resource, pickle));
    }
    return pickleEvents;
}