Search in sources :

Example 66 with Player

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

the class ClientServiceTest method sendAvatarList.

@Test
public void sendAvatarList() throws Exception {
    List<Avatar> avatars = Arrays.asList(new Avatar().setUrl("http://example.com/foo.bar").setDescription("Foo bar"), new Avatar());
    ConnectionAware connectionAware = new Player().setClientConnection(clientConnection);
    instance.sendAvatarList(avatars, connectionAware);
    ArgumentCaptor<AvatarsResponse> captor = ArgumentCaptor.forClass(AvatarsResponse.class);
    verify(clientGateway).send(captor.capture(), eq(clientConnection));
    assertThat(captor.getValue().getAvatars(), hasSize(2));
    assertThat(captor.getValue().getAvatars().get(0).getUrl(), is("http://example.com/foo.bar"));
    assertThat(captor.getValue().getAvatars().get(0).getDescription(), is("Foo bar"));
}
Also used : Player(com.faforever.server.entity.Player) Avatar(com.faforever.server.entity.Avatar) Test(org.junit.Test)

Example 67 with Player

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

the class ClientServiceTest method setUp.

@Before
public void setUp() throws Exception {
    serverProperties = new ServerProperties();
    clientConnection = new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class));
    player = new Player().setClientConnection(clientConnection);
    instance = new ClientService(clientGateway, coopService, serverProperties);
}
Also used : Player(com.faforever.server.entity.Player) ServerProperties(com.faforever.server.config.ServerProperties) Before(org.junit.Before)

Example 68 with Player

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

the class ClientServiceTest method connectToHost.

@Test
public void connectToHost() throws Exception {
    Game game = new Game().setHost((Player) new Player().setLogin("JUnit").setId(1));
    instance.connectToHost(player, game);
    verify(clientGateway).send(new ConnectToHostResponse("JUnit", 1), clientConnection);
}
Also used : Player(com.faforever.server.entity.Player) Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 69 with Player

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

the class ClientServiceTest method broadcastPlayerInformation.

@Test
public void broadcastPlayerInformation() throws Exception {
    instance.broadcastMinDelay = Duration.ofMinutes(-1);
    instance.broadcastPlayerInformation(Arrays.asList((Player) new Player().setAvailableAvatars(emptyList()).setId(1), (Player) new Player().setAvailableAvatars(emptyList()).setId(2), (Player) new Player().setAvailableAvatars(emptyList()).setId(3)));
    instance.broadcastDelayedResponses();
    verify(clientGateway).broadcast(serverMessageCaptor.capture());
    ServerMessage message = serverMessageCaptor.getValue();
    assertThat(message, instanceOf(PlayerResponses.class));
}
Also used : Player(com.faforever.server.entity.Player) ServerMessage(com.faforever.server.common.ServerMessage) Test(org.junit.Test)

Example 70 with Player

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

the class ClientServiceTest method connectToPeer.

@Test
public void connectToPeer() throws Exception {
    Player peer = new Player();
    peer.setId(2);
    peer.setLogin("test");
    instance.connectToPeer(player, peer, false);
    ArgumentCaptor<ConnectToPeerResponse> captor = ArgumentCaptor.forClass(ConnectToPeerResponse.class);
    verify(clientGateway).send(captor.capture(), eq(clientConnection));
    ConnectToPeerResponse response = captor.getValue();
    assertThat(response.getPlayerId(), is(peer.getId()));
    assertThat(response.getPlayerName(), is(peer.getLogin()));
    assertThat(response.isOffer(), is(false));
}
Also used : Player(com.faforever.server.entity.Player) 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