Search in sources :

Example 6 with FeaturedMod

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

the class MatchMakerServiceTest method setUp.

@Before
public void setUp() throws Exception {
    properties = new ServerProperties();
    FeaturedMod ladder1v1Mod = new FeaturedMod().setTechnicalName("faf");
    when(modService.getFeaturedMod(ladder1v1Mod.getTechnicalName())).thenReturn(Optional.of(ladder1v1Mod));
    when(modService.getLadder1v1()).thenReturn(Optional.of(ladder1v1Mod));
    when(modService.isLadder1v1(ladder1v1Mod)).thenReturn(true);
    when(mapService.getRandomLadderMap()).thenReturn(new MapVersion().setFilename("maps/SCMP_001.zip"));
    when(gameService.createGame(any(), any(), any(), any(), any(), anyInt(), anyInt(), any())).thenReturn(CompletableFuture.completedFuture(new Game().setId(1)));
    RatingService ratingService = new RatingService(properties);
    instance = new MatchMakerService(modService, properties, ratingService, clientService, gameService, mapService, playerService);
}
Also used : Game(com.faforever.server.entity.Game) ServerProperties(com.faforever.server.config.ServerProperties) MapVersion(com.faforever.server.entity.MapVersion) FeaturedMod(com.faforever.server.entity.FeaturedMod) RatingService(com.faforever.server.rating.RatingService) Before(org.junit.Before)

Example 7 with FeaturedMod

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

the class GameServiceTest method setUp.

@Before
public void setUp() throws Exception {
    MapVersion map = new MapVersion();
    map.setRanked(true);
    player1 = new Player();
    player1.setId(1);
    player1.setLogin(PLAYER_NAME_1);
    player2 = new Player();
    player2.setId(2);
    player2.setLogin(PLAYER_NAME_2);
    FeaturedMod fafFeaturedMod = new FeaturedMod();
    fafFeaturedMod.setTechnicalName(FAF_TECHNICAL_NAME);
    when(gameRepository.findMaxId()).thenReturn(Optional.empty());
    when(mapService.findMap(anyString())).thenReturn(Optional.empty());
    when(mapService.findMap(MAP_NAME)).thenReturn(Optional.of(map));
    when(modService.getFeaturedMod(FAF_TECHNICAL_NAME)).thenReturn(Optional.of(fafFeaturedMod));
    when(playerService.getOnlinePlayer(anyInt())).thenReturn(Optional.empty());
    doAnswer(invocation -> invocation.getArgumentAt(0, Player.class).setGlobalRating(new GlobalRating())).when(ratingService).initGlobalRating(any());
    serverProperties = new ServerProperties();
    serverProperties.getGame().setRankedMinTimeMultiplicator(-10000);
    instance = new GameService(gameRepository, counterService, clientService, mapService, modService, playerService, ratingService, serverProperties, divisionService, entityManager, armyStatisticsService);
    instance.onApplicationEvent(null);
}
Also used : Player(com.faforever.server.entity.Player) ServerProperties(com.faforever.server.config.ServerProperties) GlobalRating(com.faforever.server.entity.GlobalRating) MapVersion(com.faforever.server.entity.MapVersion) FeaturedMod(com.faforever.server.entity.FeaturedMod) Before(org.junit.Before)

Example 8 with FeaturedMod

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

the class ClientServiceTest method startGameProcess.

@Test
public void startGameProcess() throws Exception {
    Game game = new Game().setId(1).setFeaturedMod(new FeaturedMod());
    instance.startGameProcess(game, player);
    ArgumentCaptor<StartGameProcessResponse> captor = ArgumentCaptor.forClass(StartGameProcessResponse.class);
    verify(clientGateway).send(captor.capture(), any());
    assertThat(captor.getValue().getGameId(), is(1));
}
Also used : Game(com.faforever.server.entity.Game) FeaturedMod(com.faforever.server.entity.FeaturedMod) StartGameProcessResponse(com.faforever.server.game.StartGameProcessResponse) Test(org.junit.Test)

Example 9 with FeaturedMod

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

the class ArmyStatisticsServiceTest method testWin1v1Within10Minutes.

/**
 * Tests {@link AchievementId#ACH_RUSHER}.
 */
@Test
public void testWin1v1Within10Minutes() throws Exception {
    FeaturedMod ladder1v1FeaturedMod = new FeaturedMod();
    when(modService.isLadder1v1(ladder1v1FeaturedMod)).thenReturn(true);
    game.setFeaturedMod(ladder1v1FeaturedMod);
    game.getReportedArmyResults().put(player.getId(), ImmutableMap.of(1, ArmyResult.of(1, Outcome.VICTORY, null)));
    game.setStartTime(Instant.now().minus(Duration.ofMinutes(9)));
    game.setEndTime(Instant.now());
    List<ArmyStatistics> stats = readStats("/stats/game_stats_simple_win.json");
    instance.process(player, game, stats);
    assertThat(this.achievementUpdates, hasItem(new AchievementUpdate(42, AchievementId.ACH_RUSHER, AchievementUpdate.UpdateType.UNLOCK, 0)));
}
Also used : AchievementUpdate(com.faforever.server.stats.achievements.AchievementUpdate) FeaturedMod(com.faforever.server.entity.FeaturedMod) Test(org.junit.Test)

Aggregations

FeaturedMod (com.faforever.server.entity.FeaturedMod)9 Test (org.junit.Test)6 ServerProperties (com.faforever.server.config.ServerProperties)3 Game (com.faforever.server.entity.Game)3 MapVersion (com.faforever.server.entity.MapVersion)3 Player (com.faforever.server.entity.Player)3 AchievementUpdate (com.faforever.server.stats.achievements.AchievementUpdate)3 RatingService (com.faforever.server.rating.RatingService)2 Before (org.junit.Before)2 ClientService (com.faforever.server.client.ClientService)1 ConnectionAware (com.faforever.server.client.ConnectionAware)1 GlobalRating (com.faforever.server.entity.GlobalRating)1 Ladder1v1Rating (com.faforever.server.entity.Ladder1v1Rating)1 ErrorCode (com.faforever.server.error.ErrorCode)1 RequestException (com.faforever.server.error.RequestException)1 Requests (com.faforever.server.error.Requests)1 Faction (com.faforever.server.game.Faction)1 GameService (com.faforever.server.game.GameService)1 GameVisibility (com.faforever.server.game.GameVisibility)1 StartGameProcessResponse (com.faforever.server.game.StartGameProcessResponse)1