From dbc3f54ec03cda03e88d0fbe58ad5f934347a1c2 Mon Sep 17 00:00:00 2001 From: Dmitry Baev Date: Mon, 29 Jan 2024 15:34:53 +0000 Subject: [PATCH] parse labels from tags using naming convention (via #2326) --- .../qameta/allure/ConfigurationBuilder.java | 2 +- .../qameta/allure/DummyReportGenerator.java | 2 +- .../io/qameta/allure/tags/TagsPlugin.java | 48 ++- .../io/qameta/allure/tags/TagsPluginTest.java | 322 ++++++++++++++++++ 4 files changed, 370 insertions(+), 4 deletions(-) create mode 100644 allure-generator/src/test/java/io/qameta/allure/tags/TagsPluginTest.java diff --git a/allure-generator/src/main/java/io/qameta/allure/ConfigurationBuilder.java b/allure-generator/src/main/java/io/qameta/allure/ConfigurationBuilder.java index ab5414f63..d9cd6d9c6 100644 --- a/allure-generator/src/main/java/io/qameta/allure/ConfigurationBuilder.java +++ b/allure-generator/src/main/java/io/qameta/allure/ConfigurationBuilder.java @@ -96,9 +96,9 @@ public ConfigurationBuilder useDefault() { new FreemarkerContext(), new RandomUidContext(), new MarkdownDescriptionsPlugin(), + new TagsPlugin(), new RetryPlugin(), new RetryTrendPlugin(), - new TagsPlugin(), new SeverityPlugin(), new OwnerPlugin(), new IdeaLinksPlugin(), diff --git a/allure-generator/src/main/java/io/qameta/allure/DummyReportGenerator.java b/allure-generator/src/main/java/io/qameta/allure/DummyReportGenerator.java index d64bf71d2..a1a1ddcdd 100644 --- a/allure-generator/src/main/java/io/qameta/allure/DummyReportGenerator.java +++ b/allure-generator/src/main/java/io/qameta/allure/DummyReportGenerator.java @@ -84,9 +84,9 @@ public final class DummyReportGenerator { new FreemarkerContext(), new RandomUidContext(), new MarkdownDescriptionsPlugin(), + new TagsPlugin(), new RetryPlugin(), new RetryTrendPlugin(), - new TagsPlugin(), new SeverityPlugin(), new OwnerPlugin(), new IdeaLinksPlugin(), diff --git a/allure-generator/src/main/java/io/qameta/allure/tags/TagsPlugin.java b/allure-generator/src/main/java/io/qameta/allure/tags/TagsPlugin.java index 54ed3df7a..50b24991c 100644 --- a/allure-generator/src/main/java/io/qameta/allure/tags/TagsPlugin.java +++ b/allure-generator/src/main/java/io/qameta/allure/tags/TagsPlugin.java @@ -19,18 +19,27 @@ import io.qameta.allure.ReportStorage; import io.qameta.allure.core.Configuration; import io.qameta.allure.core.LaunchResults; +import io.qameta.allure.entity.Label; import io.qameta.allure.entity.LabelName; +import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Objects; +import java.util.Optional; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; /** * @author charlie (Dmitry Baev). */ public class TagsPlugin implements Aggregator2 { + private static final Pattern LABEL_TAG = Pattern.compile("^@?allure\\.label\\.(?.+)[:=](?.+)$"); + public static final String TAGS_BLOCK_NAME = "tags"; @Override @@ -41,8 +50,43 @@ public void aggregate(final Configuration configuration, .map(LaunchResults::getAllResults) .flatMap(Collection::stream) .forEach(result -> { - final Set tags = new HashSet<>(result.findAllLabels(LabelName.TAG)); - result.addExtraBlock(TAGS_BLOCK_NAME, tags); + + final Set tags = result.findAllLabels(LabelName.TAG, Collectors.toSet()); + + final List