cucumber.api.event.TestSourceRead Java Examples

The following examples show how to use cucumber.api.event.TestSourceRead. 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 bdt with Apache License 2.0 6 votes vote down vote up
private void parseGherkinSource(String path) {
    if (this.pathToReadEventMap.containsKey(path)) {
        Parser<GherkinDocument> parser = new Parser(new AstBuilder());
        TokenMatcher matcher = new TokenMatcher();

        try {
            GherkinDocument gherkinDocument = (GherkinDocument) parser.parse(((TestSourceRead) this.pathToReadEventMap.get(path)).source, matcher);
            this.pathToAstMap.put(path, gherkinDocument);
            Map<Integer, TestSourcesModel.AstNode> nodeMap = new HashMap();
            TestSourcesModel.AstNode currentParent = new TestSourcesModel.AstNode(gherkinDocument.getFeature(), (TestSourcesModel.AstNode) null);
            Iterator var7 = gherkinDocument.getFeature().getChildren().iterator();

            while (var7.hasNext()) {
                ScenarioDefinition child = (ScenarioDefinition) var7.next();
                this.processScenarioDefinition(nodeMap, child, currentParent);
            }

            this.pathToNodeMap.put(path, nodeMap);
        } catch (ParserException var9) {
            ;
        }

    }
}
 
Example #2
Source File: TestSourcesModel.java    From bdt with Apache License 2.0 6 votes vote down vote up
public String getKeywordFromSource(String uri, int stepLine) {
    Feature feature = this.getFeature(uri);
    if (feature != null) {
        TestSourceRead event = this.getTestSourceReadEvent(uri);
        String trimmedSourceLine = event.source.split("\n")[stepLine - 1].trim();
        GherkinDialect dialect = (new GherkinDialectProvider(feature.getLanguage())).getDefaultDialect();
        Iterator var7 = dialect.getStepKeywords().iterator();

        while (var7.hasNext()) {
            String keyword = (String) var7.next();
            if (trimmedSourceLine.startsWith(keyword)) {
                return keyword;
            }
        }
    }

    return "";
}
 
Example #3
Source File: AllureCucumber4Jvm.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Override
public void setEventPublisher(final EventPublisher publisher) {
    publisher.registerHandlerFor(TestSourceRead.class, featureStartedHandler);

    publisher.registerHandlerFor(TestCaseStarted.class, caseStartedHandler);
    publisher.registerHandlerFor(TestCaseFinished.class, caseFinishedHandler);

    publisher.registerHandlerFor(TestStepStarted.class, stepStartedHandler);
    publisher.registerHandlerFor(TestStepFinished.class, stepFinishedHandler);

    publisher.registerHandlerFor(WriteEvent.class, writeEventHandler);
    publisher.registerHandlerFor(EmbedEvent.class, embedEventHandler);
}
 
Example #4
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 5 votes vote down vote up
public String getKeywordFromSource(final String uri, final int stepLine) {
    final Feature feature = getFeature(uri);
    if (feature != null) {
        final TestSourceRead event = getTestSourceReadEvent(uri);
        final String trimmedSourceLine = event.source.split("\n")[stepLine - 1].trim();
        final GherkinDialect dialect = new GherkinDialectProvider(feature.getLanguage()).getDefaultDialect();
        for (String keyword : dialect.getStepKeywords()) {
            if (trimmedSourceLine.startsWith(keyword)) {
                return keyword;
            }
        }
    }
    return "";
}
 
Example #5
Source File: AllureCucumber3Jvm.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Override
public void setEventPublisher(final EventPublisher publisher) {
    publisher.registerHandlerFor(TestSourceRead.class, featureStartedHandler);

    publisher.registerHandlerFor(TestCaseStarted.class, caseStartedHandler);
    publisher.registerHandlerFor(TestCaseFinished.class, caseFinishedHandler);

    publisher.registerHandlerFor(TestStepStarted.class, stepStartedHandler);
    publisher.registerHandlerFor(TestStepFinished.class, stepFinishedHandler);

    publisher.registerHandlerFor(WriteEvent.class, writeEventHandler);
    publisher.registerHandlerFor(EmbedEvent.class, embedEventHandler);
}
 
Example #6
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 5 votes vote down vote up
public String getKeywordFromSource(final String uri, final int stepLine) {
    final Feature feature = getFeature(uri);
    if (feature != null) {
        final TestSourceRead event = getTestSourceReadEvent(uri);
        final String trimmedSourceLine = event.source.split("\n")[stepLine - 1].trim();
        final GherkinDialect dialect = new GherkinDialectProvider(feature.getLanguage()).getDefaultDialect();
        for (String keyword : dialect.getStepKeywords()) {
            if (trimmedSourceLine.startsWith(keyword)) {
                return keyword;
            }
        }
    }
    return "";
}
 
Example #7
Source File: TestSourcesModel.java    From extentreports-cucumber4-adapter with Apache License 2.0 5 votes vote down vote up
String getKeywordFromSource(String uri, int stepLine) {
    Feature feature = getFeature(uri);
    if (feature != null) {
        TestSourceRead event = getTestSourceReadEvent(uri);
        String trimmedSourceLine = event.source.split("\n")[stepLine - 1].trim();
        GherkinDialect dialect = new GherkinDialectProvider(feature.getLanguage()).getDefaultDialect();
        for (String keyword : dialect.getStepKeywords()) {
            if (trimmedSourceLine.startsWith(keyword)) {
                return keyword;
            }
        }
    }
    return "";
}
 
Example #8
Source File: ExtentCucumberAdapter.java    From extentreports-cucumber4-adapter with Apache License 2.0 5 votes vote down vote up
@Override
public void setEventPublisher(EventPublisher publisher) {
    publisher.registerHandlerFor(TestSourceRead.class, testSourceReadHandler);
    publisher.registerHandlerFor(TestCaseStarted.class, caseStartedHandler);
    publisher.registerHandlerFor(TestStepStarted.class, stepStartedHandler);
    publisher.registerHandlerFor(TestStepFinished.class, stepFinishedHandler);
    publisher.registerHandlerFor(EmbedEvent.class, embedEventhandler);
    publisher.registerHandlerFor(WriteEvent.class, writeEventhandler);
    publisher.registerHandlerFor(TestRunFinished.class, runFinishedHandler);
}
 
Example #9
Source File: AllureCucumber2Jvm.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Override
public void setEventPublisher(final EventPublisher publisher) {
    publisher.registerHandlerFor(TestSourceRead.class, featureStartedHandler);

    publisher.registerHandlerFor(TestCaseStarted.class, caseStartedHandler);
    publisher.registerHandlerFor(TestCaseFinished.class, caseFinishedHandler);

    publisher.registerHandlerFor(TestStepStarted.class, stepStartedHandler);
    publisher.registerHandlerFor(TestStepFinished.class, stepFinishedHandler);

    publisher.registerHandlerFor(WriteEvent.class, writeEventHandler);
    publisher.registerHandlerFor(EmbedEvent.class, embedEventHandler);
}
 
Example #10
Source File: AllureCucumber3Jvm.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private void handleFeatureStartedHandler(final TestSourceRead event) {
    cucumberSourceUtils.addTestSourceReadEvent(event.uri, event);
}
 
Example #11
Source File: TestSourcesModel.java    From bdt with Apache License 2.0 4 votes vote down vote up
private TestSourceRead getTestSourceReadEvent(String uri) {
    return this.pathToReadEventMap.containsKey(uri) ? (TestSourceRead) this.pathToReadEventMap.get(uri) : null;
}
 
Example #12
Source File: TestSourcesModel.java    From extentreports-cucumber4-adapter with Apache License 2.0 4 votes vote down vote up
private TestSourceRead getTestSourceReadEvent(String uri) {
    if (pathToReadEventMap.containsKey(uri)) {
        return pathToReadEventMap.get(uri);
    }
    return null;
}
 
Example #13
Source File: TestSourcesModel.java    From bdt with Apache License 2.0 4 votes vote down vote up
public void addTestSourceReadEvent(String path, TestSourceRead event) {
    this.pathToReadEventMap.put(path, event);
}
 
Example #14
Source File: CucumberReportAdapter.java    From openCypher with Apache License 2.0 4 votes vote down vote up
private Consumer<TCKEvents.FeatureRead> featureReadEvent() {
    return feature -> {
        featureNameToUri.put(feature.name(), feature.uri());
        bus.handle(new TestSourceRead(time(), feature.uri(), feature.source()));
    };
}
 
Example #15
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private TestSourceRead getTestSourceReadEvent(final String uri) {
    if (pathToReadEventMap.containsKey(uri)) {
        return pathToReadEventMap.get(uri);
    }
    return null;
}
 
Example #16
Source File: ExtentCucumberAdapter.java    From extentreports-cucumber4-adapter with Apache License 2.0 4 votes vote down vote up
@Override
public void receive(TestSourceRead event) {
    handleTestSourceRead(event);
}
 
Example #17
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 4 votes vote down vote up
public void addTestSourceReadEvent(final String path, final TestSourceRead event) {
    pathToReadEventMap.put(path, event);
}
 
Example #18
Source File: AllureCucumber4Jvm.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private void handleFeatureStartedHandler(final TestSourceRead event) {
    testSources.addTestSourceReadEvent(event.uri, event);
}
 
Example #19
Source File: TestSourcesModel.java    From extentreports-cucumber4-adapter with Apache License 2.0 4 votes vote down vote up
void addTestSourceReadEvent(String path, TestSourceRead event) {
    pathToReadEventMap.put(path, event);
}
 
Example #20
Source File: TestSourcesModelProxy.java    From allure-java with Apache License 2.0 4 votes vote down vote up
public void addTestSourceReadEvent(final String path, final TestSourceRead event) {
    testSources.addTestSourceReadEvent(path, event);
}
 
Example #21
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private TestSourceRead getTestSourceReadEvent(final String uri) {
    if (pathToReadEventMap.containsKey(uri)) {
        return pathToReadEventMap.get(uri);
    }
    return null;
}
 
Example #22
Source File: ExtentCucumberAdapter.java    From extentreports-cucumber4-adapter with Apache License 2.0 4 votes vote down vote up
private void handleTestSourceRead(TestSourceRead event) {
    testSources.addTestSourceReadEvent(event.uri, event);
}
 
Example #23
Source File: CucumberSourceUtils.java    From allure-java with Apache License 2.0 4 votes vote down vote up
public void addTestSourceReadEvent(final String path, final TestSourceRead event) {
    pathToReadEventMap.put(path, event);
}
 
Example #24
Source File: AllureCucumber2Jvm.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private void handleFeatureStartedHandler(final TestSourceRead event) {
    cucumberSourceUtils.addTestSourceReadEvent(event.uri, event);
}