[grid] Using DefaultSlotMatcher in DockerSessionFactory
With this, all places where matching is done are now
using the same logic for matching. Next step is to
retrieve the matching class from the configuration.
Fixes
import org.openqa.selenium.docker.Image;
import org.openqa.selenium.docker.Port;
import org.openqa.selenium.grid.data.CreateSessionRequest;
+import org.openqa.selenium.grid.data.DefaultSlotMatcher;
+import org.openqa.selenium.grid.data.SlotMatcher;
import org.openqa.selenium.grid.node.ActiveSession;
import org.openqa.selenium.grid.node.SessionFactory;
import org.openqa.selenium.internal.Either;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import java.util.Objects;
import java.util.Optional;
import java.util.TimeZone;
import java.util.logging.Level;
private final DockerAssetsPath assetsPath;
private final String networkName;
private final boolean runningInDocker;
+ private final SlotMatcher slotMatcher;
public DockerSessionFactory(
Tracer tracer,
@@ -120,16 +122,12 @@ public DockerSessionFactory(
this.videoImage = videoImage;
this.assetsPath = assetsPath;
this.runningInDocker = runningInDocker;
+ this.slotMatcher = new DefaultSlotMatcher();
}
@Override
public boolean test(Capabilities capabilities) {
- return stereotype.getCapabilityNames().stream()
- .map(
- name ->
- Objects.equals(stereotype.getCapability(name), capabilities.getCapability(name)))
- .reduce(Boolean::logicalAnd)
- .orElse(false);
+ return slotMatcher.matches(stereotype, capabilities);
}
@Override
