Search in sources :

Example 1 with Mod

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

the class GameServiceTest method updateGameMods.

@Test
public void updateGameMods() 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, modUids);
    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 2 with Mod

use of com.faforever.server.entity.Mod 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 3 with Mod

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

the class GameServiceTest method updateGameValidityUnrankedMod.

@Test
public void updateGameValidityUnrankedMod() throws Exception {
    Game game = hostGame(player1);
    game.getSimMods().add(new ModVersion().setRanked(false).setMod(new Mod().setDisplayName("Mod")));
    launchGame(game);
    instance.updateGameValidity(game);
    assertThat(game.getValidity(), is(Validity.BAD_MOD));
}
Also used : ModVersion(com.faforever.server.entity.ModVersion) Game(com.faforever.server.entity.Game) FeaturedMod(com.faforever.server.entity.FeaturedMod) Mod(com.faforever.server.entity.Mod) Test(org.junit.Test)

Example 4 with Mod

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

the class GameServiceTest method updateGameModsCountClearsIfZero.

@Test
public void updateGameModsCountClearsIfZero() 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, 0);
    assertThat(game.getSimMods(), is(empty()));
}
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)

Aggregations

FeaturedMod (com.faforever.server.entity.FeaturedMod)4 Game (com.faforever.server.entity.Game)4 Mod (com.faforever.server.entity.Mod)4 ModVersion (com.faforever.server.entity.ModVersion)4 Test (org.junit.Test)4 Matchers.anyString (org.mockito.Matchers.anyString)3