Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -269,5 +270,9 @@ private void addLinks(Map<String, Object> body, String rid) {
if (labels != null && !labels.isEmpty()) {
links.addAll(labels);
}
List<String> jiraLinks = JiraLinkStorage.LINKED_JIRA_LINK_STORAGE.get(rid);
if (jiraLinks != null && !jiraLinks.isEmpty()) {
links.addAll(jiraLinks);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,4 +52,12 @@ public static void label(String labelName, List<String> 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);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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<List<String>> TEMP_JIRA_LINK_STORAGE =
ThreadLocal.withInitial(ArrayList::new);

public static volatile Map<String, List<String>> LINKED_JIRA_LINK_STORAGE =
new ConcurrentHashMap<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,6 +29,7 @@ public void handleFacadeFunctions(TestCaseFinished testCaseFinished) {
handleMetaAfterEach(rid);
handleLogFunction(rid);
handleLabels(rid);
handleLinkJira(rid);
handleArtifactsAfterEach(testCaseFinished);
}

Expand All @@ -53,6 +55,13 @@ private void handleLabels(String rid) {
}
}

private void handleLinkJira(String rid) {
List<String> storedLinks = JiraLinkStorage.TEMP_JIRA_LINK_STORAGE.get();
if (!storedLinks.isEmpty()) {
JiraLinkStorage.LINKED_JIRA_LINK_STORAGE.put(rid, storedLinks);
}
}

private void handleLogFunction(String rid) {
List<String> storedLogs = LogStorage.TEMP_LOG_STORAGE.get();
if (!storedLogs.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, String> metaData = MetaStorage.TEMP_META_STORAGE.get();

if (!metaData.isEmpty()) {
Expand All @@ -50,8 +52,7 @@ private void handleMetaAfterEach(ExtensionContext context) {
}
}

private void handleLogsAfterEach(ExtensionContext context) {
String rid = context.getUniqueId();
private void handleLogsAfterEach(String rid) {
List<String> storedLogs = LogStorage.TEMP_LOG_STORAGE.get();
if (!storedLogs.isEmpty()) {
String[] logs = new String[storedLogs.size()];
Expand All @@ -67,14 +68,20 @@ private void handleArtifactsAfterEach(ExtensionContext context) {
}
}

private void handleLabels(ExtensionContext context) {
String rid = context.getUniqueId();
private void handleLabels(String rid) {
List<Map<String, String>> storedLabels = LabelStorage.TEMP_LABEL_STORAGE.get();
if (!storedLabels.isEmpty()) {
LabelStorage.LINKED_LABEL_STORAGE.put(rid, storedLabels);
}
}

private void handleLinkJira(String rid) {
List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, String> metaData = MetaStorage.TEMP_META_STORAGE.get();

if (!metaData.isEmpty()) {
Expand All @@ -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<String> storedLogs = LogStorage.TEMP_LOG_STORAGE.get();
if (!storedLogs.isEmpty()) {
String[] logs = new String[storedLogs.size()];
Expand All @@ -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<Map<String, String>> storedLabels = LabelStorage.TEMP_LABEL_STORAGE.get();
if (!storedLabels.isEmpty()) {
LabelStorage.LINKED_LABEL_STORAGE.put(rid, storedLabels);
}
}

private void handleLinkJira(String rid) {
List<String> 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;
Expand Down