Skip to content

Commit 2f48140

Browse files
committed
server: Hiding data behind methods
1 parent 093f775 commit 2f48140

File tree

3 files changed

+35
-25
lines changed

3 files changed

+35
-25
lines changed

Diff for: java/server/src/org/openqa/grid/common/GridRole.java

+24-20
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.openqa.grid.common;
1919

20+
import com.google.common.collect.ImmutableList;
21+
2022
import org.openqa.grid.common.exception.GridConfigurationException;
2123

2224
import java.util.ArrayList;
@@ -25,6 +27,23 @@
2527
public enum GridRole {
2628
NOT_GRID, HUB, NODE;
2729

30+
private static List<String> rcAliases = new ImmutableList.Builder<String>()
31+
.add("rc")
32+
.add("remotecontrol")
33+
.add("remote-control")
34+
.build();
35+
36+
private static List<String> wdAliases = new ImmutableList.Builder<String>()
37+
.add("wd")
38+
.add("webdriver")
39+
.build();
40+
41+
private static List<String> nodeAliases = new ImmutableList.Builder<String>()
42+
.add("node")
43+
.addAll(rcAliases)
44+
.addAll(wdAliases)
45+
.build();
46+
2847
/**
2948
* finds the requested role from the parameters.
3049
*
@@ -42,7 +61,7 @@ public static GridRole find(String[] args) {
4261
"-role needs to be followed by the role of this component in the grid.");
4362
} else {
4463
String role = args[i + 1].toLowerCase();
45-
if (NodeAliases().contains(role)) {
64+
if (nodeAliases.contains(role)) {
4665
return NODE;
4766
} else if ("hub".equals(role)) {
4867
return HUB;
@@ -56,26 +75,11 @@ public static GridRole find(String[] args) {
5675
return NOT_GRID;
5776
}
5877

59-
private static List<String> NodeAliases() {
60-
List<String> res = new ArrayList<String>();
61-
res.add("node");
62-
res.addAll(RCAliases());
63-
res.addAll(WDAliases());
64-
return res;
65-
}
66-
67-
public static List<String> RCAliases() {
68-
List<String> res = new ArrayList<String>();
69-
res.add("rc");
70-
res.add("remotecontrol");
71-
res.add("remote-control");
72-
return res;
78+
public static boolean isRC(String nodeType) {
79+
return rcAliases.contains(nodeType);
7380
}
7481

75-
public static List<String> WDAliases() {
76-
List<String> res = new ArrayList<String>();
77-
res.add("wd");
78-
res.add("webdriver");
79-
return res;
82+
public static boolean isWebDriver(String nodeType) {
83+
return wdAliases.contains(nodeType);
8084
}
8185
}

Diff for: java/server/src/org/openqa/grid/common/RegistrationRequest.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -366,17 +366,15 @@ public static RegistrationRequest build(String... args) {
366366

367367
res.role = GridRole.find(args);
368368

369-
370369
String defaultConfig = "defaults/DefaultNode.json";
371370
String nodeType = helper.getParamValue("-role");
372-
if (GridRole.RCAliases().contains(nodeType)) {
371+
if (GridRole.isRC(nodeType)) {
373372
defaultConfig = "defaults/DefaultNodeSelenium.json";
374373
}
375-
if (GridRole.WDAliases().contains(nodeType)) {
374+
if (GridRole.isWebDriver(nodeType)) {
376375
defaultConfig = "defaults/DefaultNodeWebDriver.json";
377376
}
378377

379-
380378
res.loadFromJSON(defaultConfig);
381379

382380
// -file *.json ?
@@ -398,7 +396,7 @@ public static RegistrationRequest build(String... args) {
398396
}
399397
if (cap.getCapability(SELENIUM_PROTOCOL) == null) {
400398
cap.setCapability(SELENIUM_PROTOCOL,
401-
GridRole.RCAliases().contains(nodeType)
399+
GridRole.isRC(nodeType)
402400
? SeleniumProtocol.Selenium.toString() : SeleniumProtocol.WebDriver.toString());
403401
}
404402
}

Diff for: java/server/src/org/openqa/grid/common/Utils.java

+8
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,16 @@
1919

2020
import org.openqa.selenium.remote.BrowserType;
2121

22+
/**
23+
* @deprecated This class is not used in Selenium code, to be removed in the next release
24+
*/
25+
@Deprecated
2226
public class Utils {
2327

28+
/**
29+
* @deprecated This method is not used in Selenium code, to be removed in the next release
30+
*/
31+
@Deprecated
2432
public static String getSelenium1Equivalent(String webDriverBrowserName) {
2533
if (BrowserType.FIREFOX.equals(webDriverBrowserName)) {
2634
return "*firefox";

0 commit comments

Comments
 (0)