Search in sources :

Example 6 with Avatar

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"));
}
Also used : PlayerResponse(com.faforever.server.player.PlayerResponse) Serializable(java.io.Serializable) Rating(com.faforever.server.player.PlayerResponse.Player.Rating) PlayerResponses(com.faforever.server.client.PlayerResponses) List(java.util.List) Map(java.util.Map) Avatar(com.faforever.server.player.PlayerResponse.Player.Avatar) Test(org.junit.Test)

Example 7 with Avatar

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]));
}
Also used : PlayerResponse(com.faforever.server.player.PlayerResponse) Serializable(java.io.Serializable) Rating(com.faforever.server.player.PlayerResponse.Player.Rating) PlayerResponses(com.faforever.server.client.PlayerResponses) List(java.util.List) Map(java.util.Map) Avatar(com.faforever.server.player.PlayerResponse.Player.Avatar) Test(org.junit.Test)

Example 8 with Avatar

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]));
}
Also used : PlayerResponse(com.faforever.server.player.PlayerResponse) Serializable(java.io.Serializable) Rating(com.faforever.server.player.PlayerResponse.Player.Rating) PlayerResponses(com.faforever.server.client.PlayerResponses) List(java.util.List) Map(java.util.Map) Avatar(com.faforever.server.player.PlayerResponse.Player.Avatar) Test(org.junit.Test)

Aggregations

PlayerResponse (com.faforever.server.player.PlayerResponse)8 Avatar (com.faforever.server.player.PlayerResponse.Player.Avatar)8 Rating (com.faforever.server.player.PlayerResponse.Player.Rating)8 Test (org.junit.Test)8 Serializable (java.io.Serializable)6 Map (java.util.Map)6 LoginDetailsResponse (com.faforever.server.player.LoginDetailsResponse)4 PlayerResponses (com.faforever.server.client.PlayerResponses)3 List (java.util.List)3 Player (com.faforever.server.game.GameResponse.Player)1