Search in sources :

Example 56 with Player

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

the class GameServiceTest method addPlayer.

private void addPlayer(Game game, Player player) {
    instance.joinGame(game.getId(), game.getPassword(), player);
    instance.updatePlayerGameState(PlayerGameState.LOBBY, player);
    Player host = game.getHost();
    instance.updatePlayerOption(host, player.getId(), OPTION_FACTION, 1);
    instance.updatePlayerOption(host, player.getId(), OPTION_SLOT, player.getId());
    instance.updatePlayerOption(host, player.getId(), OPTION_ARMY, player.getId());
    instance.updatePlayerOption(host, player.getId(), OPTION_COLOR, player.getId());
    instance.updatePlayerOption(host, player.getId(), OPTION_START_SPOT, player.getId());
    instance.updatePlayerOption(host, player.getId(), OPTION_TEAM, GameService.NO_TEAM_ID);
}
Also used : Player(com.faforever.server.entity.Player)

Example 57 with Player

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

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

the class IceServiceTest method forwardIceMessageToOnlinePlayer.

@Test
public void forwardIceMessageToOnlinePlayer() throws Exception {
    Player receiver = (Player) new Player().setId(42);
    when(playerService.getOnlinePlayer(42)).thenReturn(Optional.of(receiver));
    Object payload = new Object();
    instance.forwardIceMessage(player, 42, payload);
    verify(clientService).sendIceMessage(player.getId(), payload, receiver);
}
Also used : Player(com.faforever.server.entity.Player) Test(org.junit.Test)

Example 59 with Player

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

the class IceServiceTest method setUp.

@Before
public void setUp() throws Exception {
    player = (Player) new Player().setId(1);
    List<IceServersProvider> serverProviders = Arrays.asList(() -> new IceServerList(60, Instant.now(), Arrays.asList(new IceServer(URI.create("http://localhost:1234"), "user1", "password1", "token"), new IceServer(URI.create("http://localhost:2345"), "user2", "password2", "token"))), () -> new IceServerList(60, Instant.now(), Arrays.asList(new IceServer(URI.create("http://localhost:3465"), "user3", "password3", "token"), new IceServer(URI.create("http://localhost:4567"), "user4", "password4", "token"))));
    instance = new IceService(clientService, playerService, serverProviders);
}
Also used : Player(com.faforever.server.entity.Player) Before(org.junit.Before)

Example 60 with Player

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

the class IceServiceActivatorsTest method setUp.

@Before
public void setUp() throws Exception {
    player = new Player();
    player.setClientConnection(clientConnection);
    clientConnection = new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class)).setAuthentication(new TestingAuthenticationToken(new FafUserDetails((User) new User().setPlayer(player).setPassword("pw").setLogin("JUnit")), null));
    instance = new IceServiceActivators(iceService);
}
Also used : Player(com.faforever.server.entity.Player) User(com.faforever.server.entity.User) ClientConnection(com.faforever.server.client.ClientConnection) FafUserDetails(com.faforever.server.security.FafUserDetails) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) InetAddress(java.net.InetAddress) Before(org.junit.Before)

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