Search in sources :

Example 76 with Game

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

the class GameServiceTest method reportArmyScoreNotInGame.

@Test
public void reportArmyScoreNotInGame() throws Exception {
    Game game = hostGame(player1);
    assertThat(player2.getCurrentGame(), is(nullValue()));
    instance.reportArmyScore(player2, 1, 10);
    assertThat(game.getReportedArmyResults().values(), is(empty()));
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 77 with Game

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

the class GameServiceTest method onGameEndedSavesGameIfGameStarted.

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

Example 78 with Game

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

the class GameServiceTest method onGameClosedDoesntProcessArmyStatsIfGameDidntStart.

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

Example 79 with Game

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

the class GameServiceTest method mutualDrawRequestedByObserver.

@Test
public void mutualDrawRequestedByObserver() throws Exception {
    Game game = hostGame(player1);
    instance.updatePlayerOption(player1, player1.getId(), OPTION_TEAM, GameService.OBSERVERS_TEAM_ID);
    launchGame(game);
    instance.mutuallyAgreeDraw(player1);
    assertThat(game.isMutuallyAgreedDraw(), is(false));
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 80 with Game

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

the class GameServiceTest method onGameLaunchingSentByNonHostIsIgnored.

@Test
public void onGameLaunchingSentByNonHostIsIgnored() throws Exception {
    Game game = hostGame(player1);
    addPlayer(game, player2);
    Mockito.reset(clientService);
    instance.updatePlayerGameState(PlayerGameState.LAUNCHING, player2);
    assertThat(game.getState(), is(GameState.OPEN));
    verifyZeroInteractions(clientService);
    verify(gameRepository, never()).save(game);
}
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