Search in sources :

Example 1 with PlayerResponses

use of com.faforever.server.client.PlayerResponses in project faf-java-server by FAForever.

the class PlayerResponsesTransformerTest method transformHandleAvatarNull.

@Test
@SuppressWarnings("unchecked")
public void transformHandleAvatarNull() 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, null, "FOO")))));
    List<Map<String, Object>> players = (List<Map<String, Object>>) result.get("players");
    assertThat(players.get(0).get("avatar"), is(nullValue()));
}
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) Test(org.junit.Test)

Example 2 with PlayerResponses

use of com.faforever.server.client.PlayerResponses in project faf-java-server by FAForever.

the class PlayerResponsesTransformerTest method transformHandleCountryNull.

@Test
@SuppressWarnings("unchecked")
public void transformHandleCountryNull() throws Exception {
    Map<String, Serializable> result = PlayerResponsesTransformer.INSTANCE.transform(new PlayerResponses(Collections.singletonList(new PlayerResponse(1, TEST_USERNAME, null, new PlayerResponse.Player(new Rating(1200d, 200d), new Rating(900d, 100d), 12, null, "FOO")))));
    List<Map<String, Object>> players = (List<Map<String, Object>>) result.get("players");
    assertThat(players.get(0).get("country"), is(""));
}
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) Test(org.junit.Test)

Example 3 with PlayerResponses

use of com.faforever.server.client.PlayerResponses 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 4 with PlayerResponses

use of com.faforever.server.client.PlayerResponses 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 5 with PlayerResponses

use of com.faforever.server.client.PlayerResponses 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

PlayerResponses (com.faforever.server.client.PlayerResponses)5 PlayerResponse (com.faforever.server.player.PlayerResponse)5 Rating (com.faforever.server.player.PlayerResponse.Player.Rating)5 Serializable (java.io.Serializable)5 List (java.util.List)5 Map (java.util.Map)5 Test (org.junit.Test)5 Avatar (com.faforever.server.player.PlayerResponse.Player.Avatar)3