Search in sources :

Example 36 with Game

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

the class GameServiceTest method restoreGameSessionWasNeverInGame.

@Test
public void restoreGameSessionWasNeverInGame() throws Exception {
    Game game = hostGame(player1);
    launchGame(game);
    expectedException.expect(requestExceptionWithCode(ErrorCode.CANT_RESTORE_GAME_NOT_PARTICIPANT));
    instance.restoreGameSession(player2, game.getId());
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 37 with Game

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

the class GameServiceTest method updateGameValidityMutualDraw.

@Test
public void updateGameValidityMutualDraw() throws Exception {
    Game game = hostGame(player1);
    game.setMutuallyAgreedDraw(true);
    launchGame(game);
    instance.updateGameValidity(game);
    assertThat(game.getValidity(), is(Validity.MUTUAL_DRAW));
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 38 with Game

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

the class GameServiceTest method updateGameValidityUnevenTeams.

@Test
public void updateGameValidityUnevenTeams() 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, 2);
    instance.updatePlayerOption(player1, player3.getId(), OPTION_TEAM, 3);
    launchGame(game);
    instance.updateGameValidity(game);
    assertThat(game.getValidity(), is(Validity.UNEVEN_TEAMS));
}
Also used : Player(com.faforever.server.entity.Player) Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 39 with Game

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

the class GameServiceTest method updateGameValidityAlreadySetThrowsException.

@Test(expected = IllegalStateException.class)
public void updateGameValidityAlreadySetThrowsException() throws Exception {
    Game game = hostGame(player1);
    game.setValidity(Validity.UNKNOWN_RESULT);
    instance.updateGameValidity(game);
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 40 with Game

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

the class GameServiceTest method clearSlot.

@Test
public void clearSlot() throws Exception {
    Game game = hostGame(player1);
    instance.updatePlayerOption(game.getHost(), player1.getId(), OPTION_SLOT, 2);
    addPlayer(game, player2);
    instance.updatePlayerOption(player1, 1, OPTION_SLOT, 3);
    instance.updatePlayerOption(player1, 1, OPTION_FACTION, 3);
    instance.updatePlayerOption(player1, 2, OPTION_SLOT, 4);
    instance.updatePlayerOption(player1, 2, OPTION_FACTION, 4);
    instance.clearSlot(game, 1);
    assertThat(game.getPlayerOptions().containsKey(1), is(true));
    assertThat(game.getPlayerOptions().containsKey(2), is(true));
    instance.clearSlot(game, 4);
    assertThat(game.getPlayerOptions().containsKey(1), is(true));
    assertThat(game.getPlayerOptions().containsKey(2), is(false));
    instance.clearSlot(game, 3);
    assertThat(game.getPlayerOptions().containsKey(1), is(false));
    assertThat(game.getPlayerOptions().containsKey(2), is(false));
    instance.clearSlot(game, 2);
    assertThat(game.getPlayerOptions().containsKey(1), is(false));
    assertThat(game.getPlayerOptions().containsKey(2), is(false));
}
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