[java] Fixing Java 8 incompatibilities in tests
import org.openqa.selenium.remote.tracing.Tracer;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
+import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -83,8 +86,10 @@ public void nestingSpansInTheSameThreadShouldWork() {
}
}
- SpanData parent = allSpans.stream().filter(data -> data.getName().equals("parent")).findFirst().orElseThrow();
- SpanData child = allSpans.stream().filter(data -> data.getName().equals("child")).findFirst().orElseThrow();
+ SpanData parent = allSpans.stream().filter(data -> data.getName().equals("parent"))
+ .findFirst().orElseThrow(NoSuchElementException::new);
+ SpanData child = allSpans.stream().filter(data -> data.getName().equals("child"))
+ .findFirst().orElseThrow(NoSuchElementException::new);
assertThat(child.getParentSpanId()).isEqualTo(parent.getSpanId());
}
@@ -103,8 +108,10 @@ public void nestingSpansFromDifferentThreadsIsFineToo() throws ExecutionExceptio
future.get();
}
- SpanData parent = allSpans.stream().filter(data -> data.getName().equals("parent")).findFirst().orElseThrow();
- SpanData child = allSpans.stream().filter(data -> data.getName().equals("child")).findFirst().orElseThrow();
+ SpanData parent = allSpans.stream().filter(data -> data.getName().equals("parent"))
+ .findFirst().orElseThrow(NoSuchElementException::new);
+ SpanData child = allSpans.stream().filter(data -> data.getName().equals("child"))
+ .findFirst().orElseThrow(NoSuchElementException::new);
assertThat(child.getParentSpanId()).isEqualTo(parent.getSpanId());
}
@@ -166,7 +173,7 @@ public void cleverShenanigansRepresentingWhatWeSeeInTheRouter() {
handler.addHandler(Route.get("/status").to(() -> req -> {
try (Span span = HttpTracing.newSpanAsChildOf(tracer, req, "status")) {
- executors.submit(span.wrap(() -> Set.of("cheese", "peas"))).get();
+ executors.submit(span.wrap(() -> new HashSet<>(Arrays.asList("cheese", "peas")))).get();
CompletableFuture<String> toReturn = new CompletableFuture<>();
executors.submit(() -> {
