Skip to content
Draft
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
6 changes: 3 additions & 3 deletions java/src/org/openqa/selenium/grid/graphql/Grid.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

package org.openqa.selenium.grid.graphql;

import com.google.common.collect.ImmutableList;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -68,7 +68,7 @@ public String getVersion() {
}

public List<Node> getNodes() {
ImmutableList.Builder<Node> toReturn = ImmutableList.builder();
List<Node> toReturn = new ArrayList<>();

for (NodeStatus status : distributorStatus.getNodes()) {
Map<Capabilities, Integer> stereotypes = new HashMap<>();
Expand Down Expand Up @@ -105,7 +105,7 @@ public List<Node> getNodes() {
osInfo));
}

return toReturn.build();
return Collections.unmodifiableList(toReturn);
}

public int getNodeCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
Expand Down Expand Up @@ -85,7 +86,7 @@ public byte[] apply(Session session, Map<String, Object> metadata) {

@Override
public byte[] apply(Session session) {
return apply(session, ImmutableMap.of());
return apply(session, Map.of());
}

/** Create a UTF-8 encoded response for a given dialect for use with the New Session command. */
Expand All @@ -108,14 +109,14 @@ private static byte[] encodeAsResponse(

private static Map<String, Object> encodeW3C(
SessionId id, Capabilities capabilities, Map<String, Object> metadata) {
return ImmutableMap.<String, Object>builder()
.putAll(metadata)
.put(
"value",
ImmutableMap.of(
"sessionId", id,
"capabilities", capabilities))
.build();
Map<String, Object> encodedResult = new HashMap<>(metadata);
encodedResult.put(
"value",
Map.of(
"sessionId", id,
"capabilities", capabilities));

return Collections.unmodifiableMap(encodedResult);
}
}
}
14 changes: 6 additions & 8 deletions java/src/org/openqa/selenium/grid/node/CustomLocatorHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import static org.openqa.selenium.json.Json.MAP_TYPE;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Map;
Expand Down Expand Up @@ -72,7 +70,7 @@ class CustomLocatorHandler implements Routable {
new UrlTemplate("/session/{sessionId}/element/{elementId}/elements");
// These are derived from the w3c webdriver spec
private static final Set<String> W3C_STRATEGIES =
ImmutableSet.of("css selector", "link text", "partial link text", "tag name", "xpath");
Set.of("css selector", "link text", "partial link text", "tag name", "xpath");
private final HttpHandler toNode;
private final Map<String, Function<Object, By>> extraLocators;

Expand Down Expand Up @@ -119,9 +117,9 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
.setStatus(HTTP_BAD_REQUEST)
.setContent(
Contents.asJson(
ImmutableMap.of(
Map.of(
"value",
ImmutableMap.of(
Map.of(
"error", "invalid argument",
"message", "Unable to determine element locating strategy",
"stacktrace", ""))));
Expand All @@ -138,9 +136,9 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
.setStatus(HTTP_BAD_REQUEST)
.setContent(
Contents.asJson(
ImmutableMap.of(
Map.of(
"value",
ImmutableMap.of(
Map.of(
"error", "invalid argument",
"message", "Unable to determine element locator arguments",
"stacktrace", ""))));
Expand Down Expand Up @@ -224,7 +222,7 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
toReturn = context.findElement(by);
}

return new HttpResponse().setContent(Contents.asJson(ImmutableMap.of("value", toReturn)));
return new HttpResponse().setContent(Contents.asJson(Map.of("value", toReturn)));
}

private static class NodeWrappingExecutor implements CommandExecutor {
Expand Down
4 changes: 2 additions & 2 deletions java/src/org/openqa/selenium/grid/node/GetNodeSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import static org.openqa.selenium.remote.http.Contents.asJson;

import com.google.common.collect.ImmutableMap;
import java.io.UncheckedIOException;
import java.util.Map;
import org.openqa.selenium.grid.data.Session;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.SessionId;
Expand All @@ -42,6 +42,6 @@ class GetNodeSession implements HttpHandler {
public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
Session session = node.getSession(id);

return new HttpResponse().setContent(asJson(ImmutableMap.of("value", session)));
return new HttpResponse().setContent(asJson(Map.of("value", session)));
}
}
4 changes: 2 additions & 2 deletions java/src/org/openqa/selenium/grid/node/IsSessionOwner.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import static org.openqa.selenium.remote.http.Contents.asJson;

import com.google.common.collect.ImmutableMap;
import java.io.UncheckedIOException;
import java.util.Map;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.SessionId;
import org.openqa.selenium.remote.http.HttpHandler;
Expand All @@ -39,6 +39,6 @@ class IsSessionOwner implements HttpHandler {

@Override
public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
return new HttpResponse().setContent(asJson(ImmutableMap.of("value", node.isSessionOwner(id))));
return new HttpResponse().setContent(asJson(Map.of("value", node.isSessionOwner(id))));
}
}
4 changes: 2 additions & 2 deletions java/src/org/openqa/selenium/grid/node/NewNodeSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import static org.openqa.selenium.remote.http.Contents.asJson;
import static org.openqa.selenium.remote.http.Contents.string;

import com.google.common.collect.ImmutableMap;
import java.io.UncheckedIOException;
import java.util.HashMap;
import java.util.Map;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.grid.data.CreateSessionRequest;
import org.openqa.selenium.grid.data.CreateSessionResponse;
Expand Down Expand Up @@ -58,7 +58,7 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
WebDriverException exception = result.left();
response.put(
"exception",
ImmutableMap.of(
Map.of(
"error", exception.getClass(),
"message", exception.getMessage()));
}
Expand Down
9 changes: 4 additions & 5 deletions java/src/org/openqa/selenium/grid/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import static org.openqa.selenium.remote.http.Route.matching;
import static org.openqa.selenium.remote.http.Route.post;

import com.google.common.collect.ImmutableMap;
import java.io.IOException;
import java.net.URI;
import java.time.Duration;
Expand Down Expand Up @@ -125,7 +124,7 @@ public abstract class Node implements HasReadyState, Routable {

private static final Logger LOG = Logger.getLogger(Node.class.getName());
private static final BuildInfo INFO = new BuildInfo();
private static final ImmutableMap<String, String> OS_INFO = loadOsInfo();
private static final Map<String, String> OS_INFO = loadOsInfo();
protected final Tracer tracer;
private final NodeId id;
private final URI uri;
Expand Down Expand Up @@ -206,8 +205,8 @@ protected Node(
get("/status").to(() -> new StatusHandler(this)).with(spanDecorator("node.status")));
}

private static ImmutableMap<String, String> loadOsInfo() {
return ImmutableMap.of(
private static Map<String, String> loadOsInfo() {
return Map.of(
"arch", System.getProperty("os.arch"),
"name", System.getProperty("os.name"),
"version", System.getProperty("os.version"));
Expand All @@ -233,7 +232,7 @@ public String getNodeVersion() {
return String.format("%s (revision %s)", INFO.getReleaseLabel(), INFO.getBuildRevision());
}

public ImmutableMap<String, String> getOsInfo() {
public Map<String, String> getOsInfo() {
return OS_INFO;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import static org.openqa.selenium.internal.Debug.getDebugLogLevel;
import static org.openqa.selenium.remote.http.HttpMethod.GET;

import com.google.common.collect.ImmutableSet;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.logging.Level;
Expand Down Expand Up @@ -53,8 +53,8 @@ public class ProxyNodeWebsockets
private static final UrlTemplate FWD_TEMPLATE = new UrlTemplate("/session/{sessionId}/se/fwd");
private static final UrlTemplate VNC_TEMPLATE = new UrlTemplate("/session/{sessionId}/se/vnc");
private static final Logger LOG = Logger.getLogger(ProxyNodeWebsockets.class.getName());
private static final ImmutableSet<String> CDP_ENDPOINT_CAPS =
ImmutableSet.of("goog:chromeOptions", "ms:edgeOptions");
private static final Set<String> CDP_ENDPOINT_CAPS =
Set.of("goog:chromeOptions", "ms:edgeOptions");
private final HttpClient.Factory clientFactory;
private final Node node;
private final String gridSubPath;
Expand Down
8 changes: 4 additions & 4 deletions java/src/org/openqa/selenium/grid/node/StatusHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import static org.openqa.selenium.remote.http.Contents.asJson;

import com.google.common.collect.ImmutableMap;
import java.io.UncheckedIOException;
import java.util.Map;
import org.openqa.selenium.grid.data.NodeStatus;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.http.HttpHandler;
Expand All @@ -39,10 +39,10 @@ class StatusHandler implements HttpHandler {
public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
NodeStatus status = node.getStatus();

ImmutableMap<String, Object> report =
ImmutableMap.of(
Map<String, Object> report =
Map.of(
"value",
ImmutableMap.of(
Map.of(
"ready",
status.hasCapacity(),
"message",
Expand Down
Loading
Loading