Better follow project coding style
import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME;
-import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import org.openqa.selenium.ImmutableCapabilities;
import org.openqa.selenium.Platform;
interface Validator extends BiFunction<Map<String, Object>, Map<String, Object>, Boolean> {}
private boolean anything(Object requested) {
- return requested == null
- || ImmutableList.of("any", "", "*").contains(requested.toString().toLowerCase());
+ return requested == null ||
+ ImmutableSet.of("any", "", "*").contains(requested.toString().toLowerCase());
}
class PlatformValidator implements Validator {
@@ -83,12 +83,20 @@ public Boolean apply(Map<String, Object> providedCapabilities, Map<String, Objec
@Override
public Boolean apply(Map<String, Object> providedCapabilities, Map<String, Object> requestedCapabilities) {
Object requested = Stream.of(propertyAliases)
- .map(requestedCapabilities::get).filter(Objects::nonNull).findFirst().orElse(null);
+ .map(requestedCapabilities::get)
+ .filter(Objects::nonNull)
+ .findFirst()
+ .orElse(null);
+
if (anything(requested)) {
return true;
}
+
Object provided = Stream.of(propertyAliases)
- .map(providedCapabilities::get).filter(Objects::nonNull).findFirst().orElse(null);
+ .map(providedCapabilities::get)
+ .filter(Objects::nonNull)
+ .findFirst()
+ .orElse(null);
return Objects.equals(requested, provided);
}
}
@@ -116,13 +124,14 @@ public Boolean apply(Map<String, Object> providedCapabilities, Map<String, Objec
if (! "firefox".equals(requestedCapabilities.get(BROWSER_NAME))) {
return true;
}
- if (requestedCapabilities.get("marionette") != null
- && !Boolean.valueOf(requestedCapabilities.get("marionette").toString())) {
- return providedCapabilities.get("marionette") != null
- && !Boolean.valueOf(providedCapabilities.get("marionette").toString());
+
+ if (requestedCapabilities.get("marionette") != null &&
+ !Boolean.valueOf(requestedCapabilities.get("marionette").toString())) {
+ return providedCapabilities.get("marionette") != null &&
+ !Boolean.valueOf(providedCapabilities.get("marionette").toString());
} else {
- return providedCapabilities.get("marionette") == null
- || Boolean.valueOf(providedCapabilities.get("marionette").toString());
+ return providedCapabilities.get("marionette") == null ||
+ Boolean.valueOf(providedCapabilities.get("marionette").toString());
}
}
}
