use of com.faforever.server.player.PlayerResponse in project faf-java-server by FAForever.
the class LoginDetailsServerMessageTransformerTest method transformHandleGlobalRatingNull.
@Test
@SuppressWarnings("unchecked")
public void transformHandleGlobalRatingNull() throws Exception {
Map<String, Serializable> result = LoginDetailsResponseTransformer.INSTANCE.transform(new LoginDetailsResponse(new PlayerResponse(1, TEST_USERNAME, "CH", new PlayerResponse.Player(null, new Rating(900d, 100d), 12, new Avatar("http://example.com", "Tooltip"), "FOO"))));
Map<String, Object> me = (Map<String, Object>) result.get("me");
assertThat(me.get("global_rating"), is(new double[2]));
}
use of com.faforever.server.player.PlayerResponse in project faf-java-server by FAForever.
the class PlayerResponsesTransformerTest method transformFull.
@Test
@SuppressWarnings("unchecked")
public void transformFull() throws Exception {
Map<String, Serializable> result = PlayerResponsesTransformer.INSTANCE.transform(new PlayerResponses(Collections.singletonList(new PlayerResponse(1, TEST_USERNAME, "CH", new PlayerResponse.Player(new Rating(1200d, 200d), new Rating(900d, 100d), 12, new Avatar("http://example.com", "Tooltip"), "FOO")))));
assertThat(result.get("command"), is("player_info"));
List<Map<String, Serializable>> players = (List<Map<String, Serializable>>) result.get("players");
assertThat(players.size(), is(1));
Map<String, Serializable> player = players.get(0);
assertThat(player.get("id"), is(1));
assertThat(player.get("login"), is(TEST_USERNAME));
assertThat(player.get("login"), is(TEST_USERNAME));
assertThat(player.get("global_rating"), is(new double[] { 1200, 200 }));
assertThat(player.get("ladder_rating"), is(new double[] { 900, 100 }));
assertThat(player.get("number_of_games"), is(12));
Map<String, Serializable> avatarMap = (Map<String, Serializable>) player.get("avatar");
assertThat(avatarMap.get("url"), is("http://example.com"));
assertThat(avatarMap.get("tooltip"), is("Tooltip"));
assertThat(player.get("country"), is("CH"));
assertThat(player.get("clan"), is("FOO"));
}
use of com.faforever.server.player.PlayerResponse in project faf-java-server by FAForever.
the class PlayerResponsesTransformerTest method transformHandleLadder1v1RatingNull.
@Test
@SuppressWarnings("unchecked")
public void transformHandleLadder1v1RatingNull() throws Exception {
Map<String, Serializable> result = PlayerResponsesTransformer.INSTANCE.transform(new PlayerResponses(Collections.singletonList(new PlayerResponse(1, TEST_USERNAME, "CH", new PlayerResponse.Player(new Rating(900d, 100d), null, 12, new Avatar("http://example.com", "Tooltip"), "FOO")))));
List<Map<String, Object>> players = (List<Map<String, Object>>) result.get("players");
assertThat(players.get(0).get("ladder_rating"), is(new double[2]));
}
use of com.faforever.server.player.PlayerResponse in project faf-java-server by FAForever.
the class PlayerResponsesTransformerTest method transformHandleGlobalRatingNull.
@Test
@SuppressWarnings("unchecked")
public void transformHandleGlobalRatingNull() throws Exception {
Map<String, Serializable> result = PlayerResponsesTransformer.INSTANCE.transform(new PlayerResponses(Collections.singletonList(new PlayerResponse(1, TEST_USERNAME, "CH", new PlayerResponse.Player(null, new Rating(900d, 100d), 12, new Avatar("http://example.com", "Tooltip"), "FOO")))));
List<Map<String, Object>> players = (List<Map<String, Object>>) result.get("players");
assertThat(players.get(0).get("global_rating"), is(new double[2]));
}
use of com.faforever.server.player.PlayerResponse in project faf-java-server by FAForever.
the class ClientServiceTest method sendOnlinePlayerList.
@Test
public void sendOnlinePlayerList() throws Exception {
List<Player> players = Arrays.asList((Player) new Player().setAvailableAvatars(emptyList()).setId(1).setLogin("JUnit").setCountry("CH"), (Player) new Player().setAvailableAvatars(emptyList()).setId(2).setLogin("JUnit").setCountry("CH"));
ConnectionAware connectionAware = new Player().setClientConnection(clientConnection);
CompletableFuture<PlayerResponses> sent = new CompletableFuture<>();
doAnswer(invocation -> sent.complete(invocation.getArgumentAt(0, PlayerResponses.class))).when(clientGateway).send(any(PlayerResponses.class), eq(clientConnection));
instance.sendPlayerInformation(players, connectionAware);
PlayerResponses responses = sent.get(10, TimeUnit.SECONDS);
assertThat(responses.getResponses(), hasSize(2));
Iterator<PlayerResponse> iterator = responses.getResponses().iterator();
assertThat(iterator.next().getPlayerId(), is(1));
assertThat(iterator.next().getPlayerId(), is(2));
}
Aggregations