Skip to content

Commit

Permalink
fix JIRA integration (#3330)
Browse files Browse the repository at this point in the history
  • Loading branch information
cliviu authored Nov 17, 2023
1 parent 07cd518 commit 5b32966
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import net.thucydides.model.steps.StepFailure;
import net.thucydides.model.steps.StepListener;
import net.thucydides.model.util.EnvironmentVariables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.ZonedDateTime;
import java.util.List;
Expand All @@ -24,11 +26,11 @@
public class JiraStepListener implements StepListener {

private final TestResultTally<TestOutcomeSummary> resultTally = new TestResultTally<>();
private final Set<String> testSuiteIssues = new CopyOnWriteArraySet();
// private static TestResultTally<TestOutcomeSummary> resultTally = new TestResultTally<>();
// private static Set<String> testSuiteIssues = new CopyOnWriteArraySet();
private final Set<String> testSuiteIssues = new CopyOnWriteArraySet<>();
private final JiraUpdater jiraUpdater;

private static final Logger LOGGER = LoggerFactory.getLogger(JiraStepListener.class);


public JiraStepListener(IssueTracker issueTracker,
EnvironmentVariables environmentVariables,
Expand Down Expand Up @@ -63,8 +65,11 @@ public void testStarted(String description, String id, ZonedDateTime startTime)

}

@Override
public void testFinished(TestOutcome result) {
if (jiraUpdater.shouldUpdateIssues()) {
boolean shouldUpdateIssues = jiraUpdater.shouldUpdateIssues();
LOGGER.info("TestFinished updateIssues=" + shouldUpdateIssues);
if (shouldUpdateIssues) {
List<String> issues = jiraUpdater.getPrefixedIssuesWithoutHashes(new TestOutcomeSummary(result));
tallyResults(new TestOutcomeSummary(result), issues);
testSuiteIssues.addAll(issues);
Expand All @@ -73,7 +78,12 @@ public void testFinished(TestOutcome result) {

@Override
public void testFinished(TestOutcome result, boolean isInDataDrivenTest, ZonedDateTime finishTime) {
testFinished(result);
}

@Override
public void testFinished(TestOutcome result, boolean isInDataDrivenTest) {
testFinished(result);
}

private void tallyResults(TestOutcomeSummary result, List<String> issues) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ private SortedMap<String, NamedTestResult> findTestResults(List<String> commentL
}

private SortedMap<String, NamedTestResult> indexByTestName(List<NamedTestResult> namedTestResults) {
Map<String, NamedTestResult> indexedTestResults = namedTestResults.stream().collect(Collectors.toMap(NamedTestResult::getTestName, Function.identity()));
Map<String, NamedTestResult> indexedTestResults = namedTestResults.stream().collect(Collectors.toMap(NamedTestResult::getTestName, Function.identity(),(result1, result2) -> {
return result1;
}));
SortedMap<String, NamedTestResult> sortedTestResults = Maps.newTreeMap();
sortedTestResults.putAll(indexedTestResults);
return sortedTestResults;
Expand Down

0 comments on commit 5b32966

Please sign in to comment.