How to use equals method of org.openqa.selenium.grid.data.SlotId class

Best Selenium code snippet using org.openqa.selenium.grid.data.SlotId.equals

Source:GridModel.java Github

copy

Full Screen

...71 Iterator<NodeStatus> iterator = nodes.iterator();72 while (iterator.hasNext()) {73 NodeStatus next = iterator.next();74 // If the ID is the same, we're re-adding a node. If the URI is the same a node probably restarted75 if (next.getId().equals(node.getId()) || next.getUri().equals(node.getUri())) {76 LOG.info(String.format("Re-adding node with id %s and URI %s.", node.getId(), node.getUri()));77 iterator.remove();78 }79 }80 }81 // Nodes are initially added in the "down" state until something changes their availability82 nodes(DOWN).add(node);83 } finally {84 writeLock.unlock();85 }86 return this;87 }88 public GridModel refresh(Secret registrationSecret, NodeStatus status) {89 Require.nonNull("Node status", status);90 Secret statusSecret = status.getRegistrationSecret() == null ? null : new Secret(status.getRegistrationSecret());91 if (!Objects.equals(registrationSecret, statusSecret)) {92 LOG.severe(String.format("Node at %s failed to send correct registration secret. Node NOT refreshed.", status.getUri()));93 events.fire(new NodeRejectedEvent(status.getUri()));94 return this;95 }96 Lock writeLock = lock.writeLock();97 writeLock.lock();98 try {99 AvailabilityAndNode availabilityAndNode = findNode(status.getId());100 if (availabilityAndNode == null) {101 return this;102 }103 // if the node was marked as "down", keep it down until a healthcheck passes:104 // just because the node can hit the event bus doesn't mean it's reachable105 if (DOWN.equals(availabilityAndNode.availability)) {106 nodes(DOWN).remove(availabilityAndNode.status);107 nodes(DOWN).add(status);108 return this;109 }110 // But do trust the node if it tells us it's draining111 nodes(availabilityAndNode.availability).remove(availabilityAndNode.status);112 nodes(status.getAvailability()).add(status);113 return this;114 } finally {115 writeLock.unlock();116 }117 }118 public GridModel remove(NodeId id) {119 Require.nonNull("Node ID", id);120 Lock writeLock = lock.writeLock();121 writeLock.lock();122 try {123 AvailabilityAndNode availabilityAndNode = findNode(id);124 if (availabilityAndNode == null) {125 return this;126 }127 nodes(availabilityAndNode.availability).remove(availabilityAndNode.status);128 return this;129 } finally {130 writeLock.unlock();131 }132 }133 public Availability setAvailability(NodeId id, Availability availability) {134 Require.nonNull("Node ID", id);135 Require.nonNull("Availability", availability);136 Lock writeLock = lock.writeLock();137 writeLock.lock();138 try {139 AvailabilityAndNode availabilityAndNode = findNode(id);140 if (availabilityAndNode == null) {141 return DOWN;142 }143 if (availability.equals(availabilityAndNode.availability)) {144 return availability;145 }146 nodes(availabilityAndNode.availability).remove(availabilityAndNode.status);147 nodes(availability).add(availabilityAndNode.status);148 LOG.info(String.format(149 "Switching node %s (uri: %s) from %s to %s",150 id,151 availabilityAndNode.status.getUri(),152 availabilityAndNode.availability,153 availability));154 return availabilityAndNode.availability;155 } finally {156 writeLock.unlock();157 }158 }159 public boolean reserve(SlotId slotId) {160 Lock writeLock = lock.writeLock();161 writeLock.lock();162 try {163 AvailabilityAndNode node = findNode(slotId.getOwningNodeId());164 if (node == null) {165 LOG.warning(String.format("Asked to reserve slot on node %s, but unable to find node", slotId.getOwningNodeId()));166 return false;167 }168 if (!UP.equals(node.availability)) {169 LOG.warning(String.format(170 "Asked to reserve a slot on node %s, but not is %s",171 slotId.getOwningNodeId(),172 node.availability));173 return false;174 }175 Optional<Slot> maybeSlot = node.status.getSlots().stream()176 .filter(slot -> slotId.equals(slot.getId()))177 .findFirst();178 if (!maybeSlot.isPresent()) {179 LOG.warning(String.format(180 "Asked to reserve slot on node %s, but no slot with id %s found",181 node.status.getId(),182 slotId));183 return false;184 }185 reserve(node.status, maybeSlot.get());186 return true;187 } finally {188 writeLock.unlock();189 }190 }191 public Set<NodeStatus> getSnapshot() {192 Lock readLock = this.lock.readLock();193 readLock.lock();194 try {195 ImmutableSet.Builder<NodeStatus> snapshot = ImmutableSet.builder();196 for (Map.Entry<Availability, Set<NodeStatus>> entry : nodes.entrySet()) {197 entry.getValue().stream()198 .map(status -> rewrite(status, entry.getKey()))199 .forEach(snapshot::add);200 }201 return snapshot.build();202 } finally {203 readLock.unlock();204 }205 }206 private Set<NodeStatus> nodes(Availability availability) {207 return nodes.computeIfAbsent(availability, ignored -> new HashSet<>());208 }209 private AvailabilityAndNode findNode(NodeId id) {210 for (Map.Entry<Availability, Set<NodeStatus>> entry : nodes.entrySet()) {211 for (NodeStatus nodeStatus : entry.getValue()) {212 if (id.equals(nodeStatus.getId())) {213 return new AvailabilityAndNode(entry.getKey(), nodeStatus);214 }215 }216 }217 return null;218 }219 private NodeStatus rewrite(NodeStatus status, Availability availability) {220 return new NodeStatus(221 status.getId(),222 status.getUri(),223 status.getMaxSessionCount(),224 status.getSlots(),225 availability,226 status.getRegistrationSecret() == null ? null : new Secret(status.getRegistrationSecret()));227 }228 private void release(SessionId id) {229 if (id == null) {230 return;231 }232 Lock writeLock = lock.writeLock();233 writeLock.lock();234 try {235 for (Map.Entry<Availability, Set<NodeStatus>> entry : nodes.entrySet()) {236 for (NodeStatus node : entry.getValue()) {237 for (Slot slot : node.getSlots()) {238 if (!slot.getSession().isPresent()) {239 continue;240 }241 if (id.equals(slot.getSession().get().getId())) {242 Slot released = new Slot(243 slot.getId(),244 slot.getStereotype(),245 slot.getLastStarted(),246 Optional.empty());247 amend(entry.getKey(), node, released);248 return;249 }250 }251 }252 }253 } finally {254 writeLock.unlock();255 }256 }257 private void reserve(NodeStatus status, Slot slot) {258 Instant now = Instant.now();259 Slot reserved = new Slot(260 slot.getId(),261 slot.getStereotype(),262 now,263 Optional.of(new Session(264 RESERVED,265 status.getUri(),266 slot.getStereotype(),267 slot.getStereotype(),268 now)));269 amend(UP, status, reserved);270 }271 public void setSession(SlotId slotId, Session session) {272 Require.nonNull("Slot ID", slotId);273 AvailabilityAndNode node = findNode(slotId.getOwningNodeId());274 if (node == null) {275 LOG.warning("Grid model and reality have diverged. Unable to find node " + slotId.getOwningNodeId());276 return;277 }278 Optional<Slot> maybeSlot = node.status.getSlots().stream()279 .filter(slot -> slotId.equals(slot.getId()))280 .findFirst();281 if (!maybeSlot.isPresent()) {282 LOG.warning("Grid model and reality have diverged. Unable to find slot " + slotId);283 return;284 }285 Slot slot = maybeSlot.get();286 Optional<Session> maybeSession = slot.getSession();287 if (!maybeSession.isPresent()) {288 LOG.warning("Grid model and reality have diverged. Slot is not reserved. " + slotId);289 return;290 }291 Session current = maybeSession.get();292 if (!RESERVED.equals(current.getId())) {293 LOG.warning("Gid model and reality have diverged. Slot has session and is not reserved. " + slotId);294 return;295 }296 Slot updated = new Slot(297 slot.getId(),298 slot.getStereotype(),299 session == null ? slot.getLastStarted() : session.getStartTime(),300 Optional.ofNullable(session));301 amend(node.availability, node.status, updated);302 }303 private void amend(Availability availability, NodeStatus status, Slot slot) {304 Set<Slot> newSlots = new HashSet<>(status.getSlots());305 newSlots.removeIf(s -> s.getId().equals(slot.getId()));306 newSlots.add(slot);307 nodes(availability).remove(status);308 nodes(availability).add(new NodeStatus(309 status.getId(),310 status.getUri(),311 status.getMaxSessionCount(),312 newSlots,313 status.getAvailability(),314 status.getRegistrationSecret() == null ? null : new Secret(status.getRegistrationSecret())));315 }316 private static class AvailabilityAndNode {317 public final Availability availability;318 public final NodeStatus status;319 public AvailabilityAndNode(Availability availability, NodeStatus status) {...

Full Screen

Full Screen

Source:OneShotNode.java Github

copy

Full Screen

...116 Optional<String> driverName = config.get("k8s", "driver_name").map(String::toLowerCase);117 // Find the webdriver info corresponding to the driver name118 WebDriverInfo driverInfo = StreamSupport.stream(ServiceLoader.load(WebDriverInfo.class).spliterator(), false)119 .filter(info -> info.isSupporting(stereotype))120 .filter(info -> driverName.map(name -> name.equals(info.getDisplayName().toLowerCase())).orElse(true))121 .findFirst()122 .orElseThrow(() -> new ConfigException(123 "Unable to find matching driver for %s and %s", stereotype, driverName.orElse("any driver")));124 LOG.info(String.format("Creating one-shot node for %s with stereotype %s", driverInfo, stereotype));125 LOG.info("Grid URI is: " + nodeOptions.getPublicGridUri());126 return new OneShotNode(127 loggingOptions.getTracer(),128 eventOptions.getEventBus(),129 serverOptions.getRegistrationSecret(),130 new NodeId(UUID.randomUUID()),131 serverOptions.getExternalUri(),132 nodeOptions.getPublicGridUri().orElseThrow(() -> new ConfigException("Unable to determine public grid address")),133 stereotype,134 driverInfo);135 }136 @Override137 public Optional<CreateSessionResponse> newSession(CreateSessionRequest sessionRequest) {138 if (driver != null) {139 throw new IllegalStateException("Only expected one session at a time");140 }141 Optional<WebDriver> driver = driverInfo.createDriver(sessionRequest.getCapabilities());142 if (!driver.isPresent()) {143 return Optional.empty();144 }145 if (!(driver.get() instanceof RemoteWebDriver)) {146 driver.get().quit();147 return Optional.empty();148 }149 this.driver = (RemoteWebDriver) driver.get();150 this.sessionId = this.driver.getSessionId();151 this.client = extractHttpClient(this.driver);152 this.capabilities = rewriteCapabilities(this.driver);153 this.sessionStart = Instant.now();154 LOG.info("Encoded response: " + JSON.toJson(ImmutableMap.of(155 "value", ImmutableMap.of(156 "sessionId", sessionId,157 "capabilities", capabilities))));158 events.fire(new NodeDrainStarted(getId()));159 return Optional.of(160 new CreateSessionResponse(161 getSession(sessionId),162 JSON.toJson(ImmutableMap.of(163 "value", ImmutableMap.of(164 "sessionId", sessionId,165 "capabilities", capabilities))).getBytes(UTF_8)));166 }167 private HttpClient extractHttpClient(RemoteWebDriver driver) {168 CommandExecutor executor = driver.getCommandExecutor();169 try {170 Field client = null;171 Class<?> current = executor.getClass();172 while (client == null && (current != null || Object.class.equals(current))) {173 client = findClientField(current);174 current = current.getSuperclass();175 }176 if (client == null) {177 throw new IllegalStateException("Unable to find client field in " + executor.getClass());178 }179 if (!HttpClient.class.isAssignableFrom(client.getType())) {180 throw new IllegalStateException("Client field is not assignable to http client");181 }182 client.setAccessible(true);183 return (HttpClient) client.get(executor);184 } catch (ReflectiveOperationException e) {185 throw new IllegalStateException(e);186 }187 }188 private Field findClientField(Class<?> clazz) {189 try {190 return clazz.getDeclaredField("client");191 } catch (NoSuchFieldException e) {192 return null;193 }194 }195 private Capabilities rewriteCapabilities(RemoteWebDriver driver) {196 // Rewrite the se:options if necessary197 Object rawSeleniumOptions = driver.getCapabilities().getCapability("se:options");198 if (rawSeleniumOptions == null || rawSeleniumOptions instanceof Map) {199 @SuppressWarnings("unchecked") Map<String, Object> original = (Map<String, Object>) rawSeleniumOptions;200 Map<String, Object> updated = new TreeMap<>(original == null ? new HashMap<>() : original);201 String cdpPath = String.format("/session/%s/se/cdp", driver.getSessionId());202 updated.put("cdp", rewrite(cdpPath));203 return new PersistentCapabilities(driver.getCapabilities()).setCapability("se:options", updated);204 }205 return ImmutableCapabilities.copyOf(driver.getCapabilities());206 }207 private URI rewrite(String path) {208 try {209 return new URI(210 gridUri.getScheme(),211 gridUri.getUserInfo(),212 gridUri.getHost(),213 gridUri.getPort(),214 path,215 null,216 null);217 } catch (URISyntaxException e) {218 throw new RuntimeException(e);219 }220 }221 @Override222 public HttpResponse executeWebDriverCommand(HttpRequest req) {223 LOG.info("Executing " + req);224 HttpResponse res = client.execute(req);225 if (DELETE.equals(req.getMethod()) && req.getUri().equals("/session/" + sessionId)) {226 // Ensure the response is sent before we viciously kill the node227 new Thread(228 () -> {229 try {230 Thread.sleep(500);231 } catch (InterruptedException e) {232 Thread.currentThread().interrupt();233 throw new RuntimeException(e);234 }235 LOG.info("Stopping session: " + sessionId);236 stop(sessionId);237 },238 "Node clean up: " + getId())239 .start();240 }241 return res;242 }243 @Override244 public Session getSession(SessionId id) throws NoSuchSessionException {245 if (!isSessionOwner(id)) {246 throw new NoSuchSessionException("Unable to find session with id: " + id);247 }248 return new Session(249 sessionId,250 getUri(),251 stereotype,252 capabilities,253 sessionStart); }254 @Override255 public HttpResponse uploadFile(HttpRequest req, SessionId id) {256 return null;257 }258 @Override259 public void stop(SessionId id) throws NoSuchSessionException {260 LOG.info("Stop has been called: " + id);261 Require.nonNull("Session ID", id);262 if (!isSessionOwner(id)) {263 throw new NoSuchSessionException("Unable to find session " + id);264 }265 LOG.info("Quitting session " + id);266 try {267 driver.quit();268 } catch (Exception e) {269 // It's possible that the driver has already quit.270 }271 events.fire(new SessionClosedEvent(id));272 LOG.info("Firing node drain complete message");273 events.fire(new NodeDrainComplete(getId()));274 }275 @Override276 public boolean isSessionOwner(SessionId id) {277 return driver != null && sessionId.equals(id);278 }279 @Override280 public boolean isSupporting(Capabilities capabilities) {281 return driverInfo.isSupporting(capabilities);282 }283 @Override284 public NodeStatus getStatus() {285 return new NodeStatus(286 getId(),287 getUri(),288 1,289 ImmutableSet.of(290 new Slot(291 new SlotId(getId(), slotId),...

Full Screen

Full Screen

Source:AddingNodesTest.java Github

copy

Full Screen

...230 throw new UnsupportedOperationException("uploadFile");231 }232 @Override233 public Session getSession(SessionId id) throws NoSuchSessionException {234 if (running == null || !running.getId().equals(id)) {235 throw new NoSuchSessionException();236 }237 return running;238 }239 @Override240 public void stop(SessionId id) throws NoSuchSessionException {241 getSession(id);242 running = null;243 bus.fire(new SessionClosedEvent(id));244 }245 @Override246 public boolean isSessionOwner(SessionId id) {247 return running != null && running.getId().equals(id);248 }249 @Override250 public boolean isSupporting(Capabilities capabilities) {251 return Objects.equals("cake", capabilities.getCapability("cheese"));252 }253 @Override254 public NodeStatus getStatus() {255 Session sess = null;256 if (running != null) {257 try {258 sess = new Session(running.getId(), new URI("http://localhost:14568"), CAPS, running.getCapabilities(), Instant.now());259 } catch (URISyntaxException e) {260 throw new RuntimeException(e);261 }262 }263 return new NodeStatus(264 getId(),265 getUri(),...

Full Screen

Full Screen

Source:LocalDistributor.java Github

copy

Full Screen

...116 }117 private void register(Secret registrationSecret, NodeStatus status) {118 Require.nonNull("Node", status);119 Secret nodeSecret = status.getRegistrationSecret() == null ? null : new Secret(status.getRegistrationSecret());120 if (!Objects.equals(registrationSecret, nodeSecret)) {121 LOG.severe(String.format("Node at %s failed to send correct registration secret. Node NOT registered.", status.getUri()));122 bus.fire(new NodeRejectedEvent(status.getUri()));123 return;124 }125 Lock writeLock = lock.writeLock();126 writeLock.lock();127 try {128 if (nodes.containsKey(status.getId())) {129 return;130 }131 Set<Capabilities> capabilities = status.getSlots().stream()132 .map(Slot::getStereotype)133 .map(ImmutableCapabilities::copyOf)134 .collect(toImmutableSet());135 // A new node! Add this as a remote node, since we've not called add136 RemoteNode remoteNode = new RemoteNode(137 tracer,138 clientFactory,139 status.getId(),140 status.getUri(),141 registrationSecret,142 capabilities);143 add(remoteNode);144 } finally {145 writeLock.unlock();146 }147 }148 @Override149 public LocalDistributor add(Node node) {150 Require.nonNull("Node", node);151 LOG.info(String.format("Added node %s at %s.", node.getId(), node.getUri()));152 nodes.put(node.getId(), node);153 model.add(node.getStatus());154 // Extract the health check155 Runnable runnableHealthCheck = asRunnableHealthCheck(node);156 allChecks.put(node.getId(), runnableHealthCheck);157 hostChecker.submit(runnableHealthCheck, Duration.ofMinutes(5), Duration.ofSeconds(30));158 bus.fire(new NodeAddedEvent(node.getId()));159 return this;160 }161 private Runnable asRunnableHealthCheck(Node node) {162 HealthCheck healthCheck = node.getHealthCheck();163 NodeId id = node.getId();164 return () -> {165 HealthCheck.Result result;166 try {167 result = healthCheck.check();168 } catch (Exception e) {169 LOG.log(Level.WARNING, "Unable to process node " + id, e);170 result = new HealthCheck.Result(DOWN, "Unable to run healthcheck. Assuming down");171 }172 Lock writeLock = lock.writeLock();173 writeLock.lock();174 try {175 model.setAvailability(id, result.getAvailability());176 } finally {177 writeLock.unlock();178 }179 };180 }181 @Override182 public boolean drain(NodeId nodeId) {183 Node node = nodes.get(nodeId);184 if (node == null) {185 LOG.info("Asked to drain unregistered node " + nodeId);186 return false;187 }188 Lock writeLock = lock.writeLock();189 writeLock.lock();190 try {191 node.drain();192 model.setAvailability(nodeId, DRAINING);193 } finally {194 writeLock.unlock();195 }196 return node.isDraining();197 }198 public void remove(NodeId nodeId) {199 Lock writeLock = lock.writeLock();200 writeLock.lock();201 try {202 model.remove(nodeId);203 Runnable runnable = allChecks.remove(nodeId);204 if (runnable != null) {205 hostChecker.remove(runnable);206 }207 } finally {208 writeLock.unlock();209 bus.fire(new NodeRemovedEvent(nodeId));210 }211 }212 @Override213 public DistributorStatus getStatus() {214 Lock readLock = this.lock.readLock();215 readLock.lock();216 try {217 return new DistributorStatus(model.getSnapshot());218 } finally {219 readLock.unlock();220 }221 }222 @Beta223 public void refresh() {224 List<Runnable> allHealthChecks = new ArrayList<>();225 Lock readLock = this.lock.readLock();226 readLock.lock();227 try {228 allHealthChecks.addAll(allChecks.values());229 } finally {230 readLock.unlock();231 }232 allHealthChecks.parallelStream().forEach(Runnable::run);233 }234 @Override235 protected Set<NodeStatus> getAvailableNodes() {236 Lock readLock = this.lock.readLock();237 readLock.lock();238 try {239 return model.getSnapshot().stream()240 .filter(node -> !DOWN.equals(node.getAvailability()))241 .collect(toImmutableSet());242 } finally {243 readLock.unlock();244 }245 }246 @Override247 protected Supplier<CreateSessionResponse> reserve(SlotId slotId, CreateSessionRequest request) {248 Require.nonNull("Slot ID", slotId);249 Require.nonNull("New Session request", request);250 Lock writeLock = this.lock.writeLock();251 writeLock.lock();252 try {253 Node node = nodes.get(slotId.getOwningNodeId());254 if (node == null) {...

Full Screen

Full Screen

Source:DefaultSlotSelectorTest.java Github

copy

Full Screen

...109 NodeStatus heavy = createNode(Collections.singletonList(caps), 10, 6);110 NodeStatus massive = createNode(Collections.singletonList(caps), 10, 8);111 Set<SlotId> ids = selector.selectSlot(caps, ImmutableSet.of(heavy, medium, lightest, massive));112 SlotId expected = ids.iterator().next();113 assertThat(lightest.getSlots().stream()).anyMatch(slot -> expected.equals(slot.getId()));114 }115 @Test116 public void nodesAreOrderedByNumberOfSupportedBrowsersAndLoad() {117 Capabilities chrome = new ImmutableCapabilities("browserName", "chrome");118 Capabilities firefox = new ImmutableCapabilities("browserName", "firefox");119 Capabilities safari = new ImmutableCapabilities("browserName", "safari");120 NodeStatus lightLoadAndThreeBrowsers =121 createNode(ImmutableList.of(chrome, firefox, safari), 12, 2);122 NodeStatus mediumLoadAndTwoBrowsers =123 createNode(ImmutableList.of(chrome, firefox), 12, 5);124 NodeStatus mediumLoadAndOtherTwoBrowsers =125 createNode(ImmutableList.of(safari, chrome), 12, 6);126 NodeStatus highLoadAndOneBrowser =127 createNode(ImmutableList.of(chrome), 12, 8);128 Set<SlotId> ids = selector.selectSlot(129 chrome,130 ImmutableSet.of(131 lightLoadAndThreeBrowsers,132 mediumLoadAndTwoBrowsers,133 mediumLoadAndOtherTwoBrowsers,134 highLoadAndOneBrowser));135 // The slot should belong to the Node with high load because it only supports Chrome, leaving136 // the other Nodes with more availability for other browsers137 SlotId expected = ids.iterator().next();138 assertThat(highLoadAndOneBrowser.getSlots().stream())139 .anyMatch(slot -> expected.equals(slot.getId()));140 // Nodes are ordered by the diversity of supported browsers, then by load141 ImmutableSet<NodeId> nodeIds = ids.stream()142 .map(SlotId::getOwningNodeId)143 .distinct()144 .collect(toImmutableSet());145 assertThat(nodeIds)146 .containsSequence(147 highLoadAndOneBrowser.getId(),148 mediumLoadAndTwoBrowsers.getId(),149 mediumLoadAndOtherTwoBrowsers.getId(),150 lightLoadAndThreeBrowsers.getId());151 }152 private NodeStatus createNode(List<Capabilities> stereotypes, int count, int currentLoad) {153 NodeId nodeId = new NodeId(UUID.randomUUID());...

Full Screen

Full Screen

Source:Slot.java Github

copy

Full Screen

...60 }61 public boolean isSupporting(Capabilities caps) {62 // Simple implementation --- only checks current values63 return registeredCapabilities.getCapabilityNames().stream()64 .map(name -> Objects.equals(65 registeredCapabilities.getCapability(name),66 caps.getCapability(name)))67 .reduce(Boolean::logicalAnd)68 .orElse(false);69 }70 public Supplier<CreateSessionResponse> onReserve(CreateSessionRequest sessionRequest) {71 if (getStatus() != AVAILABLE) {72 throw new IllegalStateException("Node is not available");73 }74 currentStatus = RESERVED;75 return () -> {76 try {77 CreateSessionResponse sessionResponse = node.newSession(sessionRequest)78 .orElseThrow(79 () -> new SessionNotCreatedException(80 "Unable to create session for " + sessionRequest));81 onStart(sessionResponse.getSession());82 return sessionResponse;83 } catch (Throwable t) {84 currentStatus = AVAILABLE;85 currentSession = null;86 throw t;87 }88 };89 }90 public void onStart(Session session) {91 if (getStatus() != RESERVED) {92 throw new IllegalStateException("Slot is not reserved");93 }94 this.lastStartedNanos = System.nanoTime();95 this.currentStatus = ACTIVE;96 this.currentSession = Require.nonNull("Session", session);97 }98 public void onEnd(SessionId id) {99 if (currentSession == null || !currentSession.getId().equals(id)) {100 return;101 }102 this.currentStatus = AVAILABLE;103 this.currentSession = null;104 }105 public enum Status {106 AVAILABLE,107 RESERVED,108 ACTIVE,109 }110}...

Full Screen

Full Screen

equals

Using AI Code Generation

copy

Full Screen

1public class SlotId {2 private final String id;3 public SlotId(String id) {4 this.id = id;5 }6 public String getId() {7 return id;8 }9 public boolean equals(Object o) {10 if (this == o) {11 return true;12 }13 if (o == null || getClass() != o.getClass()) {14 return false;15 }16 SlotId slotId = (SlotId) o;17 return id.equals(slotId.id);18 }19 public int hashCode() {20 return Objects.hash(id);21 }22}23[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ selenium-grid --- 24[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project selenium-grid: Compilation failure: Compilation failure:

Full Screen

Full Screen

equals

Using AI Code Generation

copy

Full Screen

1SlotId slotId = new SlotId(UUID.randomUUID());2SlotId slotId2 = new SlotId(UUID.randomUUID());3System.out.println(slotId.equals(slotId2));4System.out.println(slotId.equals(slotId));5System.out.println(slotId.equals(null));6System.out.println(slotId.equals("foo"));7SessionId sessionId = new SessionId(UUID.randomUUID());8SessionId sessionId2 = new SessionId(UUID.randomUUID());9System.out.println(sessionId.equals(sessionId2));10System.out.println(sessionId.equals(sessionId));11System.out.println(sessionId.equals(null));12System.out.println(sessionId.equals("foo"));13NodeId nodeId = new NodeId(UUID.randomUUID());14NodeId nodeId2 = new NodeId(UUID.randomUUID());15System.out.println(nodeId.equals(nodeId2));16System.out.println(nodeId.equals(nodeId));17System.out.println(nodeId.equals(null));18System.out.println(nodeId.equals("foo"));19NodeStatus nodeStatus = new NodeStatus(20 new NodeId(UUID.randomUUID()),21 new NodeStatus.Available(),22 1);23NodeStatus nodeStatus2 = new NodeStatus(24 new NodeId(UUID.randomUUID()),25 new NodeStatus.Available(),26 1);27System.out.println(nodeStatus.equals(nodeStatus2));28System.out.println(nodeStatus.equals(nodeStatus));29System.out.println(nodeStatus.equals(null));30System.out.println(nodeStatus.equals("foo"));31Availability availability = new Availability(1, 1);32Availability availability2 = new Availability(1, 1);33System.out.println(availability.equals(availability2));34System.out.println(availability.equals(availability));35System.out.println(availability.equals(null));36System.out.println(availability.equals("foo"));

Full Screen

Full Screen

equals

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.grid.data.SlotId;2SlotId slot1 = new SlotId(UUID.randomUUID(), UUID.randomUUID());3SlotId slot2 = new SlotId(UUID.randomUUID(), UUID.randomUUID());4System.out.println(slot1.equals(slot2));5 implements java.io.Serializable, Comparable<String>, CharSequence {6 public boolean equals(Object anObject) {7 if (this == anObject) {8 return true;9 }10 if (anObject instanceof String) {11 String anotherString = (String)anObject;12 int n = value.length;13 if (n == anotherString.value.length) {14 char v1[] = value;15 char v2[] = anotherString.value;16 int i = 0;17 while (n-- != 0) {18 if (v1[i] != v2[i])19 return false;20 i++;21 }22 return true;23 }24 }25 return false;26 }27}28import java.util.Scanner;29public class StringDemo {30 public static void main(String[] args) {31 Scanner sc = new Scanner(System.in);32 System.out.print("Enter first string: ");33 String str1 = sc.nextLine();34 System.out.print("Enter second string: ");35 String str2 = sc.nextLine();36 System.out.println(str1.equals(str2));37 }38}39public final class Integer extends Number implements Comparable<Integer> {40 public boolean equals(Object obj) {41 if (obj instanceof Integer) {42 return value == ((Integer)obj).intValue();43 }44 return false;45 }46}47import java.util.Scanner;48public class IntegerDemo {49 public static void main(String[] args) {50 Scanner sc = new Scanner(System.in);51 System.out.print("Enter first integer: ");52 int num1 = sc.nextInt();53 System.out.print("Enter second integer: ");54 int num2 = sc.nextInt();55 System.out.println(new Integer(num1).equals(new Integer(num2)));56 }57}

Full Screen

Full Screen

equals

Using AI Code Generation

copy

Full Screen

1SlotId slotId = new SlotId("foo");2SlotId slotId1 = new SlotId("foo");3System.out.println(slotId.equals(slotId1));4SlotId slotId = new SlotId("foo");5SlotId slotId1 = new SlotId("bar");6System.out.println(slotId.equals(slotId1));7SlotId slotId = new SlotId("foo");8SlotId slotId1 = new SlotId("foo");9System.out.println(slotId.equals(slotId1));10SlotId slotId = new SlotId("foo");11SlotId slotId1 = new SlotId("bar");12System.out.println(slotId.equals(slotId1));13SlotId slotId = new SlotId("foo");14SlotId slotId1 = new SlotId("foo");15System.out.println(slotId.equals(slotId1));16SlotId slotId = new SlotId("foo");17SlotId slotId1 = new SlotId("bar");18System.out.println(slotId.equals(slotId1));19SlotId slotId = new SlotId("foo");20SlotId slotId1 = new SlotId("foo");21System.out.println(slotId.equals(slotId1));22SlotId slotId = new SlotId("foo");23SlotId slotId1 = new SlotId("bar");24System.out.println(slotId.equals(slotId1));25SlotId slotId = new SlotId("foo");26SlotId slotId1 = new SlotId("foo");27System.out.println(slotId.equals(slotId1));

Full Screen

Full Screen

equals

Using AI Code Generation

copy

Full Screen

1 public void testSlotIdEquals() {2 SlotId slotId1 = new SlotId(UUID.fromString("5c6f1d6c-9b8a-4f1a-8f3d-3e6b5c7e0a25"));3 SlotId slotId2 = new SlotId(UUID.fromString("5c6f1d6c-9b8a-4f1a-8f3d-3e6b5c7e0a25"));4 }5}6package org.openqa.selenium.grid.data;7import java.util.Objects;8import java.util.UUID;9public class SlotId {10 private final UUID id;11 public SlotId(UUID id) {12 this.id = Objects.requireNonNull(id);13 }14 public UUID getId() {15 return id;16 }17 public boolean equals(Object o) {18 if (this == o) return true;19 if (o == null || getClass() != o.getClass()) return false;20 SlotId slotId = (SlotId) o;21 return id.equals(slotId.id);22 }23 public int hashCode() {24 return Objects.hash(id);25 }26}

Full Screen

Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Run Selenium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in SlotId

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful