11package net .thucydides .core .reports .html ;
22
33import io .cucumber .tagexpressions .Expression ;
4- import io .cucumber .tagexpressions .TagExpressionParser ;
5- import net .thucydides .core .ThucydidesSystemProperty ;
6- import net .thucydides .core .model .TestTag ;
74import net .thucydides .core .requirements .model .Requirement ;
85import net .thucydides .core .util .EnvironmentVariables ;
96
107import java .util .List ;
8+ import java .util .function .Predicate ;
119import java .util .stream .Collectors ;
1210
1311import static net .thucydides .core .ThucydidesSystemProperty .TAGS ;
@@ -25,12 +23,9 @@ public boolean inDisplayOnlyTags(Requirement requirement) {
2523
2624
2725 private boolean requirementMatchesAnyTagIn (Requirement requirement , Expression expectedTags ) {
28- List <String > requirementTags = CucumberTagConverter .toStrings (requirement .getTags ());
29-
30- if (expectedTags .evaluate (requirementTags ) || (matchExistsInScenarios (expectedTags , requirement ))) {
26+ if (new RequirementTagMatcher (expectedTags ).test (requirement )) {
3127 return true ;
3228 }
33-
3429 return hasChildWithMatchingTag (requirement , expectedTags );
3530 }
3631
@@ -44,12 +39,25 @@ private boolean hasChildWithMatchingTag(Requirement requirement, Expression expe
4439 if (!requirement .hasChildren ()) {
4540 return false ;
4641 }
47- return requirement .getNestedChildren ().stream ().anyMatch (
48- child -> expectedTags .evaluate (CucumberTagConverter .toStrings (child .getTags ()))
49- );
42+ return requirement .getNestedChildren ().stream ().anyMatch (new RequirementTagMatcher (expectedTags ));
43+ }
44+
45+ private class RequirementTagMatcher implements Predicate <Requirement > {
46+
47+ private Expression expectedTags ;
48+
49+ public RequirementTagMatcher (Expression expectedTags ) {
50+ this .expectedTags = expectedTags ;
51+ }
52+
53+ @ Override
54+ public boolean test (Requirement requirement ) {
55+ return expectedTags .evaluate (CucumberTagConverter .toStrings (requirement .getTags ())) || matchExistsInScenarios (expectedTags , requirement );
56+ }
5057 }
5158
5259
60+
5361 public List <Requirement > filteredByDisplayTag (List <Requirement > requirements ) {
5462 return requirements .stream ()
5563 .filter (this ::inDisplayOnlyTags )
0 commit comments