Search in sources :

Example 31 with Game

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

the class GameServiceTest method enforceRating.

@Test
public void enforceRating() throws Exception {
    Game game = hostGame(player1);
    assertThat(game.isRatingEnforced(), is(false));
    instance.enforceRating(player1);
    assertThat(game.isRatingEnforced(), is(true));
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 32 with Game

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

the class GameServiceTest method updateGameValidityUnitRestriction.

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

Example 33 with Game

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

the class GameServiceTest method updateGameValidityUnrankedMap.

@Test
public void updateGameValidityUnrankedMap() throws Exception {
    Game game = hostGame(player1);
    game.getMapVersion().setRanked(false);
    launchGame(game);
    instance.updateGameValidity(game);
    assertThat(game.getValidity(), is(Validity.BAD_MAP));
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 34 with Game

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

the class GameServiceTest method updateGameModsCountDoesntClearIfNonZero.

@Test
public void updateGameModsCountDoesntClearIfNonZero() throws Exception {
    List<String> modUids = Arrays.asList("1-1-1-1", "2-2-2-2");
    when(modService.findModVersionsByUids(modUids)).thenReturn(Arrays.asList(new ModVersion().setUid("1-1-1-1").setMod(new Mod().setDisplayName("Mod #1")), new ModVersion().setUid("2-2-2-2").setMod(new Mod().setDisplayName("Mod #2"))));
    Game game = hostGame(player1);
    instance.updateGameMods(game, Arrays.asList("1-1-1-1", "2-2-2-2"));
    instance.updateGameModsCount(game, 1);
    List<ModVersion> simMods = game.getSimMods();
    assertThat(simMods, hasSize(2));
    assertThat(simMods.get(0).getUid(), is("1-1-1-1"));
    assertThat(simMods.get(0).getMod().getDisplayName(), is("Mod #1"));
    assertThat(simMods.get(1).getUid(), is("2-2-2-2"));
    assertThat(simMods.get(1).getMod().getDisplayName(), is("Mod #2"));
}
Also used : ModVersion(com.faforever.server.entity.ModVersion) FeaturedMod(com.faforever.server.entity.FeaturedMod) Mod(com.faforever.server.entity.Mod) Game(com.faforever.server.entity.Game) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 35 with Game

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

the class GameServiceTest method updateGameValidityWrongVictoryConditionDominationNotCoop.

@Test
public void updateGameValidityWrongVictoryConditionDominationNotCoop() throws Exception {
    Game game = hostGame(player1);
    game.setVictoryCondition(VictoryCondition.DOMINATION);
    when(modService.isCoop(any())).thenReturn(false);
    launchGame(game);
    instance.updateGameValidity(game);
    assertThat(game.getValidity(), is(Validity.WRONG_VICTORY_CONDITION));
}
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