|
17 | 17 |
|
18 | 18 | package org.openqa.selenium.grid.graphql; |
19 | 19 |
|
20 | | -import static java.util.Collections.singletonList; |
21 | | -import static java.util.Collections.singletonMap; |
22 | | -import static java.util.concurrent.TimeUnit.SECONDS; |
23 | | -import static org.assertj.core.api.Assertions.assertThat; |
24 | | -import static org.assertj.core.api.Assertions.fail; |
25 | | -import static org.assertj.core.api.InstanceOfAssertFactories.LIST; |
26 | | -import static org.assertj.core.api.InstanceOfAssertFactories.MAP; |
27 | | -import static org.openqa.selenium.json.Json.MAP_TYPE; |
28 | | -import static org.openqa.selenium.remote.Dialect.OSS; |
29 | | -import static org.openqa.selenium.remote.Dialect.W3C; |
30 | | -import static org.openqa.selenium.remote.http.HttpMethod.GET; |
31 | | - |
32 | 20 | import com.google.common.collect.ImmutableMap; |
33 | 21 |
|
34 | 22 | import org.junit.Before; |
|
42 | 30 | import org.openqa.selenium.grid.data.CreateSessionRequest; |
43 | 31 | import org.openqa.selenium.grid.data.CreateSessionResponse; |
44 | 32 | import org.openqa.selenium.grid.data.DefaultSlotMatcher; |
45 | | -import org.openqa.selenium.grid.data.NewSessionRequestEvent; |
46 | 33 | import org.openqa.selenium.grid.data.RequestId; |
47 | 34 | import org.openqa.selenium.grid.data.Session; |
48 | 35 | import org.openqa.selenium.grid.data.SessionRequest; |
|
81 | 68 | import java.util.Map; |
82 | 69 | import java.util.Set; |
83 | 70 | import java.util.UUID; |
84 | | -import java.util.concurrent.CountDownLatch; |
| 71 | + |
| 72 | +import static java.util.Collections.singletonList; |
| 73 | +import static java.util.Collections.singletonMap; |
| 74 | +import static org.assertj.core.api.Assertions.assertThat; |
| 75 | +import static org.assertj.core.api.Assertions.fail; |
| 76 | +import static org.assertj.core.api.InstanceOfAssertFactories.LIST; |
| 77 | +import static org.assertj.core.api.InstanceOfAssertFactories.MAP; |
| 78 | +import static org.openqa.selenium.json.Json.MAP_TYPE; |
| 79 | +import static org.openqa.selenium.remote.Dialect.OSS; |
| 80 | +import static org.openqa.selenium.remote.Dialect.W3C; |
| 81 | +import static org.openqa.selenium.remote.http.HttpMethod.GET; |
85 | 82 |
|
86 | 83 | public class GraphqlHandlerTest { |
87 | 84 |
|
@@ -168,15 +165,13 @@ public void shouldBeAbleToGetGridVersion() { |
168 | 165 |
|
169 | 166 | private void continueOnceAddedToQueue(SessionRequest request) { |
170 | 167 | // Add to the queue in the background |
171 | | - CountDownLatch latch = new CountDownLatch(1); |
172 | | - events.addListener(NewSessionRequestEvent.listener(id -> latch.countDown())); |
173 | 168 | new Thread(() -> queue.addToQueue(request)).start(); |
174 | | - try { |
175 | | - assertThat(latch.await(5, SECONDS)).isTrue(); |
176 | | - } catch (InterruptedException e) { |
177 | | - Thread.currentThread().interrupt(); |
178 | | - throw new RuntimeException(e); |
179 | | - } |
| 169 | + new FluentWait<>(request) |
| 170 | + .withTimeout(Duration.ofSeconds(5)) |
| 171 | + .until( |
| 172 | + r -> queue.getQueueContents().stream() |
| 173 | + .anyMatch(sessionRequestCapability -> |
| 174 | + sessionRequestCapability.getRequestId().equals(r.getRequestId()))); |
180 | 175 | } |
181 | 176 |
|
182 | 177 | @Test |
|
0 commit comments