> entry : featureAndFailedLinesMapping.entrySet()) {
+ String key = entry.getKey();
+ // TODO: Should these be relative?
+ FeatureWithLines featureWithLines = create(relativize(URI.create(key)), entry.getValue());
+ writer.println(featureWithLines);
+ }
+
+ writer.close();
+ }
+
+ /**
+ * Miniaturized version of Cucumber Query.
+ *
+ * The rerun plugin only needs a few things.
+ */
+ private static class Query {
+
+ private final Map testCaseById = new HashMap<>();
+ private final Map> testStepsResultStatusByTestCaseStartedId = new HashMap<>();
+ private final Map testCaseStartedById = new HashMap<>();
+ private final Map pickleById = new HashMap<>();
+
+ void update(Envelope envelope) {
+ envelope.getPickle().ifPresent(this::updatePickle);
+ envelope.getTestCase().ifPresent(this::updateTestCase);
+ envelope.getTestCaseStarted().ifPresent(this::updateTestCaseStarted);
+ envelope.getTestStepFinished().ifPresent(this::updateTestStepFinished);
+ }
+
+ private void updatePickle(Pickle event) {
+ pickleById.put(event.getId(), event);
+ }
+
+ private void updateTestCase(TestCase event) {
+ testCaseById.put(event.getId(), event);
+ }
+
+ private void updateTestCaseStarted(TestCaseStarted testCaseStarted) {
+ testCaseStartedById.put(testCaseStarted.getId(), testCaseStarted);
+ }
+
+ private void updateTestStepFinished(TestStepFinished event) {
+ String testCaseStartedId = event.getTestCaseStartedId();
+ testStepsResultStatusByTestCaseStartedId.computeIfAbsent(testCaseStartedId, s -> new ArrayList<>())
+ .add(event.getTestStepResult().getStatus());
+ }
+
+ public Optional findMostSevereTestStepResultBy(TestCaseFinished testCaseFinished) {
+ List statuses = testStepsResultStatusByTestCaseStartedId
+ .getOrDefault(testCaseFinished.getTestCaseStartedId(), emptyList());
+ if (statuses.isEmpty()) {
+ return Optional.empty();
+ }
+ return Optional.of(Collections.max(statuses, comparing(Enum::ordinal)));
+ }
+
+ public Optional findPickleBy(TestCaseFinished testCaseFinished) {
+ String testCaseStartedId = testCaseFinished.getTestCaseStartedId();
+ TestCaseStarted testCaseStarted = testCaseStartedById.get(testCaseStartedId);
+ if (testCaseStarted == null) {
+ return Optional.empty();
+ }
+ TestCase testCase = testCaseById.get(testCaseStarted.getTestCaseId());
+ if (testCase == null) {
+ return Optional.empty();
+ }
+ return Optional.ofNullable(pickleById.get(testCase.getPickleId()));
+ }
+
+ }
+
}
diff --git a/cucumber-core/src/main/java/io/cucumber/core/plugin/TeamCityPlugin.java b/cucumber-core/src/main/java/io/cucumber/core/plugin/TeamCityPlugin.java
index 24d32eb422..85ac95c626 100644
--- a/cucumber-core/src/main/java/io/cucumber/core/plugin/TeamCityPlugin.java
+++ b/cucumber-core/src/main/java/io/cucumber/core/plugin/TeamCityPlugin.java
@@ -379,7 +379,7 @@ private static String getHookName(Hook hook) {
}
private Optional findSnippets(Pickle pickle) {
- return query.findLocationOf(pickle)
+ return pickle.getLocation()
.map(location -> {
URI uri = URI.create(pickle.getUri());
List suggestionForTestCase = suggestions.stream()