|
29 | 29 | import org.springframework.context.ApplicationContext;
|
30 | 30 |
|
31 | 31 | import java.net.InetSocketAddress;
|
32 |
| -import java.util.Arrays; |
33 | 32 | import java.util.Collections;
|
34 | 33 | import java.util.List;
|
35 | 34 | import java.util.concurrent.CompletableFuture;
|
|
40 | 39 | import java.util.function.Consumer;
|
41 | 40 |
|
42 | 41 | import static com.faforever.client.fa.RatingMode.GLOBAL;
|
| 42 | +import static com.faforever.client.fa.RatingMode.RANKED_1V1; |
| 43 | +import static com.faforever.client.game.Faction.AEON; |
| 44 | +import static com.faforever.client.game.Faction.CYBRAN; |
43 | 45 | import static com.faforever.client.remote.domain.GameState.CLOSED;
|
44 | 46 | import static com.faforever.client.remote.domain.GameState.PLAYING;
|
| 47 | +import static java.util.Arrays.asList; |
45 | 48 | import static java.util.concurrent.CompletableFuture.completedFuture;
|
46 | 49 | import static org.hamcrest.CoreMatchers.is;
|
47 | 50 | import static org.hamcrest.CoreMatchers.notNullValue;
|
|
59 | 62 | import static org.mockito.Mockito.doAnswer;
|
60 | 63 | import static org.mockito.Mockito.mock;
|
61 | 64 | import static org.mockito.Mockito.never;
|
| 65 | +import static org.mockito.Mockito.timeout; |
62 | 66 | import static org.mockito.Mockito.verify;
|
63 | 67 | import static org.mockito.Mockito.when;
|
64 | 68 |
|
@@ -235,12 +239,12 @@ public void testAddOnGameStartedListener() throws Exception {
|
235 | 239 |
|
236 | 240 | NewGameInfo newGameInfo = NewGameInfoBuilder.create().defaultValues().get();
|
237 | 241 | GameLaunchMessage gameLaunchMessage = GameLaunchMessageBuilder.create().defaultValues().get();
|
238 |
| - gameLaunchMessage.setArgs(Arrays.asList("/foo bar", "/bar foo")); |
| 242 | + gameLaunchMessage.setArgs(asList("/foo bar", "/bar foo")); |
239 | 243 | InetSocketAddress externalSocketAddress = new InetSocketAddress(123);
|
240 | 244 |
|
241 | 245 | when(localRelayServer.getPort()).thenReturn(gpgPort);
|
242 | 246 | when(forgedAllianceService.startGame(
|
243 |
| - gameLaunchMessage.getUid(), gameLaunchMessage.getMod(), null, Arrays.asList("/foo", "bar", "/bar", "foo"), GLOBAL, gpgPort) |
| 247 | + gameLaunchMessage.getUid(), gameLaunchMessage.getMod(), null, asList("/foo", "bar", "/bar", "foo"), GLOBAL, gpgPort) |
244 | 248 | ).thenReturn(process);
|
245 | 249 | when(connectivityService.getExternalSocketAddress()).thenReturn(externalSocketAddress);
|
246 | 250 | when(gameUpdateService.updateInBackground(any(), any(), any(), any())).thenReturn(completedFuture(null));
|
@@ -270,7 +274,7 @@ public void testAddOnGameStartedListener() throws Exception {
|
270 | 274 |
|
271 | 275 | gameTerminatedLatch.await(TIMEOUT, TIME_UNIT);
|
272 | 276 | verify(forgedAllianceService).startGame(
|
273 |
| - gameLaunchMessage.getUid(), gameLaunchMessage.getMod(), null, Arrays.asList("/foo", "bar", "/bar", "foo"), GLOBAL, |
| 277 | + gameLaunchMessage.getUid(), gameLaunchMessage.getMod(), null, asList("/foo", "bar", "/bar", "foo"), GLOBAL, |
274 | 278 | gpgPort);
|
275 | 279 | verify(replayService).startReplayServer(gameLaunchMessage.getUid());
|
276 | 280 | }
|
@@ -301,7 +305,7 @@ public void testOnGames() throws Exception {
|
301 | 305 | assertThat(instance.getGameInfoBeans(), empty());
|
302 | 306 |
|
303 | 307 | GameInfoMessage multiGameInfoMessage = new GameInfoMessage();
|
304 |
| - multiGameInfoMessage.setGames(Arrays.asList( |
| 308 | + multiGameInfoMessage.setGames(asList( |
305 | 309 | GameInfoMessageBuilder.create(1).defaultValues().get(),
|
306 | 310 | GameInfoMessageBuilder.create(2).defaultValues().get()
|
307 | 311 | ));
|
@@ -388,20 +392,22 @@ public void testOnGameInfoRemove() {
|
388 | 392 | @Test
|
389 | 393 | public void testStartSearchRanked1v1() throws Exception {
|
390 | 394 | GameLaunchMessage gameLaunchMessage = new GameLaunchMessage();
|
| 395 | + gameLaunchMessage.setMod("ladder1v1"); |
391 | 396 | gameLaunchMessage.setUid(123);
|
392 | 397 | gameLaunchMessage.setArgs(Collections.emptyList());
|
393 |
| - when(fafService.startSearchRanked1v1(Faction.CYBRAN, GAME_PORT)).thenReturn(CompletableFuture.completedFuture(gameLaunchMessage)); |
| 398 | + when(fafService.startSearchRanked1v1(CYBRAN, GAME_PORT)).thenReturn(CompletableFuture.completedFuture(gameLaunchMessage)); |
394 | 399 | when(gameUpdateService.updateInBackground(GameType.LADDER_1V1.getString(), null, Collections.emptyMap(), Collections.emptySet())).thenReturn(CompletableFuture.completedFuture(null));
|
395 | 400 | when(applicationContext.getBean(SearchExpansionTask.class)).thenReturn(searchExpansionTask);
|
396 | 401 | when(scheduledExecutorService.scheduleWithFixedDelay(any(), anyLong(), anyLong(), any())).thenReturn(mock(ScheduledFuture.class));
|
397 | 402 | when(localRelayServer.getPort()).thenReturn(111);
|
398 | 403 |
|
399 |
| - CompletableFuture<Void> future = instance.startSearchRanked1v1(Faction.CYBRAN).toCompletableFuture(); |
| 404 | + CompletableFuture<Void> future = instance.startSearchRanked1v1(CYBRAN).toCompletableFuture(); |
400 | 405 |
|
401 | 406 | verify(searchExpansionTask).setMaxRadius(SEARCH_MAX_RADIUS);
|
402 | 407 | verify(searchExpansionTask).setRadiusIncrement(SEARCH_RADIUS_INCREMENT);
|
403 | 408 | verify(scheduledExecutorService).scheduleWithFixedDelay(searchExpansionTask, SEARCH_EXPANSION_DELAY, SEARCH_EXPANSION_DELAY, TimeUnit.MILLISECONDS);
|
404 |
| - verify(fafService).startSearchRanked1v1(Faction.CYBRAN, GAME_PORT); |
| 409 | + verify(fafService).startSearchRanked1v1(CYBRAN, GAME_PORT); |
| 410 | + verify(forgedAllianceService, timeout(5)).startGame(eq(123), eq("ladder1v1"), eq(CYBRAN), eq(asList("/team", "1", "/players", "2")), eq(RANKED_1V1), anyInt()); |
405 | 411 | assertThat(future.get(TIMEOUT, TIME_UNIT), is(nullValue()));
|
406 | 412 | }
|
407 | 413 |
|
@@ -432,7 +438,7 @@ public void testStartSearchRanked1v1GameRunningDoesNothing() throws Exception {
|
432 | 438 | instance.hostGame(newGameInfo);
|
433 | 439 | gameRunningLatch.await(TIMEOUT, TIME_UNIT);
|
434 | 440 |
|
435 |
| - instance.startSearchRanked1v1(Faction.AEON); |
| 441 | + instance.startSearchRanked1v1(AEON); |
436 | 442 |
|
437 | 443 | assertThat(instance.searching1v1Property().get(), is(false));
|
438 | 444 | }
|
|
0 commit comments