17
17
18
18
package org .openqa .selenium .grid .graphql ;
19
19
20
+ import com .google .common .collect .ImmutableMap ;
20
21
import org .junit .Before ;
21
22
import org .junit .Test ;
22
23
import org .openqa .selenium .Capabilities ;
23
24
import org .openqa .selenium .ImmutableCapabilities ;
24
25
import org .openqa .selenium .SessionNotCreatedException ;
25
26
import org .openqa .selenium .events .EventBus ;
26
27
import org .openqa .selenium .events .local .GuavaEventBus ;
27
- import org .openqa .selenium .grid .data .*;
28
+ import org .openqa .selenium .grid .data .CreateSessionRequest ;
29
+ import org .openqa .selenium .grid .data .CreateSessionResponse ;
30
+ import org .openqa .selenium .grid .data .RequestId ;
28
31
import org .openqa .selenium .grid .data .Session ;
29
32
import org .openqa .selenium .grid .data .Slot ;
30
33
import org .openqa .selenium .grid .distributor .Distributor ;
57
60
import java .io .UncheckedIOException ;
58
61
import java .net .URI ;
59
62
import java .net .URISyntaxException ;
60
- import java .time .Instant ;
61
63
import java .time .Duration ;
64
+ import java .time .Instant ;
62
65
import java .util .Collections ;
63
66
import java .util .Map ;
64
67
import java .util .Optional ;
77
80
import static org .openqa .selenium .remote .http .HttpMethod .GET ;
78
81
import static org .openqa .selenium .remote .http .HttpMethod .POST ;
79
82
80
- import com .google .common .collect .ImmutableMap ;
81
-
82
83
public class GraphqlHandlerTest {
83
84
85
+ private static final Json JSON = new Json ();
84
86
private final Secret registrationSecret = new Secret ("stilton" );
85
87
private final URI publicUri = new URI ("http://example.com/grid-o-matic" );
86
88
private final String version = "4.0.0" ;
87
89
private final Wait <Object > wait = new FluentWait <>(new Object ()).withTimeout (Duration .ofSeconds (5 ));
88
- private static final Json JSON = new Json ();
89
90
private Distributor distributor ;
90
91
private NewSessionQueuer queuer ;
91
92
private Tracer tracer ;
@@ -188,12 +189,12 @@ public void shouldBeAbleToGetSessionQueueRequests() {
188
189
GraphqlHandler handler = new GraphqlHandler (tracer , distributor , queuer , publicUri , version );
189
190
190
191
Map <String , Object > topLevel = executeQuery (handler ,
191
- "{ grid { sessionQueueRequests } }" );
192
+ "{ sessionsInfo { sessionQueueRequests } }" );
192
193
193
194
assertThat (topLevel ).isEqualTo (
194
195
singletonMap (
195
196
"data" , singletonMap (
196
- "grid " , singletonMap (
197
+ "sessionsInfo " , singletonMap (
197
198
"sessionQueueRequests" , singletonList (JSON .toJson (caps ))))));
198
199
}
199
200
@@ -202,25 +203,25 @@ public void shouldBeReturnAnEmptyListIfQueueIsEmpty() {
202
203
GraphqlHandler handler = new GraphqlHandler (tracer , distributor , queuer , publicUri , version );
203
204
204
205
Map <String , Object > topLevel = executeQuery (handler ,
205
- "{ grid { sessionQueueRequests } }" );
206
+ "{ sessionsInfo { sessionQueueRequests } }" );
206
207
207
208
assertThat (topLevel ).isEqualTo (
208
209
singletonMap (
209
210
"data" , singletonMap (
210
- "grid " , singletonMap (
211
+ "sessionsInfo " , singletonMap (
211
212
"sessionQueueRequests" , Collections .emptyList ()))));
212
213
}
213
214
214
215
@ Test
215
216
public void shouldReturnAnEmptyListForNodesIfNoneAreRegistered () {
216
217
GraphqlHandler handler = new GraphqlHandler (tracer , distributor , queuer , publicUri , version );
217
218
218
- Map <String , Object > topLevel = executeQuery (handler , "{ grid { nodes { uri } } }" );
219
+ Map <String , Object > topLevel = executeQuery (handler , "{ nodesInfo { nodes { uri } } }" );
219
220
220
221
assertThat (topLevel ).describedAs (topLevel .toString ()).isEqualTo (
221
222
singletonMap (
222
223
"data" , singletonMap (
223
- "grid " , singletonMap (
224
+ "nodesInfo " , singletonMap (
224
225
"nodes" , Collections .emptyList ()))));
225
226
}
226
227
@@ -245,12 +246,12 @@ public boolean test(Capabilities capabilities) {
245
246
wait .until (obj -> distributor .getStatus ().hasCapacity ());
246
247
247
248
GraphqlHandler handler = new GraphqlHandler (tracer , distributor , queuer , publicUri , version );
248
- Map <String , Object > topLevel = executeQuery (handler , "{ grid { nodes { uri } } }" );
249
+ Map <String , Object > topLevel = executeQuery (handler , "{ nodesInfo { nodes { uri } } }" );
249
250
250
251
assertThat (topLevel ).describedAs (topLevel .toString ()).isEqualTo (
251
252
singletonMap (
252
253
"data" , singletonMap (
253
- "grid " , singletonMap (
254
+ "nodesInfo " , singletonMap (
254
255
"nodes" , singletonList (singletonMap ("uri" , nodeUri ))))));
255
256
}
256
257
0 commit comments