Search in sources :

Example 11 with Game

use of com.faforever.server.entity.Game in project faf-java-server by FAForever.

the class GameServiceTest method updateGameValidityNoRushEnabled.

@Test
public void updateGameValidityNoRushEnabled() throws Exception {
    Game game = hostGame(player1);
    game.getOptions().put(OPTION_NO_RUSH, "On");
    launchGame(game);
    instance.updateGameValidity(game);
    assertThat(game.getValidity(), is(Validity.NO_RUSH_ENABLED));
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 12 with Game

use of com.faforever.server.entity.Game in project faf-java-server by FAForever.

the class GameServiceTest method joinGameWrongPassword.

@Test
public void joinGameWrongPassword() throws Exception {
    Game game = hostGame(player1);
    game.setPassword("pw");
    expectedException.expect(requestExceptionWithCode(ErrorCode.INVALID_PASSWORD));
    instance.joinGame(game.getId(), "PW", player2);
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 13 with Game

use of com.faforever.server.entity.Game in project faf-java-server by FAForever.

the class GameServiceTest method updateAiOptionArmy.

@Test
public void updateAiOptionArmy() throws Exception {
    Game game = hostGame(player1);
    assertThat(game.getAiOptions().containsKey(QAI), is(false));
    instance.updateAiOption(player1, QAI, OPTION_ARMY, 2);
    assertThat(game.getAiOptions().get(QAI).get(OPTION_ARMY), is(2));
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 14 with Game

use of com.faforever.server.entity.Game in project faf-java-server by FAForever.

the class GameServiceTest method updateGameValidityFreeForAll.

@Test
public void updateGameValidityFreeForAll() throws Exception {
    Player player3 = (Player) new Player().setId(3);
    Game game = hostGame(player1);
    addPlayer(game, player2);
    addPlayer(game, player3);
    instance.updatePlayerOption(player1, player1.getId(), OPTION_TEAM, 2);
    instance.updatePlayerOption(player1, player2.getId(), OPTION_TEAM, 3);
    instance.updatePlayerOption(player1, player3.getId(), OPTION_TEAM, 4);
    launchGame(game);
    game.getReportedArmyResults().put(1, Collections.emptyMap());
    game.getReportedArmyResults().put(2, Collections.emptyMap());
    game.getReportedArmyResults().put(1, Collections.emptyMap());
    game.getReportedArmyResults().put(2, Collections.emptyMap());
    instance.updateGameValidity(game);
    assertThat(game.getValidity(), is(Validity.FREE_FOR_ALL));
}
Also used : Player(com.faforever.server.entity.Player) Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 15 with Game

use of com.faforever.server.entity.Game in project faf-java-server by FAForever.

the class GameServiceTest method onGameClosedDoesntSaveGameIfGameDidntStart.

@Test
public void onGameClosedDoesntSaveGameIfGameDidntStart() throws Exception {
    Game game = hostGame(player1);
    instance.updatePlayerGameState(PlayerGameState.CLOSED, player1);
    assertThat(game.getState(), is(GameState.CLOSED));
    verify(gameRepository, never()).save(any(Game.class));
    verifyZeroInteractions(divisionService);
    assertThat(player1.getCurrentGame(), is(nullValue()));
    assertThat(player1.getGameState(), is(PlayerGameState.NONE));
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Aggregations

Game (com.faforever.server.entity.Game)96 Test (org.junit.Test)71 Player (com.faforever.server.entity.Player)26 FeaturedMod (com.faforever.server.entity.FeaturedMod)15 ModVersion (com.faforever.server.entity.ModVersion)12 ConnectionAware (com.faforever.server.client.ConnectionAware)11 Ladder1v1Rating (com.faforever.server.entity.Ladder1v1Rating)11 List (java.util.List)11 ClientService (com.faforever.server.client.ClientService)10 ServerProperties (com.faforever.server.config.ServerProperties)10 RequestException (com.faforever.server.error.RequestException)10 ModService (com.faforever.server.mod.ModService)10 VisibleForTesting (com.google.common.annotations.VisibleForTesting)10 Duration (java.time.Duration)10 Map (java.util.Map)10 Optional (java.util.Optional)10 Slf4j (lombok.extern.slf4j.Slf4j)10 Service (org.springframework.stereotype.Service)10 ArmyResult (com.faforever.server.entity.ArmyResult)9 GamePlayerStats (com.faforever.server.entity.GamePlayerStats)9