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