Skip to content

Commit 472078c

Browse files
committed
Restoring DefaultCapabilityMatcher.addToConsider method deleted by mistake.
1 parent 6e95a66 commit 472078c

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

java/server/src/org/openqa/grid/internal/utils/DefaultCapabilityMatcher.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.openqa.selenium.remote.CapabilityType;
2727
import org.openqa.selenium.safari.SafariOptions;
2828

29+
import java.util.ArrayList;
2930
import java.util.Arrays;
3031
import java.util.List;
3132
import java.util.Map;
@@ -140,14 +141,21 @@ public Boolean apply(Map<String, Object> providedCapabilities, Map<String, Objec
140141
}
141142
}
142143

143-
private final List<Validator> validators = ImmutableList.of(
144-
new PlatformValidator(),
145-
new AliasedPropertyValidator(CapabilityType.BROWSER_NAME, "browser"),
146-
new AliasedPropertyValidator(CapabilityType.BROWSER_VERSION, CapabilityType.VERSION),
147-
new SimplePropertyValidator(CapabilityType.APPLICATION_NAME),
148-
new FirefoxSpecificValidator(),
149-
new SafariSpecificValidator()
150-
);
144+
private final List<Validator> validators = new ArrayList<>();
145+
{
146+
validators.addAll(Arrays.asList(
147+
new PlatformValidator(),
148+
new AliasedPropertyValidator(CapabilityType.BROWSER_NAME, "browser"),
149+
new AliasedPropertyValidator(CapabilityType.BROWSER_VERSION, CapabilityType.VERSION),
150+
new SimplePropertyValidator(CapabilityType.APPLICATION_NAME),
151+
new FirefoxSpecificValidator(),
152+
new SafariSpecificValidator()
153+
));
154+
}
155+
156+
public void addToConsider(String capabilityName) {
157+
validators.add(new SimplePropertyValidator(capabilityName));
158+
}
151159

152160
public boolean matches(Map<String, Object> providedCapabilities, Map<String, Object> requestedCapabilities) {
153161
return providedCapabilities != null && requestedCapabilities != null

java/server/test/org/openqa/grid/internal/utils/DefaultCapabilityMatcherTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ public void unknownPlatformMatchingTest() {
107107
assertFalse(matcher.matches(ImmutableMap.of(CapabilityType.PLATFORM, "PS/2"), requested));
108108
}
109109

110+
@Test
111+
public void canAddAttributeMatcher() {
112+
matcher.addToConsider("my:capability");
113+
Map<String, Object> requested = ImmutableMap.of("my:capability", "cheese");
114+
assertTrue(matcher.matches(ImmutableMap.of("my:capability", "cheese"), requested));
115+
assertFalse(matcher.matches(ImmutableMap.of("my:capability", "milk"), requested));
116+
}
117+
110118
@Test
111119
public void nullEmptyValues() {
112120
Map<String, Object> requested = new HashMap<>();

0 commit comments

Comments
 (0)