Skip to content

Commit b91fa90

Browse files
committed
Refactor multiline string formatting for consistency in Java files
1 parent fb094af commit b91fa90

File tree

8 files changed

+26
-18
lines changed

8 files changed

+26
-18
lines changed

java/src/org/openqa/selenium/devtools/CdpClientGenerator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,12 +1021,13 @@ public TypeDeclaration<?> toTypeDeclaration() {
10211021
.get()
10221022
.addStatement(
10231023
String.format(
1024-
"""
1024+
"""
10251025
return java.util.Arrays.stream(%s.values())
10261026
.filter(rs -> rs.value.equalsIgnoreCase(s))
10271027
.findFirst()
10281028
.orElseThrow(() -> new org.openqa.selenium.devtools.DevToolsException(
1029-
"Given value " + s + " is not found within %s "));""",
1029+
"Given value " + s + " is not found within %s "));\
1030+
""",
10301031
name, name));
10311032

10321033
enumDecl

java/src/org/openqa/selenium/grid/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public Executable configure(PrintStream out, PrintStream err, String... args) {
143143

144144
outWriter.write("\nFor each command, run with `--help` for command-specific help\n");
145145
outWriter.write(
146-
"""
146+
"""
147147
148148
Use the `--ext` flag before the command name to specify an additional \
149149
classpath to use with the server (for example, to provide additional \

java/src/org/openqa/selenium/grid/node/config/NodeFlags.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,15 @@ public class NodeFlags implements HasRoles {
173173
name = "driver-configuration",
174174
prefixed = true,
175175
example =
176-
"""
176+
"""
177177
178178
display-name = "Firefox Nightly"
179179
webdriver-executable = "/usr/local/bin/geckodriver"
180180
max-sessions = 2
181181
stereotype = "{\\"browserName\\": \\"firefox\\", \\"browserVersion\\":\
182182
\\"86\\", \\"moz:firefoxOptions\\": {\\"binary\\":\\"/Applications/Firefox\
183-
Nightly.app/Contents/MacOS/firefox\\"}}\"""")
183+
Nightly.app/Contents/MacOS/firefox\\"}}\"\
184+
""")
184185
public List<String> driverConfiguration;
185186

186187
@Parameter(

java/src/org/openqa/selenium/grid/node/relay/RelayFlags.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ public class RelayFlags implements HasRoles {
5151
name = "configs",
5252
prefixed = true,
5353
example =
54-
"""
54+
"""
5555
5656
max-sessions = 2
5757
stereotype = "{\\"browserName\\": \\"safari\\", \\"platformName\\":\
58-
\\"iOS\\", \\"appium:platformVersion\\": \\"14.5\\" }}\"""")
58+
\\"iOS\\", \\"appium:platformVersion\\": \\"14.5\\" }}\"\
59+
""")
5960
public List<String> driverConfiguration;
6061

6162
@Parameter(

java/src/org/openqa/selenium/grid/sessionmap/jdbc/JdbcSessionMapOptions.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ public JdbcSessionMapOptions(Config config) {
4646
}
4747
} catch (NoSuchElementException e) {
4848
throw new JdbcException(
49-
"""
49+
"""
5050
Missing session options. Check and add all the following options\s
5151
\
5252
--jdbc-url <url>\s
5353
--jdbc-user <user>\s
54-
--jdbc-password <password>""");
54+
--jdbc-password <password>\
55+
""");
5556
}
5657
}
5758

java/src/org/openqa/selenium/remote/Augmenter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public WebDriver augment(WebDriver driver) {
147147

148148
if (driver instanceof Decorated<?>) {
149149
LOG.warning(
150-
"""
150+
"""
151151
Warning: In future versions, passing a decorated driver will no longer be allowed.
152152
Instead, augment the driver first and then use it to created a decorated\
153153
driver.
@@ -156,7 +156,8 @@ public WebDriver augment(WebDriver driver) {
156156
For example, augmenting HasDevTools interface to a decorated driver.\s
157157
The decorated driver is not aware that after augmentation it is an instance of\
158158
HasDevTools. So it does not invoke the close() method of the underlying\
159-
websocket, potentially causing a memory leak.\s""");
159+
websocket, potentially causing a memory leak.\s\
160+
""");
160161
}
161162

162163
Capabilities caps = ImmutableCapabilities.copyOf(((HasCapabilities) driver).getCapabilities());

java/src/org/openqa/selenium/remote/codec/w3c/W3CHttpCommandCodec.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,11 @@ public W3CHttpCommandCodec() {
214214

215215
case GET_PAGE_SOURCE:
216216
return toScript(
217-
"""
217+
"""
218218
var source = document.documentElement.outerHTML;\s
219219
if (!source) { source = new XMLSerializer().serializeToString(document); }
220-
return source;""");
220+
return source;\
221+
""");
221222

222223
case CLEAR_LOCAL_STORAGE:
223224
return toScript("localStorage.clear()");
@@ -328,7 +329,7 @@ public W3CHttpCommandCodec() {
328329
}
329330
case SUBMIT_ELEMENT:
330331
return toScript(
331-
"""
332+
"""
332333
/* submitForm */var form = arguments[0];
333334
while (form.nodeName != "FORM" && form.parentNode) {
334335
form = form.parentNode;

java/test/org/openqa/selenium/remote/codec/w3c/W3CHttpResponseCodecTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ void noErrorNoCry() {
6060
@Test
6161
void shouldBeAbleToHandleGatewayTimeoutError() {
6262
String responseString =
63-
"""
63+
"""
6464
<html>\r
6565
<body>\r
6666
<h1>504 Gateway Time-out</h1>\r
6767
The server didn't respond in time.\r
6868
</body>\r
69-
</html>""";
69+
</html>\
70+
""";
7071

7172
byte[] contents = responseString.getBytes(UTF_8);
7273

@@ -86,14 +87,15 @@ void shouldBeAbleToHandleGatewayTimeoutError() {
8687
@Test
8788
void shouldBeAbleToHandleBadGatewayError() {
8889
String responseString =
89-
"""
90+
"""
9091
<html>\r
9192
<head><title>502 Bad Gateway</title></head>\r
9293
<body>\r
9394
<center><h1>502 Bad Gateway</h1></center>\r
9495
<hr><center>nginx</center>\r
9596
</body>\r
96-
</html>""";
97+
</html>\
98+
""";
9799

98100
byte[] contents = responseString.getBytes(UTF_8);
99101

0 commit comments

Comments
 (0)