Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java]Replace lambdas with method references #14857

Merged
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
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/chromium/ChromiumDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected ChromiumDriver(

try {
try {
cdpUri = client.flatMap(httpClient -> CdpEndpointFinder.getCdpEndPoint(httpClient));
cdpUri = client.flatMap(CdpEndpointFinder::getCdpEndPoint);
} catch (Exception e) {
try {
client.ifPresent(HttpClient::close);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static Optional<Connection> create(
client = reportedUri.map(uri -> CdpEndpointFinder.getHttpClient(clientFactory, uri));

try {
cdpUri = client.flatMap(httpClient -> CdpEndpointFinder.getCdpEndPoint(httpClient));
cdpUri = client.flatMap(CdpEndpointFinder::getCdpEndPoint);
} catch (Exception e) {
try {
client.ifPresent(HttpClient::close);
Expand All @@ -87,7 +87,7 @@ public static Optional<Connection> create(
throw e;
}

if (!cdpUri.isPresent()) {
if (cdpUri.isEmpty()) {
try {
client.ifPresent(HttpClient::close);
} catch (Exception e) {
Expand Down
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/firefox/FirefoxDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private FirefoxDriver(
Optional<URI> cdpUri;

try {
cdpUri = client.flatMap(httpClient -> CdpEndpointFinder.getCdpEndPoint(httpClient));
cdpUri = client.flatMap(CdpEndpointFinder::getCdpEndPoint);
} catch (Exception e) {
try {
client.ifPresent(HttpClient::close);
Expand Down
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/remote/RemoteWebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ public void addCredential(Credential credential) {
Stream.concat(
credential.toMap().entrySet().stream(),
Stream.of(Map.entry("authenticatorId", id)))
.collect(Collectors.toUnmodifiableMap((e) -> e.getKey(), (e) -> e.getValue())));
.collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue)));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion java/test/org/openqa/selenium/NoSuchShadowRootTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public void getNoSuchShadowRoot() {
driver.get(pages.shadowRootPage);
WebElement nonExistentShadowRootElement = driver.findElement(By.id("noShadowRoot"));
assertThatExceptionOfType(NoSuchShadowRootException.class)
.isThrownBy(() -> nonExistentShadowRootElement.getShadowRoot());
.isThrownBy(nonExistentShadowRootElement::getShadowRoot);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,7 @@ void protocolVersionThrowsConfigException() {
Config config = new TomlConfig(new StringReader(String.join("\n", rawConfig)));
RelayOptions relayOptions = new RelayOptions(config);
assertThatExceptionOfType(ConfigException.class)
.isThrownBy(
() -> {
relayOptions.getServiceProtocolVersion();
})
.isThrownBy(relayOptions::getServiceProtocolVersion)
.withMessageContaining("Unsupported protocol version provided: HTTP/0.9");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ void externalUriFailsForNonUriStrings() {
BaseServerOptions options =
new BaseServerOptions(new MapConfig(Map.of("server", Map.of("external-url", "not a URL"))));

Exception exception =
assertThrows(
RuntimeException.class,
() -> {
options.getExternalUri();
});
Exception exception = assertThrows(RuntimeException.class, options::getExternalUri);

assertThat(exception.getMessage())
.as("External URI must be parseable as URI.")
Expand Down
Loading