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