Search in sources :

Example 26 with Player

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

the class TeamKillServiceTest method reportTeamKillWhenVictimIsntReported.

@Test
public void reportTeamKillWhenVictimIsntReported() throws Exception {
    Player reporter = new Player();
    reporter.setCurrentGame(new Game());
    reporter.setId(1);
    Player killer = (Player) new Player().setId(2);
    Player victim = (Player) new Player().setId(2);
    when(playerService.getOnlinePlayer(killer.getId())).thenReturn(Optional.of(killer));
    instance.reportTeamKill(reporter, Duration.ofMinutes(28), killer.getId(), victim.getId());
    verifyZeroInteractions(teamKillRepository);
}
Also used : Player(com.faforever.server.entity.Player) Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 27 with Player

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

the class ClientServiceTest method sendIceServers.

@Test
public void sendIceServers() throws Exception {
    List<IceServerList> iceServers = Collections.singletonList(new IceServerList(60, Instant.now(), Arrays.asList(new IceServer(URI.create("turn:test1"), null, null, null), new IceServer(URI.create("turn:test2"), "username", "credential", "credentialType"))));
    ConnectionAware connectionAware = new Player().setClientConnection(clientConnection);
    instance.sendIceServers(iceServers, connectionAware);
    verify(clientGateway).send(new IceServersResponse(iceServers), clientConnection);
}
Also used : Player(com.faforever.server.entity.Player) IceServer(com.faforever.server.ice.IceServer) IceServerList(com.faforever.server.ice.IceServerList) Test(org.junit.Test)

Example 28 with Player

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

the class ClientServiceTest method disconnectPlayerSendsToAllPlayersInGame.

@Test
public void disconnectPlayerSendsToAllPlayersInGame() throws Exception {
    List<Player> recipients = Arrays.asList(player, new Player(), new Player(), new Player());
    instance.disconnectPlayerFromGame(12, recipients);
    verify(clientGateway, times(4)).send(any(DisconnectPlayerFromGameResponse.class), any());
}
Also used : Player(com.faforever.server.entity.Player) Test(org.junit.Test)

Example 29 with Player

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

the class CoopServiceTest method reportOperationCompleteNotInGame.

@Test
public void reportOperationCompleteNotInGame() throws Exception {
    expectedException.expect(requestExceptionWithCode(ErrorCode.COOP_CANT_REPORT_NOT_IN_GAME));
    instance.reportOperationComplete(new Player(), true, Duration.ofMinutes(1));
}
Also used : Player(com.faforever.server.entity.Player) Test(org.junit.Test)

Example 30 with Player

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

the class GameServiceTest method updateGameValidityFreeForAll.

@Test
public void updateGameValidityFreeForAll() throws Exception {
    Player player3 = (Player) new Player().setId(3);
    Game game = hostGame(player1);
    addPlayer(game, player2);
    addPlayer(game, player3);
    instance.updatePlayerOption(player1, player1.getId(), OPTION_TEAM, 2);
    instance.updatePlayerOption(player1, player2.getId(), OPTION_TEAM, 3);
    instance.updatePlayerOption(player1, player3.getId(), OPTION_TEAM, 4);
    launchGame(game);
    game.getReportedArmyResults().put(1, Collections.emptyMap());
    game.getReportedArmyResults().put(2, Collections.emptyMap());
    game.getReportedArmyResults().put(1, Collections.emptyMap());
    game.getReportedArmyResults().put(2, Collections.emptyMap());
    instance.updateGameValidity(game);
    assertThat(game.getValidity(), is(Validity.FREE_FOR_ALL));
}
Also used : Player(com.faforever.server.entity.Player) Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Aggregations

Player (com.faforever.server.entity.Player)73 Test (org.junit.Test)38 Game (com.faforever.server.entity.Game)25 Before (org.junit.Before)13 ServerProperties (com.faforever.server.config.ServerProperties)11 GamePlayerStats (com.faforever.server.entity.GamePlayerStats)11 PlayerOnlineEvent (com.faforever.server.player.PlayerOnlineEvent)11 List (java.util.List)11 Slf4j (lombok.extern.slf4j.Slf4j)11 Service (org.springframework.stereotype.Service)11 ClientService (com.faforever.server.client.ClientService)10 ConnectionAware (com.faforever.server.client.ConnectionAware)10 FeaturedMod (com.faforever.server.entity.FeaturedMod)10 Ladder1v1Rating (com.faforever.server.entity.Ladder1v1Rating)10 Optional (java.util.Optional)10 GlobalRating (com.faforever.server.entity.GlobalRating)9 ModService (com.faforever.server.mod.ModService)9 VisibleForTesting (com.google.common.annotations.VisibleForTesting)9 Duration (java.time.Duration)9 Map (java.util.Map)9