Search in sources :

Example 1 with Avatar

use of com.faforever.server.player.PlayerResponse.Player.Avatar in project faf-java-server by FAForever.

the class V2ServerMessageTransformerTest method player.

@Test
public void player() throws Exception {
    String response = instance.transform(new PlayerResponse(1, "A", "CH", new PlayerResponse.Player(new Rating(900, 120), new Rating(600, 50), 12, new Avatar("http://localhost/avatar.png", "Avatar"), "AA")));
    assertThat(response, is("{\"data\":{\"playerId\":1,\"username\":\"A\",\"country\":\"CH\",\"player\":{\"globalRating\":{\"mean\":900.0,\"deviation\":120.0},\"ladder1v1Rating\":{\"mean\":600.0,\"deviation\":50.0},\"numberOfGames\":12,\"avatar\":{\"url\":\"http://localhost/avatar.png\",\"description\":\"Avatar\"},\"clanTag\":\"AA\"}},\"type\":\"player\"}"));
}
Also used : PlayerResponse(com.faforever.server.player.PlayerResponse) Player(com.faforever.server.game.GameResponse.Player) Rating(com.faforever.server.player.PlayerResponse.Player.Rating) Avatar(com.faforever.server.player.PlayerResponse.Player.Avatar) Test(org.junit.Test)

Example 2 with Avatar

use of com.faforever.server.player.PlayerResponse.Player.Avatar in project faf-java-server by FAForever.

the class V2ServerMessageTransformerTest method loginDetails.

@Test
public void loginDetails() throws Exception {
    String response = instance.transform(new LoginDetailsResponse(new PlayerResponse(1, "A", "CH", new PlayerResponse.Player(new Rating(900, 120), new Rating(600, 50), 12, new Avatar("http://localhost/avatar.png", "Avatar"), "AA"))));
    assertThat(response, is("{\"data\":{\"playerId\":1,\"username\":\"A\",\"country\":\"CH\",\"player\":{\"globalRating\":{\"mean\":900.0,\"deviation\":120.0},\"ladder1v1Rating\":{\"mean\":600.0,\"deviation\":50.0},\"numberOfGames\":12,\"avatar\":{\"url\":\"http://localhost/avatar.png\",\"description\":\"Avatar\"},\"clanTag\":\"AA\"}},\"type\":\"loginDetails\"}"));
}
Also used : PlayerResponse(com.faforever.server.player.PlayerResponse) Rating(com.faforever.server.player.PlayerResponse.Player.Rating) LoginDetailsResponse(com.faforever.server.player.LoginDetailsResponse) Avatar(com.faforever.server.player.PlayerResponse.Player.Avatar) Test(org.junit.Test)

Example 3 with Avatar

use of com.faforever.server.player.PlayerResponse.Player.Avatar in project faf-java-server by FAForever.

the class LoginDetailsServerMessageTransformerTest method transformFull.

@Test
@SuppressWarnings("unchecked")
public void transformFull() throws Exception {
    Map<String, Serializable> result = LoginDetailsResponseTransformer.INSTANCE.transform(new LoginDetailsResponse(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("welcome"));
    assertThat(result.get("id"), is(1));
    assertThat(result.get("login"), is(TEST_USERNAME));
    Map<String, Object> me = (Map<String, Object>) result.get("me");
    assertThat(me.get("id"), is(1));
    assertThat(me.get("login"), is(TEST_USERNAME));
    assertThat(me.get("login"), is(TEST_USERNAME));
    assertThat(me.get("global_rating"), is(new double[] { 1200, 200 }));
    assertThat(me.get("ladder_rating"), is(new double[] { 900, 100 }));
    assertThat(me.get("number_of_games"), is(12));
    Map<String, Serializable> avatarMap = (Map<String, Serializable>) me.get("avatar");
    assertThat(avatarMap.get("url"), is("http://example.com"));
    assertThat(avatarMap.get("tooltip"), is("Tooltip"));
    assertThat(me.get("country"), is("CH"));
    assertThat(me.get("clan"), is("FOO"));
}
Also used : PlayerResponse(com.faforever.server.player.PlayerResponse) Serializable(java.io.Serializable) Rating(com.faforever.server.player.PlayerResponse.Player.Rating) LoginDetailsResponse(com.faforever.server.player.LoginDetailsResponse) Map(java.util.Map) Avatar(com.faforever.server.player.PlayerResponse.Player.Avatar) Test(org.junit.Test)

Example 4 with Avatar

use of com.faforever.server.player.PlayerResponse.Player.Avatar in project faf-java-server by FAForever.

the class LoginDetailsServerMessageTransformerTest method transformHandleLadder1v1RatingNull.

@Test
@SuppressWarnings("unchecked")
public void transformHandleLadder1v1RatingNull() throws Exception {
    Map<String, Serializable> result = LoginDetailsResponseTransformer.INSTANCE.transform(new LoginDetailsResponse(new PlayerResponse(1, TEST_USERNAME, "CH", new PlayerResponse.Player(new Rating(900d, 100d), null, 12, new Avatar("http://example.com", "Tooltip"), "FOO"))));
    Map<String, Object> me = (Map<String, Object>) result.get("me");
    assertThat(me.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) LoginDetailsResponse(com.faforever.server.player.LoginDetailsResponse) Map(java.util.Map) Avatar(com.faforever.server.player.PlayerResponse.Player.Avatar) Test(org.junit.Test)

Example 5 with Avatar

use of com.faforever.server.player.PlayerResponse.Player.Avatar 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]));
}
Also used : PlayerResponse(com.faforever.server.player.PlayerResponse) Serializable(java.io.Serializable) Rating(com.faforever.server.player.PlayerResponse.Player.Rating) LoginDetailsResponse(com.faforever.server.player.LoginDetailsResponse) 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