From c953526c1ac1789f11adb74eb9ac5e8de3b3064b Mon Sep 17 00:00:00 2001 From: yevhenii Date: Sun, 26 Oct 2025 22:06:46 +0000 Subject: [PATCH] linkJira logic in framework modules --- .../request/NativeRequestBodyBuilder.java | 5 ++++ .../io/testomat/core/facade/Testomatio.java | 9 +++++++ .../methods/linkjira/JiraLinkStorage.java | 14 +++++++++++ .../listener/FacadeFunctionsHandler.java | 9 +++++++ .../listener/FacadeFunctionsHandler.java | 25 ++++++++++++------- .../listener/FacadeFunctionsHandler.java | 25 ++++++++++++------- 6 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 java-reporter-core/src/main/java/io/testomat/core/facade/methods/linkjira/JiraLinkStorage.java diff --git a/java-reporter-core/src/main/java/io/testomat/core/client/request/NativeRequestBodyBuilder.java b/java-reporter-core/src/main/java/io/testomat/core/client/request/NativeRequestBodyBuilder.java index 8e1233b..90a7666 100644 --- a/java-reporter-core/src/main/java/io/testomat/core/client/request/NativeRequestBodyBuilder.java +++ b/java-reporter-core/src/main/java/io/testomat/core/client/request/NativeRequestBodyBuilder.java @@ -15,6 +15,7 @@ import io.testomat.core.exception.FailedToCreateRunBodyException; import io.testomat.core.facade.methods.artifact.ReportedTestStorage; import io.testomat.core.facade.methods.label.LabelStorage; +import io.testomat.core.facade.methods.linkjira.JiraLinkStorage; import io.testomat.core.facade.methods.logmethod.LogStorage; import io.testomat.core.facade.methods.meta.MetaStorage; import io.testomat.core.model.TestResult; @@ -269,5 +270,9 @@ private void addLinks(Map body, String rid) { if (labels != null && !labels.isEmpty()) { links.addAll(labels); } + List jiraLinks = JiraLinkStorage.LINKED_JIRA_LINK_STORAGE.get(rid); + if (jiraLinks != null && !jiraLinks.isEmpty()) { + links.addAll(jiraLinks); + } } } \ No newline at end of file diff --git a/java-reporter-core/src/main/java/io/testomat/core/facade/Testomatio.java b/java-reporter-core/src/main/java/io/testomat/core/facade/Testomatio.java index aac70ab..f284459 100644 --- a/java-reporter-core/src/main/java/io/testomat/core/facade/Testomatio.java +++ b/java-reporter-core/src/main/java/io/testomat/core/facade/Testomatio.java @@ -2,6 +2,7 @@ import io.testomat.core.facade.methods.artifact.manager.ArtifactManager; import io.testomat.core.facade.methods.label.LabelStorage; +import io.testomat.core.facade.methods.linkjira.JiraLinkStorage; import io.testomat.core.facade.methods.logmethod.LogStorage; import io.testomat.core.facade.methods.meta.MetaStorage; import java.util.List; @@ -51,4 +52,12 @@ public static void label(String labelName, List labelValues) { } } } + + public static void linkJira(String ... jiraLinks) { + if (jiraLinks != null && jiraLinks.length > 0) { + for (String jiraLink : jiraLinks) { + JiraLinkStorage.TEMP_JIRA_LINK_STORAGE.get().add(jiraLink); + } + } + } } diff --git a/java-reporter-core/src/main/java/io/testomat/core/facade/methods/linkjira/JiraLinkStorage.java b/java-reporter-core/src/main/java/io/testomat/core/facade/methods/linkjira/JiraLinkStorage.java new file mode 100644 index 0000000..6acff01 --- /dev/null +++ b/java-reporter-core/src/main/java/io/testomat/core/facade/methods/linkjira/JiraLinkStorage.java @@ -0,0 +1,14 @@ +package io.testomat.core.facade.methods.linkjira; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class JiraLinkStorage { + public static ThreadLocal> TEMP_JIRA_LINK_STORAGE = + ThreadLocal.withInitial(ArrayList::new); + + public static volatile Map> LINKED_JIRA_LINK_STORAGE = + new ConcurrentHashMap<>(); +} diff --git a/java-reporter-cucumber/src/main/java/io/testomat/cucumber/listener/FacadeFunctionsHandler.java b/java-reporter-cucumber/src/main/java/io/testomat/cucumber/listener/FacadeFunctionsHandler.java index fd71dd9..b4dfbf3 100644 --- a/java-reporter-cucumber/src/main/java/io/testomat/cucumber/listener/FacadeFunctionsHandler.java +++ b/java-reporter-cucumber/src/main/java/io/testomat/cucumber/listener/FacadeFunctionsHandler.java @@ -3,6 +3,7 @@ import io.cucumber.plugin.event.TestCaseFinished; import io.testomat.core.facade.methods.artifact.client.AwsService; import io.testomat.core.facade.methods.label.LabelStorage; +import io.testomat.core.facade.methods.linkjira.JiraLinkStorage; import io.testomat.core.facade.methods.logmethod.LogStorage; import io.testomat.core.facade.methods.meta.MetaStorage; import io.testomat.cucumber.extractor.TestDataExtractor; @@ -28,6 +29,7 @@ public void handleFacadeFunctions(TestCaseFinished testCaseFinished) { handleMetaAfterEach(rid); handleLogFunction(rid); handleLabels(rid); + handleLinkJira(rid); handleArtifactsAfterEach(testCaseFinished); } @@ -53,6 +55,13 @@ private void handleLabels(String rid) { } } + private void handleLinkJira(String rid) { + List storedLinks = JiraLinkStorage.TEMP_JIRA_LINK_STORAGE.get(); + if (!storedLinks.isEmpty()) { + JiraLinkStorage.LINKED_JIRA_LINK_STORAGE.put(rid, storedLinks); + } + } + private void handleLogFunction(String rid) { List storedLogs = LogStorage.TEMP_LOG_STORAGE.get(); if (!storedLogs.isEmpty()) { diff --git a/java-reporter-junit/src/main/java/io/testomat/junit/listener/FacadeFunctionsHandler.java b/java-reporter-junit/src/main/java/io/testomat/junit/listener/FacadeFunctionsHandler.java index 4832e9c..7179f64 100644 --- a/java-reporter-junit/src/main/java/io/testomat/junit/listener/FacadeFunctionsHandler.java +++ b/java-reporter-junit/src/main/java/io/testomat/junit/listener/FacadeFunctionsHandler.java @@ -4,6 +4,7 @@ import io.testomat.core.facade.methods.artifact.client.AwsService; import io.testomat.core.facade.methods.label.LabelStorage; +import io.testomat.core.facade.methods.linkjira.JiraLinkStorage; import io.testomat.core.facade.methods.logmethod.LogStorage; import io.testomat.core.facade.methods.meta.MetaStorage; import io.testomat.core.propertyconfig.impl.PropertyProviderFactoryImpl; @@ -34,14 +35,15 @@ public FacadeFunctionsHandler(boolean artifactDisabled, } public void handleFacadeFunctions(ExtensionContext context) { - handleLogsAfterEach(context); - handleMetaAfterEach(context); - handleLabels(context); + String rid = context.getUniqueId(); + handleLogsAfterEach(rid); + handleMetaAfterEach(rid); + handleLabels(rid); + handleLinkJira(rid); handleArtifactsAfterEach(context); } - private void handleMetaAfterEach(ExtensionContext context) { - String rid = context.getUniqueId(); + private void handleMetaAfterEach(String rid) { Map metaData = MetaStorage.TEMP_META_STORAGE.get(); if (!metaData.isEmpty()) { @@ -50,8 +52,7 @@ private void handleMetaAfterEach(ExtensionContext context) { } } - private void handleLogsAfterEach(ExtensionContext context) { - String rid = context.getUniqueId(); + private void handleLogsAfterEach(String rid) { List storedLogs = LogStorage.TEMP_LOG_STORAGE.get(); if (!storedLogs.isEmpty()) { String[] logs = new String[storedLogs.size()]; @@ -67,14 +68,20 @@ private void handleArtifactsAfterEach(ExtensionContext context) { } } - private void handleLabels(ExtensionContext context) { - String rid = context.getUniqueId(); + private void handleLabels(String rid) { List> storedLabels = LabelStorage.TEMP_LABEL_STORAGE.get(); if (!storedLabels.isEmpty()) { LabelStorage.LINKED_LABEL_STORAGE.put(rid, storedLabels); } } + private void handleLinkJira(String rid) { + List storedLinks = JiraLinkStorage.TEMP_JIRA_LINK_STORAGE.get(); + if (!storedLinks.isEmpty()) { + JiraLinkStorage.LINKED_JIRA_LINK_STORAGE.put(rid, storedLinks); + } + } + private boolean defineArtifactsDisabled() { boolean result; String property; diff --git a/java-reporter-testng/src/main/java/io/testomat/testng/listener/FacadeFunctionsHandler.java b/java-reporter-testng/src/main/java/io/testomat/testng/listener/FacadeFunctionsHandler.java index 347450c..a2eb0e2 100644 --- a/java-reporter-testng/src/main/java/io/testomat/testng/listener/FacadeFunctionsHandler.java +++ b/java-reporter-testng/src/main/java/io/testomat/testng/listener/FacadeFunctionsHandler.java @@ -4,6 +4,7 @@ import io.testomat.core.facade.methods.artifact.client.AwsService; import io.testomat.core.facade.methods.label.LabelStorage; +import io.testomat.core.facade.methods.linkjira.JiraLinkStorage; import io.testomat.core.facade.methods.logmethod.LogStorage; import io.testomat.core.facade.methods.meta.MetaStorage; import io.testomat.core.propertyconfig.impl.PropertyProviderFactoryImpl; @@ -40,14 +41,15 @@ public FacadeFunctionsHandler(TestNgParameterExtractor testNgParameterExtractor, } public void handleFacadeFunctions(IInvokedMethod method, ITestResult testResult) { - handleMetaAfterInvocation(testResult); - handleLogsAfterInvocation(testResult); + String rid = testNgParameterExtractor.generateRid(testResult); + handleMetaAfterInvocation(rid); + handleLogsAfterInvocation(rid); + handleLabels(rid); + handleLinkJira(rid); handleArtifactsAfterInvocation(method, testResult); - handleLabels(testResult); } - private void handleMetaAfterInvocation(ITestResult testResult) { - String rid = testNgParameterExtractor.generateRid(testResult); + private void handleMetaAfterInvocation(String rid) { Map metaData = MetaStorage.TEMP_META_STORAGE.get(); if (!metaData.isEmpty()) { @@ -66,8 +68,7 @@ private void handleArtifactsAfterInvocation(IInvokedMethod method, ITestResult t } } - private void handleLogsAfterInvocation(ITestResult testResult) { - String rid = testNgParameterExtractor.generateRid(testResult); + private void handleLogsAfterInvocation(String rid) { List storedLogs = LogStorage.TEMP_LOG_STORAGE.get(); if (!storedLogs.isEmpty()) { String[] logs = new String[storedLogs.size()]; @@ -76,14 +77,20 @@ private void handleLogsAfterInvocation(ITestResult testResult) { } } - private void handleLabels(ITestResult testResult) { - String rid = testNgParameterExtractor.generateRid(testResult); + private void handleLabels(String rid) { List> storedLabels = LabelStorage.TEMP_LABEL_STORAGE.get(); if (!storedLabels.isEmpty()) { LabelStorage.LINKED_LABEL_STORAGE.put(rid, storedLabels); } } + private void handleLinkJira(String rid) { + List storedLinks = JiraLinkStorage.TEMP_JIRA_LINK_STORAGE.get(); + if (!storedLinks.isEmpty()) { + JiraLinkStorage.LINKED_JIRA_LINK_STORAGE.put(rid, storedLinks); + } + } + private boolean defineArtifactsDisabled() { boolean result; String property;