Search in sources :

Example 1 with PlayerResponse

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

the class ClientServiceTest method sendUserDetails.

@Test
public void sendUserDetails() throws Exception {
    Avatar avatar = new Avatar().setUrl("http://example.com").setDescription("Tooltip");
    player.setAvailableAvatars(Collections.singletonList(new AvatarAssociation().setAvatar(avatar).setPlayer(player).setSelected(true))).setGlobalRating((GlobalRating) new GlobalRating().setNumGames(12).setMean(1100d).setDeviation(100d)).setLadder1v1Rating((Ladder1v1Rating) new Ladder1v1Rating().setMean(900d).setDeviation(50d)).setClanMemberships(Collections.singletonList(new ClanMembership().setClan(new Clan().setTag("FOO")))).setCountry("CH").setLogin("JUnit").setId(5);
    instance.sendLoginDetails(player, player);
    ArgumentCaptor<PlayerResponse> captor = ArgumentCaptor.forClass(PlayerResponse.class);
    verify(clientGateway).send(captor.capture(), any());
    PlayerResponse response = captor.getValue();
    assertThat(response.getPlayerId(), is(5));
    assertThat(response.getUsername(), is("JUnit"));
    assertThat(response.getPlayer().getAvatar().getDescription(), is("Tooltip"));
    assertThat(response.getPlayer().getAvatar().getUrl(), is("http://example.com"));
    assertThat(response.getPlayer().getGlobalRating().getMean(), is(1100d));
    assertThat(response.getPlayer().getGlobalRating().getDeviation(), is(100d));
    assertThat(response.getPlayer().getLadder1v1Rating().getMean(), is(900d));
    assertThat(response.getPlayer().getLadder1v1Rating().getDeviation(), is(50d));
    assertThat(response.getPlayer().getNumberOfGames(), is(12));
    assertThat(response.getPlayer().getClanTag(), is("FOO"));
    assertThat(response.getCountry(), is("CH"));
}
Also used : PlayerResponse(com.faforever.server.player.PlayerResponse) Clan(com.faforever.server.entity.Clan) GlobalRating(com.faforever.server.entity.GlobalRating) Ladder1v1Rating(com.faforever.server.entity.Ladder1v1Rating) ClanMembership(com.faforever.server.entity.ClanMembership) AvatarAssociation(com.faforever.server.entity.AvatarAssociation) Avatar(com.faforever.server.entity.Avatar) Test(org.junit.Test)

Example 2 with PlayerResponse

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

the class LoginDetailsServerMessageTransformerTest method transformHandleAvatarNull.

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

Example 3 with PlayerResponse

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

the class LoginDetailsServerMessageTransformerTest method transformHandleCountryNull.

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

Example 4 with PlayerResponse

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

use of com.faforever.server.player.PlayerResponse 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)

Aggregations

PlayerResponse (com.faforever.server.player.PlayerResponse)15 Test (org.junit.Test)14 Rating (com.faforever.server.player.PlayerResponse.Player.Rating)13 Serializable (java.io.Serializable)10 Map (java.util.Map)10 Avatar (com.faforever.server.player.PlayerResponse.Player.Avatar)8 LoginDetailsResponse (com.faforever.server.player.LoginDetailsResponse)6 PlayerResponses (com.faforever.server.client.PlayerResponses)5 List (java.util.List)5 AvatarAssociation (com.faforever.server.entity.AvatarAssociation)2 GlobalRating (com.faforever.server.entity.GlobalRating)2 Avatar (com.faforever.server.entity.Avatar)1 Clan (com.faforever.server.entity.Clan)1 ClanMembership (com.faforever.server.entity.ClanMembership)1 Ladder1v1Rating (com.faforever.server.entity.Ladder1v1Rating)1 Player (com.faforever.server.entity.Player)1 Player (com.faforever.server.game.GameResponse.Player)1 CompletableFuture (java.util.concurrent.CompletableFuture)1