Skip to content

Commit b4c7671

Browse files
committed
[java] Formatting Java files.
We really need to add this to the CI. [skip ci]
1 parent 9b42f09 commit b4c7671

File tree

3 files changed

+110
-95
lines changed

3 files changed

+110
-95
lines changed

java/src/org/openqa/selenium/Rectangle.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ public boolean equals(Object o) {
7575

7676
Rectangle rectangle = (Rectangle) o;
7777

78-
return x == rectangle.x && y == rectangle.y && height == rectangle.height
79-
&& width == rectangle.width;
78+
return x == rectangle.x
79+
&& y == rectangle.y
80+
&& height == rectangle.height
81+
&& width == rectangle.width;
8082
}
8183

8284
@Override

java/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,17 @@ private void timeoutSessions() {
164164
readLock.lock();
165165
Set<RequestId> ids;
166166
try {
167-
ids = requests.entrySet().stream()
168-
.filter(
167+
ids =
168+
requests.entrySet().stream()
169+
.filter(
169170
entry ->
170171
queue.stream()
171172
.anyMatch(
172173
sessionRequest ->
173174
sessionRequest.getRequestId().equals(entry.getKey())))
174-
.filter(entry -> isTimedOut(now, entry.getValue()))
175-
.map(Map.Entry::getKey)
176-
.collect(ImmutableSet.toImmutableSet());
175+
.filter(entry -> isTimedOut(now, entry.getValue()))
176+
.map(Map.Entry::getKey)
177+
.collect(ImmutableSet.toImmutableSet());
177178
} finally {
178179
readLock.unlock();
179180
}
@@ -323,9 +324,8 @@ private boolean isRequestInQueue(RequestId requestId) {
323324
readLock.lock();
324325

325326
try {
326-
Optional<SessionRequest> result = queue.stream()
327-
.filter(req -> req.getRequestId().equals(requestId))
328-
.findAny();
327+
Optional<SessionRequest> result =
328+
queue.stream().filter(req -> req.getRequestId().equals(requestId)).findAny();
329329
return result.isPresent();
330330
} finally {
331331
readLock.unlock();

java/test/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueueTest.java

Lines changed: 98 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private void waitUntilAddedToQueue(SessionRequest request) {
170170
@MethodSource("data")
171171
void shouldBeAbleToAddToQueueAndGetValidResponse(Supplier<TestData> supplier) {
172172
setup(supplier);
173-
173+
174174
AtomicBoolean isPresent = new AtomicBoolean(false);
175175

176176
new Thread(
@@ -207,112 +207,125 @@ void shouldBeAbleToAddToQueueAndGetValidResponse(Supplier<TestData> supplier) {
207207
assertThat(isPresent.get()).isTrue();
208208
assertEquals(HTTP_OK, httpResponse.getStatus());
209209
}
210-
211210

212211
@ParameterizedTest
213212
@MethodSource("data")
214-
void shouldBeAbleToAddToQueueWithTimeoutAndGetValidResponse(Supplier<TestData> supplier) {
213+
void shouldBeAbleToAddToQueueWithTimeoutAndGetValidResponse(Supplier<TestData> supplier) {
215214
setup(supplier);
216215

217-
SessionRequest sessionRequestWithTimeout = new SessionRequest(
218-
new RequestId(UUID.randomUUID()),
219-
Instant.now(),
220-
Set.of(W3C),
221-
Set.of(CAPS),
222-
Map.of(),
223-
Map.of());
216+
SessionRequest sessionRequestWithTimeout =
217+
new SessionRequest(
218+
new RequestId(UUID.randomUUID()),
219+
Instant.now(),
220+
Set.of(W3C),
221+
Set.of(CAPS),
222+
Map.of(),
223+
Map.of());
224224

225225
AtomicBoolean isPresent = new AtomicBoolean(false);
226226

227-
new Thread(() -> {
228-
waitUntilAddedToQueue(sessionRequestWithTimeout);
229-
isPresent.set(true);
230-
231-
Capabilities capabilities = new ImmutableCapabilities("browserName", "chrome");
232-
233-
try {
234-
Thread.sleep(4000); // simulate session waiting in queue
235-
} catch (InterruptedException e) {}
236-
237-
// remove request from queue
238-
Map<Capabilities, Long> stereotypes = new HashMap<>();
239-
stereotypes.put(new ImmutableCapabilities("browserName", "cheese"), 1L);
240-
List<SessionRequest> requests = queue.getNextAvailable(stereotypes);
241-
242-
SessionId sessionId = new SessionId("123");
243-
Session session =
244-
new Session(
245-
sessionId,
246-
URI.create("https://example.com"),
247-
CAPS,
248-
capabilities,
249-
Instant.now());
250-
CreateSessionResponse sessionResponse = new CreateSessionResponse(
251-
session,
252-
JSON.toJson(
253-
ImmutableMap.of(
254-
"value", ImmutableMap.of(
255-
"sessionId", sessionId,
256-
"capabilities", capabilities)))
257-
.getBytes(UTF_8));
258-
259-
try {
260-
Thread.sleep(2000); // simulate session creation delay
261-
} catch (InterruptedException e) {}
262-
queue.complete(sessionRequestWithTimeout.getRequestId(), Either.right(sessionResponse));
263-
}).start();
227+
new Thread(
228+
() -> {
229+
waitUntilAddedToQueue(sessionRequestWithTimeout);
230+
isPresent.set(true);
231+
232+
Capabilities capabilities = new ImmutableCapabilities("browserName", "chrome");
233+
234+
try {
235+
Thread.sleep(4000); // simulate session waiting in queue
236+
} catch (InterruptedException ignore) {
237+
}
238+
239+
// remove request from queue
240+
Map<Capabilities, Long> stereotypes = new HashMap<>();
241+
stereotypes.put(new ImmutableCapabilities("browserName", "cheese"), 1L);
242+
queue.getNextAvailable(stereotypes);
243+
244+
SessionId sessionId = new SessionId("123");
245+
Session session =
246+
new Session(
247+
sessionId,
248+
URI.create("https://example.com"),
249+
CAPS,
250+
capabilities,
251+
Instant.now());
252+
CreateSessionResponse sessionResponse =
253+
new CreateSessionResponse(
254+
session,
255+
JSON.toJson(
256+
ImmutableMap.of(
257+
"value",
258+
ImmutableMap.of(
259+
"sessionId", sessionId,
260+
"capabilities", capabilities)))
261+
.getBytes(UTF_8));
262+
263+
try {
264+
Thread.sleep(2000); // simulate session creation delay
265+
} catch (InterruptedException ignore) {
266+
}
267+
queue.complete(
268+
sessionRequestWithTimeout.getRequestId(), Either.right(sessionResponse));
269+
})
270+
.start();
264271

265272
HttpResponse httpResponse = queue.addToQueue(sessionRequestWithTimeout);
266273

267274
assertThat(isPresent.get()).isTrue();
268275
assertEquals(HTTP_OK, httpResponse.getStatus());
269276
}
270277

271-
272278
@ParameterizedTest
273279
@MethodSource("data")
274-
void shouldBeAbleToAddToQueueWithTimeoutAndTimeoutResponse(Supplier<TestData> supplier) {
280+
void shouldBeAbleToAddToQueueWithTimeoutAndTimeoutResponse(Supplier<TestData> supplier) {
275281
setup(supplier);
276282

277-
SessionRequest sessionRequestWithTimeout = new SessionRequest(
278-
new RequestId(UUID.randomUUID()),
279-
Instant.now(),
280-
Set.of(W3C),
281-
Set.of(CAPS),
282-
Map.of(),
283-
Map.of());
283+
SessionRequest sessionRequestWithTimeout =
284+
new SessionRequest(
285+
new RequestId(UUID.randomUUID()),
286+
Instant.now(),
287+
Set.of(W3C),
288+
Set.of(CAPS),
289+
Map.of(),
290+
Map.of());
284291

285292
AtomicBoolean isPresent = new AtomicBoolean(false);
286293

287-
new Thread(() -> {
288-
waitUntilAddedToQueue(sessionRequestWithTimeout);
289-
isPresent.set(true);
290-
291-
Capabilities capabilities = new ImmutableCapabilities("browserName", "chrome");
292-
293-
try {
294-
Thread.sleep(5500); // simulate session waiting in queue
295-
} catch (InterruptedException e) {}
296-
297-
SessionId sessionId = new SessionId("123");
298-
Session session =
299-
new Session(
300-
sessionId,
301-
URI.create("https://example.com"),
302-
CAPS,
303-
capabilities,
304-
Instant.now());
305-
CreateSessionResponse sessionResponse = new CreateSessionResponse(
306-
session,
307-
JSON.toJson(
308-
ImmutableMap.of(
309-
"value", ImmutableMap.of(
310-
"sessionId", sessionId,
311-
"capabilities", capabilities)))
312-
.getBytes(UTF_8));
313-
314-
queue.complete(sessionRequestWithTimeout.getRequestId(), Either.right(sessionResponse));
315-
}).start();
294+
new Thread(
295+
() -> {
296+
waitUntilAddedToQueue(sessionRequestWithTimeout);
297+
isPresent.set(true);
298+
299+
Capabilities capabilities = new ImmutableCapabilities("browserName", "chrome");
300+
301+
try {
302+
Thread.sleep(5500); // simulate session waiting in queue
303+
} catch (InterruptedException ignore) {
304+
}
305+
306+
SessionId sessionId = new SessionId("123");
307+
Session session =
308+
new Session(
309+
sessionId,
310+
URI.create("https://example.com"),
311+
CAPS,
312+
capabilities,
313+
Instant.now());
314+
CreateSessionResponse sessionResponse =
315+
new CreateSessionResponse(
316+
session,
317+
JSON.toJson(
318+
ImmutableMap.of(
319+
"value",
320+
ImmutableMap.of(
321+
"sessionId", sessionId,
322+
"capabilities", capabilities)))
323+
.getBytes(UTF_8));
324+
325+
queue.complete(
326+
sessionRequestWithTimeout.getRequestId(), Either.right(sessionResponse));
327+
})
328+
.start();
316329

317330
HttpResponse httpResponse = queue.addToQueue(sessionRequestWithTimeout);
318331

0 commit comments

Comments
 (0)