Skip to content

Commit

Permalink
[java] Use Java Map instead of Guava Immutable Map in Chromium package
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani committed Oct 10, 2023
1 parent cdd75fc commit ca15a17
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 22 deletions.
10 changes: 4 additions & 6 deletions java/src/org/openqa/selenium/chromium/AddHasCasting.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.openqa.selenium.chromium;

import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
Expand Down Expand Up @@ -62,22 +61,21 @@ public List<Map<String, String>> getCastSinks() {
public void selectCastSink(String deviceName) {
Require.nonNull("Device Name", deviceName);

executeMethod.execute(SET_CAST_SINK_TO_USE, ImmutableMap.of("sinkName", deviceName));
executeMethod.execute(SET_CAST_SINK_TO_USE, Map.of("sinkName", deviceName));
}

@Override
public void startDesktopMirroring(String deviceName) {
Require.nonNull("Device Name", deviceName);

executeMethod.execute(
START_CAST_DESKTOP_MIRRORING, ImmutableMap.of("sinkName", deviceName));
executeMethod.execute(START_CAST_DESKTOP_MIRRORING, Map.of("sinkName", deviceName));
}

@Override
public void startTabMirroring(String deviceName) {
Require.nonNull("Device Name", deviceName);

executeMethod.execute(START_CAST_TAB_MIRRORING, ImmutableMap.of("sinkName", deviceName));
executeMethod.execute(START_CAST_TAB_MIRRORING, Map.of("sinkName", deviceName));
}

@Override
Expand All @@ -89,7 +87,7 @@ public String getCastIssueMessage() {
public void stopCasting(String deviceName) {
Require.nonNull("Device Name", deviceName);

executeMethod.execute(STOP_CASTING, ImmutableMap.of("sinkName", deviceName));
executeMethod.execute(STOP_CASTING, Map.of("sinkName", deviceName));
}
};
}
Expand Down
5 changes: 2 additions & 3 deletions java/src/org/openqa/selenium/chromium/AddHasCdp.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import static org.openqa.selenium.chromium.ChromiumDriver.IS_CHROMIUM_BROWSER;

import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.function.Predicate;
import org.openqa.selenium.Capabilities;
Expand Down Expand Up @@ -58,9 +57,9 @@ public Map<String, Object> executeCdpCommand(
Map<String, Object> toReturn =
(Map<String, Object>)
executeMethod.execute(
EXECUTE_CDP, ImmutableMap.of("cmd", commandName, "params", parameters));
EXECUTE_CDP, Map.of("cmd", commandName, "params", parameters));

return ImmutableMap.copyOf(toReturn);
return Map.copyOf(toReturn);
}
};
}
Expand Down
5 changes: 2 additions & 3 deletions java/src/org/openqa/selenium/chromium/AddHasLaunchApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.openqa.selenium.chromium.ChromiumDriver.IS_CHROMIUM_BROWSER;

import com.google.auto.service.AutoService;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.function.Predicate;
import org.openqa.selenium.Capabilities;
Expand All @@ -38,7 +37,7 @@ public class AddHasLaunchApp implements AugmenterProvider<HasLaunchApp>, Additio
public static final String LAUNCH_APP = "launchApp";

private static final Map<String, CommandInfo> COMMANDS =
ImmutableMap.of(
Map.of(
LAUNCH_APP, new CommandInfo("/session/:sessionId/chromium/launch_app", HttpMethod.POST));

@Override
Expand All @@ -63,7 +62,7 @@ public HasLaunchApp getImplementation(Capabilities capabilities, ExecuteMethod e
public void launchApp(String id) {
Require.nonNull("id of Chromium App", id);

executeMethod.execute(LAUNCH_APP, ImmutableMap.of("id", id));
executeMethod.execute(LAUNCH_APP, Map.of("id", id));
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.openqa.selenium.chromium.ChromiumDriver.IS_CHROMIUM_BROWSER;

import com.google.auto.service.AutoService;
import com.google.common.collect.ImmutableMap;
import java.time.Duration;
import java.util.Map;
import java.util.function.Predicate;
Expand All @@ -42,7 +41,7 @@ public class AddHasNetworkConditions
public static final String DELETE_NETWORK_CONDITIONS = "deleteNetworkConditions";

private static final Map<String, CommandInfo> COMMANDS =
ImmutableMap.of(
Map.of(
GET_NETWORK_CONDITIONS,
new CommandInfo("/session/:sessionId/chromium/network_conditions", HttpMethod.GET),
SET_NETWORK_CONDITIONS,
Expand Down Expand Up @@ -94,7 +93,7 @@ public void setNetworkConditions(ChromiumNetworkConditions networkConditions) {
Require.nonNull("Network Conditions", networkConditions);

Map<String, Object> conditions =
ImmutableMap.of(
Map.of(
ChromiumNetworkConditions.OFFLINE,
networkConditions.getOffline(),
ChromiumNetworkConditions.LATENCY,
Expand All @@ -103,8 +102,7 @@ public void setNetworkConditions(ChromiumNetworkConditions networkConditions) {
networkConditions.getDownloadThroughput(),
ChromiumNetworkConditions.UPLOAD_THROUGHPUT,
networkConditions.getUploadThroughput());
executeMethod.execute(
SET_NETWORK_CONDITIONS, ImmutableMap.of("network_conditions", conditions));
executeMethod.execute(SET_NETWORK_CONDITIONS, Map.of("network_conditions", conditions));
}

@Override
Expand Down
7 changes: 2 additions & 5 deletions java/src/org/openqa/selenium/chromium/AddHasPermissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.openqa.selenium.chromium.ChromiumDriver.IS_CHROMIUM_BROWSER;

import com.google.auto.service.AutoService;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.function.Predicate;
import org.openqa.selenium.Capabilities;
Expand All @@ -39,8 +38,7 @@ public class AddHasPermissions
public static final String SET_PERMISSION = "setPermission";

private static final Map<String, CommandInfo> COMMANDS =
ImmutableMap.of(
SET_PERMISSION, new CommandInfo("/session/:sessionId/permissions", HttpMethod.POST));
Map.of(SET_PERMISSION, new CommandInfo("/session/:sessionId/permissions", HttpMethod.POST));

@Override
public Map<String, CommandInfo> getAdditionalCommands() {
Expand All @@ -66,8 +64,7 @@ public void setPermission(String name, String value) {
Require.nonNull("Permission value", value);

executeMethod.execute(
SET_PERMISSION,
ImmutableMap.of("descriptor", ImmutableMap.of("name", name), "state", value));
SET_PERMISSION, Map.of("descriptor", Map.of("name", name), "state", value));
}
};
}
Expand Down

0 comments on commit ca15a17

Please sign in to comment.