Search in sources :

Example 1 with GameInfoMessage

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));
}
Also used : GameInfoMessage(com.faforever.client.remote.domain.GameInfoMessage) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 2 with GameInfoMessage

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());
}
Also used : GameInfoMessage(com.faforever.client.remote.domain.GameInfoMessage) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 3 with GameInfoMessage

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());
}
Also used : GameInfoMessage(com.faforever.client.remote.domain.GameInfoMessage) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 4 with GameInfoMessage

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());
}
Also used : GameInfoMessage(com.faforever.client.remote.domain.GameInfoMessage) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 5 with GameInfoMessage

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;
}
Also used : GameInfoMessage(com.faforever.client.remote.domain.GameInfoMessage)

Aggregations

GameInfoMessage (com.faforever.client.remote.domain.GameInfoMessage)9 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)7 Test (org.junit.Test)7 FafClientApplication (com.faforever.client.FafClientApplication)1 GpgGameMessage (com.faforever.client.fa.relay.GpgGameMessage)1 Faction (com.faforever.client.game.Faction)1 KnownFeaturedMod (com.faforever.client.game.KnownFeaturedMod)1 NewGameInfo (com.faforever.client.game.NewGameInfo)1 I18n (com.faforever.client.i18n.I18n)1 ConnectionState (com.faforever.client.net.ConnectionState)1 Action (com.faforever.client.notification.Action)1 NotificationService (com.faforever.client.notification.NotificationService)1 PersistentNotification (com.faforever.client.notification.PersistentNotification)1 Severity (com.faforever.client.notification.Severity)1 MatchmakerMessage (com.faforever.client.rankedmatch.MatchmakerMessage)1 MatchmakerQueue (com.faforever.client.rankedmatch.MatchmakerMessage.MatchmakerQueue)1 Avatar (com.faforever.client.remote.domain.Avatar)1 GameAccess (com.faforever.client.remote.domain.GameAccess)1 PASSWORD (com.faforever.client.remote.domain.GameAccess.PASSWORD)1 PUBLIC (com.faforever.client.remote.domain.GameAccess.PUBLIC)1