11package io .qameta .allure .aspects ;
22
33import io .qameta .allure .model .Label ;
4+ import io .qameta .allure .model .Link ;
5+ import io .qameta .allure .util .ResultsUtils ;
46import ru .yandex .qatools .allure .annotations .Features ;
57import ru .yandex .qatools .allure .annotations .Issue ;
68import ru .yandex .qatools .allure .annotations .Issues ;
@@ -32,8 +34,6 @@ final class Allure1Utils {
3234
3335 private static final String STORY_LABEL = "story" ;
3436
35- private static final String ISSUE_LABEL = "issue" ;
36-
3737 /**
3838 * Don't instance this class.
3939 */
@@ -115,6 +115,22 @@ private static <T extends Annotation> List<Label> getLabels(final AnnotatedEleme
115115 : Collections .emptyList ();
116116 }
117117
118+ public static <T extends Annotation > List <Link > getLinks (final Method method , final Class <T > annotation ,
119+ final Function <T , List <Link >> extractor ) {
120+ final List <Link > labels = new ArrayList <>();
121+ labels .addAll (getLinks ((AnnotatedElement ) method , annotation , extractor ));
122+ labels .addAll (getLinks (method .getDeclaringClass (), annotation , extractor ));
123+ return labels ;
124+ }
125+
126+ private static <T extends Annotation > List <Link > getLinks (final AnnotatedElement element ,
127+ final Class <T > annotation ,
128+ final Function <T , List <Link >> extractor ) {
129+ return element .isAnnotationPresent (annotation )
130+ ? extractor .apply (element .getAnnotation (annotation ))
131+ : Collections .emptyList ();
132+ }
133+
118134 public static List <Label > createLabels (final Stories stories ) {
119135 return Arrays .stream (stories .value ())
120136 .map (value -> new Label ().withName (STORY_LABEL ).withValue (value ))
@@ -131,22 +147,22 @@ public static List<Label> createLabels(final Severity severity) {
131147 return Collections .singletonList (new Label ().withName (SEVERITY_LABEL ).withValue (severity .value ().value ()));
132148 }
133149
134- public static List <Label > createLabels (final Issues issues ) {
150+ public static List <Link > createLinks (final Issues issues ) {
135151 return Arrays .stream (issues .value ())
136- .map (Allure1Utils ::createLabel )
152+ .map (Allure1Utils ::createLink )
137153 .collect (Collectors .toList ());
138154 }
139155
140- public static List <Label > createLabels (final Issue issue ) {
141- return Collections .singletonList (new Label (). withName ( ISSUE_LABEL ). withValue ( issue . value () ));
156+ public static List <Link > createLinks (final Issue issue ) {
157+ return Collections .singletonList (createLink ( issue ));
142158 }
143159
144- public static List <Label > createLabels (final TestCaseId issue ) {
145- return Collections .singletonList (new Label (). withName ( ISSUE_LABEL ). withValue (issue .value ()));
160+ public static List <Link > createLinks (final TestCaseId issue ) {
161+ return Collections .singletonList (ResultsUtils . createTmsLink (issue .value ()));
146162 }
147163
148- private static Label createLabel (final Issue issue ) {
149- return new Label (). withName ( ISSUE_LABEL ). withValue (issue .value ());
164+ private static Link createLink (final Issue issue ) {
165+ return ResultsUtils . createIssueLink (issue .value ());
150166 }
151167
152168 public static String getParameterName (final Field field ) {
0 commit comments