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);
}
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);
}
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));
}
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)));
}
Aggregations