33import gherkin .formatter .model .Feature ;
44import gherkin .formatter .model .Scenario ;
55import gherkin .formatter .model .Tag ;
6- import io .qameta .allure .util .ResultsUtils ;
7- import io .qameta .allure .Severity ;
8- import io .qameta .allure .SeverityLevel ;
9- import io .qameta .allure .Story ;
106import io .qameta .allure .model .Label ;
117import io .qameta .allure .model .Link ;
8+ import io .qameta .allure .util .ResultsUtils ;
129import org .slf4j .Logger ;
1310import org .slf4j .LoggerFactory ;
1411
15- import java .lang .annotation .Annotation ;
1612import java .util .ArrayList ;
1713import java .util .Deque ;
1814import java .util .List ;
1915
16+ import static io .qameta .allure .util .ResultsUtils .createFeatureLabel ;
17+ import static io .qameta .allure .util .ResultsUtils .createSeverityLabel ;
18+ import static io .qameta .allure .util .ResultsUtils .createStoryLabel ;
19+ import static io .qameta .allure .util .ResultsUtils .createTagLabel ;
2020import static io .qameta .allure .util .ResultsUtils .getHostName ;
2121import static io .qameta .allure .util .ResultsUtils .getThreadName ;
2222
2323/**
2424 * Scenario labels and links builder.
2525 */
2626class LabelBuilder {
27- private static final Logger LOG = LoggerFactory .getLogger (LabelBuilder .class );
27+ private static final Logger LOGGER = LoggerFactory .getLogger (LabelBuilder .class );
2828 private static final String COMPOSITE_TAG_DELIMITER = "=" ;
2929
3030 private static final String SEVERITY = "@SEVERITY" ;
@@ -37,8 +37,8 @@ class LabelBuilder {
3737 LabelBuilder (final Feature feature , final Scenario scenario , final Deque <Tag > tags ) {
3838 final TagParser tagParser = new TagParser (feature , scenario );
3939
40- getScenarioLabels ().add (getFeatureLabel (feature .getName ()));
41- getScenarioLabels ().add (getStoryLabel (scenario .getName ()));
40+ getScenarioLabels ().add (createFeatureLabel (feature .getName ()));
41+ getScenarioLabels ().add (createStoryLabel (scenario .getName ()));
4242
4343 while (tags .peek () != null ) {
4444 final Tag tag = tags .remove ();
@@ -52,7 +52,7 @@ class LabelBuilder {
5252
5353 switch (tagKey ) {
5454 case SEVERITY :
55- getScenarioLabels ().add (getSeverityLabel (tagValue ));
55+ getScenarioLabels ().add (createSeverityLabel (tagValue . toLowerCase () ));
5656 break ;
5757 case TMS_LINK :
5858 getScenarioLinks ().add (ResultsUtils .createTmsLink (tagValue ));
@@ -61,12 +61,12 @@ class LabelBuilder {
6161 getScenarioLinks ().add (ResultsUtils .createIssueLink (tagValue ));
6262 break ;
6363 default :
64- LOG .warn ("Composite tag {} is not supported. adding it as RAW" , tagKey );
64+ LOGGER .warn ("Composite tag {} is not supported. adding it as RAW" , tagKey );
6565 getScenarioLabels ().add (getTagLabel (tag ));
6666 break ;
6767 }
6868 } else if (tagParser .isPureSeverityTag (tag )) {
69- getScenarioLabels ().add (getSeverityLabel (tagString .substring (1 )));
69+ getScenarioLabels ().add (createSeverityLabel (tagString .substring (1 )));
7070 } else if (!tagParser .isResultTag (tag )) {
7171 getScenarioLabels ().add (getTagLabel (tag ));
7272 }
@@ -80,57 +80,8 @@ class LabelBuilder {
8080
8181 }
8282
83- private Label getFeatureLabel (final String featureName ) {
84-
85- return ResultsUtils .createLabel (new io .qameta .allure .Feature () {
86- @ Override
87- public String value () {
88- return featureName ;
89- }
90-
91- @ Override
92- public Class <? extends Annotation > annotationType () {
93- return io .qameta .allure .Feature .class ;
94- }
95- });
96- }
97-
98- private Label getSeverityLabel (final String severity ) {
99- return ResultsUtils .createLabel (new Severity () {
100- @ Override
101- public SeverityLevel value () {
102- try {
103- return SeverityLevel .valueOf (severity .toUpperCase ());
104- } catch (IllegalArgumentException e ) {
105- LOG .warn ("There is no severity level {} failing back to 'normal'" , e );
106- return SeverityLevel .NORMAL ;
107-
108- }
109- }
110-
111- @ Override
112- public Class <? extends Annotation > annotationType () {
113- return Severity .class ;
114- }
115- });
116- }
117-
118- private Label getStoryLabel (final String storyName ) {
119- return ResultsUtils .createLabel (new Story () {
120- @ Override
121- public String value () {
122- return storyName ;
123- }
124-
125- @ Override
126- public Class <? extends Annotation > annotationType () {
127- return Story .class ;
128- }
129- });
130- }
131-
13283 private Label getTagLabel (final Tag tag ) {
133- return new Label (). withName ( "tag" ). withValue (tag .getName ().substring (1 ));
84+ return createTagLabel (tag .getName ().substring (1 ));
13485 }
13586
13687 public List <Label > getScenarioLabels () {
0 commit comments