Skip to content

Commit 8f7e554

Browse files
committed
java: Use message comparators
Reduces the custom code needed to compare messages.
1 parent 80c450d commit 8f7e554

File tree

4 files changed

+5
-74
lines changed

4 files changed

+5
-74
lines changed

java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<dependency>
5252
<groupId>io.cucumber</groupId>
5353
<artifactId>messages</artifactId>
54-
<version>[24.0.0,29.0.0)</version>
54+
<version>[28.1.0,29.0.0)</version>
5555
</dependency>
5656

5757
<dependency>

java/src/main/java/io/cucumber/query/Query.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.cucumber.query;
22

33
import io.cucumber.messages.Convertor;
4+
import io.cucumber.messages.TestStepResultStatusComparator;
5+
import io.cucumber.messages.TimestampComparator;
46
import io.cucumber.messages.types.Attachment;
57
import io.cucumber.messages.types.Envelope;
68
import io.cucumber.messages.types.Examples;
@@ -73,7 +75,7 @@
7375
public final class Query {
7476
private static final Map<TestStepResultStatus, Long> ZEROES_BY_TEST_STEP_RESULT_STATUSES = Arrays.stream(TestStepResultStatus.values())
7577
.collect(Collectors.toMap(identity(), (s) -> 0L));
76-
private final Comparator<TestStepResult> testStepResultComparator = nullsFirst(comparing(o -> o.getStatus().ordinal()));
78+
private static final Comparator<TestStepResult> testStepResultComparator = comparing(TestStepResult::getStatus, new TestStepResultStatusComparator());
7779
private final Map<String, TestCaseStarted> testCaseStartedById = new ConcurrentHashMap<>();
7880
private final Map<String, TestCaseFinished> testCaseFinishedByTestCaseStartedId = new ConcurrentHashMap<>();
7981
private final Map<String, List<TestStepFinished>> testStepsFinishedByTestCaseStartedId = new ConcurrentHashMap<>();
@@ -107,6 +109,7 @@ public int countTestCasesStarted() {
107109
}
108110

109111
public List<Pickle> findAllPickles() {
112+
// TODO: This should sort by URI and location
110113
return pickleById.values().stream()
111114
.sorted(comparing(Pickle::getId))
112115
.collect(toList());

java/src/main/java/io/cucumber/query/TimestampComparator.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

java/src/test/java/io/cucumber/query/TimestampComparatorTest.java

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)