Search in sources :

Example 86 with Game

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

the class GameServiceTest method reportArmyStatistics.

@Test
public void reportArmyStatistics() throws Exception {
    Game game = hostGame(player1);
    assertThat(game.getArmyStatistics(), is(empty()));
    instance.reportArmyStatistics(player1, Arrays.asList(new ArmyStatistics(), new ArmyStatistics()));
    assertThat(game.getArmyStatistics(), is(notNullValue()));
    assertThat(game.getArmyStatistics(), hasSize(2));
}
Also used : Game(com.faforever.server.entity.Game) ArmyStatistics(com.faforever.server.stats.ArmyStatistics) Test(org.junit.Test)

Example 87 with Game

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

the class GameServiceTest method onGameClosedProcessesStatsIfGameStarted.

@Test
public void onGameClosedProcessesStatsIfGameStarted() throws Exception {
    Game game = hostGame(player1);
    launchGame(game);
    instance.updatePlayerGameState(PlayerGameState.CLOSED, player1);
    assertThat(game.getState(), is(GameState.CLOSED));
    verify(armyStatisticsService).process(any(), eq(game), any());
    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)

Example 88 with Game

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

the class GameServiceTest method simpleValidGameWithoutEnded.

@Test
public void simpleValidGameWithoutEnded() throws Exception {
    Game game = hostGame(player1);
    addPlayer(game, player2);
    launchGame(game);
    Stream.of(player1, player2).forEach(player -> {
        instance.reportArmyOutcome(player, 2, Outcome.DEFEAT);
        instance.reportArmyScore(player, 2, -1);
        instance.reportArmyOutcome(player, 1, Outcome.VICTORY);
        instance.reportArmyScore(player, 1, 10);
    });
    assertThat(game.getValidity(), is(Validity.VALID));
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 89 with Game

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

the class GameServiceTest method updateGameValidityUnknownResult.

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

Example 90 with Game

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

the class GameServiceTest method reportArmyScoreAiScore.

@Test
public void reportArmyScoreAiScore() throws Exception {
    Game game = hostGame(player1);
    instance.updatePlayerOption(player1, player1.getId(), OPTION_ARMY, 1);
    instance.updateAiOption(player1, "QAI", OPTION_ARMY, 2);
    instance.reportArmyScore(player1, 1, 10);
    instance.reportArmyScore(player1, 2, -1);
    assertThat(game.getReportedArmyResults().values(), hasSize(1));
    assertThat(game.getReportedArmyResults().get(player1.getId()).values(), hasSize(2));
}
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