use of com.faforever.client.remote.domain.GameInfoMessage in project downlords-faf-client by FAForever.
the class GameServiceImplTest method testOnGames.
@Test
public void testOnGames() throws Exception {
assertThat(instance.getGames(), empty());
GameInfoMessage multiGameInfoMessage = new GameInfoMessage();
multiGameInfoMessage.setGames(asList(GameInfoMessageBuilder.create(1).defaultValues().get(), GameInfoMessageBuilder.create(2).defaultValues().get()));
gameInfoMessageListenerCaptor.getValue().accept(multiGameInfoMessage);
WaitForAsyncUtils.waitForFxEvents();
assertThat(instance.getGames(), hasSize(2));
}
use of com.faforever.client.remote.domain.GameInfoMessage in project downlords-faf-client by FAForever.
the class GameServiceImplTest method testOnGameInfoMessageDoesntSetCurrentGameIfUserDoesntMatch.
@Test
public void testOnGameInfoMessageDoesntSetCurrentGameIfUserDoesntMatch() throws Exception {
assertThat(instance.getCurrentGame(), nullValue());
when(playerService.getCurrentPlayer()).thenReturn(Optional.ofNullable(PlayerBuilder.create("PlayerName").get()));
GameInfoMessage gameInfoMessage = GameInfoMessageBuilder.create(1234).defaultValues().addTeamMember("1", "Other").get();
gameInfoMessageListenerCaptor.getValue().accept(gameInfoMessage);
assertThat(instance.getCurrentGame(), nullValue());
}
use of com.faforever.client.remote.domain.GameInfoMessage in project downlords-faf-client by FAForever.
the class GameServiceImplTest method testOnGameInfoModify.
@Test
public void testOnGameInfoModify() throws InterruptedException {
assertThat(instance.getGames(), empty());
GameInfoMessage gameInfoMessage = GameInfoMessageBuilder.create(1).defaultValues().title("Game 1").state(PLAYING).get();
gameInfoMessageListenerCaptor.getValue().accept(gameInfoMessage);
WaitForAsyncUtils.waitForFxEvents();
CountDownLatch changeLatch = new CountDownLatch(1);
Game game = instance.getGames().iterator().next();
game.titleProperty().addListener((observable, oldValue, newValue) -> {
changeLatch.countDown();
});
gameInfoMessage = GameInfoMessageBuilder.create(1).defaultValues().title("Game 1 modified").state(PLAYING).get();
gameInfoMessageListenerCaptor.getValue().accept(gameInfoMessage);
changeLatch.await();
assertEquals(gameInfoMessage.getTitle(), game.getTitle());
}
use of com.faforever.client.remote.domain.GameInfoMessage in project downlords-faf-client by FAForever.
the class GameServiceImplTest method testOnGameInfoRemove.
@Test
public void testOnGameInfoRemove() {
assertThat(instance.getGames(), empty());
when(playerService.getCurrentPlayer()).thenReturn(Optional.ofNullable(PlayerBuilder.create("PlayerName").get()));
GameInfoMessage gameInfoMessage = GameInfoMessageBuilder.create(1).defaultValues().title("Game 1").get();
gameInfoMessageListenerCaptor.getValue().accept(gameInfoMessage);
gameInfoMessage = GameInfoMessageBuilder.create(1).title("Game 1").defaultValues().state(CLOSED).get();
gameInfoMessageListenerCaptor.getValue().accept(gameInfoMessage);
WaitForAsyncUtils.waitForFxEvents();
assertThat(instance.getGames(), empty());
}
use of com.faforever.client.remote.domain.GameInfoMessage in project downlords-faf-client by FAForever.
the class MockFafServerAccessor method createGameInfo.
private GameInfoMessage createGameInfo(int uid, String title, GameAccess access, String featuredMod, String mapName, int numPlayers, int maxPlayers, String host) {
GameInfoMessage gameInfoMessage = new GameInfoMessage();
gameInfoMessage.setUid(uid);
gameInfoMessage.setTitle(title);
gameInfoMessage.setFeaturedMod(featuredMod);
gameInfoMessage.setMapname(mapName);
gameInfoMessage.setNumPlayers(numPlayers);
gameInfoMessage.setMaxPlayers(maxPlayers);
gameInfoMessage.setHost(host);
gameInfoMessage.setState(GameStatus.OPEN);
gameInfoMessage.setSimMods(Collections.emptyMap());
gameInfoMessage.setTeams(Collections.emptyMap());
gameInfoMessage.setFeaturedModVersions(Collections.emptyMap());
gameInfoMessage.setPasswordProtected(access == GameAccess.PASSWORD);
return gameInfoMessage;
}
Aggregations