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\"}"));
}
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\"}"));
}
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"));
}
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]));
}
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]));
}
Aggregations