use of io.cucumber.tagexpressions.Expression in project cucable-plugin by trivago.
the class GherkinDocumentParser method scenarioShouldBeIncluded.
/**
* Checks if a scenario should be included in the runner and feature generation based on the tag settings and
* scenarioNames settings.
*
* @param singleScenario a single scenario object.
* @return true if the combined tags match the given tag expression and the scenario name (if specified) matches.
*/
private boolean scenarioShouldBeIncluded(final SingleScenario singleScenario) throws CucablePluginException {
String includeScenarioTags = propertyManager.getIncludeScenarioTags();
String language = singleScenario.getFeatureLanguage();
String scenarioName = singleScenario.getScenarioName();
boolean scenarioNameMatchExists = matchScenarioWithScenarioNames(language, scenarioName) >= 0;
List<String> combinedScenarioTags = new ArrayList<>(singleScenario.getScenarioTags());
combinedScenarioTags.addAll(singleScenario.getFeatureTags());
combinedScenarioTags.addAll(singleScenario.getExampleTags());
combinedScenarioTags = combinedScenarioTags.stream().distinct().collect(Collectors.toList());
if (includeScenarioTags == null || includeScenarioTags.isEmpty()) {
return scenarioNameMatchExists;
}
try {
Expression tagExpression = TagExpressionParser.parse(includeScenarioTags);
return tagExpression.evaluate(combinedScenarioTags) && scenarioNameMatchExists;
} catch (TagExpressionException e) {
throw new CucablePluginException("The tag expression '" + includeScenarioTags + "' is invalid: " + e.getMessage());
}
}
Aggregations