Skip to content
Merged
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
14 changes: 6 additions & 8 deletions java/src/main/java/io/cucumber/query/Query.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.cucumber.query;

import io.cucumber.messages.Convertor;
import io.cucumber.messages.TestStepResultStatusComparator;
import io.cucumber.messages.types.Attachment;
import io.cucumber.messages.types.Envelope;
import io.cucumber.messages.types.Examples;
Expand Down Expand Up @@ -35,7 +36,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.LinkedHashMap;
Expand All @@ -46,11 +46,9 @@
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import static java.util.Collections.emptyList;
import static java.util.Comparator.comparing;
import static java.util.Comparator.nullsFirst;
import static java.util.Objects.requireNonNull;
import static java.util.Optional.ofNullable;
import static java.util.function.Function.identity;
Expand All @@ -72,9 +70,6 @@
* @see <a href="https://github.com/cucumber/messages?tab=readme-ov-file#message-overview">Cucumber Messages - Message Overview</a>
*/
public final class Query {
private static final Map<TestStepResultStatus, Long> ZEROES_BY_TEST_STEP_RESULT_STATUSES = Arrays.stream(TestStepResultStatus.values())
.collect(Collectors.toMap(identity(), (s) -> 0L));
private final Comparator<TestStepResult> testStepResultComparator = nullsFirst(comparing(o -> o.getStatus().ordinal()));
private final Map<String, TestCaseStarted> testCaseStartedById = new LinkedHashMap<>();
private final Map<String, TestCaseFinished> testCaseFinishedByTestCaseStartedId = new LinkedHashMap<>();
private final Map<String, List<TestStepFinished>> testStepsFinishedByTestCaseStartedId = new LinkedHashMap<>();
Expand All @@ -94,7 +89,10 @@ public final class Query {
private TestRunFinished testRunFinished;

public Map<TestStepResultStatus, Long> countMostSevereTestStepResultStatus() {
EnumMap<TestStepResultStatus, Long> results = new EnumMap<>(ZEROES_BY_TEST_STEP_RESULT_STATUSES);
EnumMap<TestStepResultStatus, Long> results = new EnumMap<>(TestStepResultStatus.class);
for (TestStepResultStatus value : TestStepResultStatus.values()) {
results.put(value, 0L);
}
results.putAll(findAllTestCaseStarted().stream()
.map(this::findMostSevereTestStepResultBy)
.filter(Optional::isPresent)
Expand Down Expand Up @@ -205,7 +203,7 @@ public Optional<TestStepResult> findMostSevereTestStepResultBy(TestCaseStarted t
return findTestStepsFinishedBy(testCaseStarted)
.stream()
.map(TestStepFinished::getTestStepResult)
.max(testStepResultComparator);
.max(comparing(TestStepResult::getStatus, new TestStepResultStatusComparator()));
}

public Optional<TestStepResult> findMostSevereTestStepResultBy(TestCaseFinished testCaseFinished) {
Expand Down
30 changes: 0 additions & 30 deletions java/src/main/java/io/cucumber/query/TimestampComparator.java

This file was deleted.

42 changes: 0 additions & 42 deletions java/src/test/java/io/cucumber/query/TimestampComparatorTest.java

This file was deleted.