use of com.faforever.server.player.PlayerResponse.Player.Avatar 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.Player.Avatar 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.Player.Avatar 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]));
}
Aggregations