Search in sources :

Example 1 with Clan

use of com.faforever.server.entity.Clan 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 Clan

use of com.faforever.server.entity.Clan in project faf-java-server by FAForever.

the class ChatServiceTest method testJoinChannels.

@SuppressWarnings("unchecked")
private void testJoinChannels(Group group, String... expectedChannels) {
    User user = (User) new User().setPassword("pw").setGroupAssociation(group == null ? null : new GroupAssociation().setGroup(group)).setLogin("junit");
    Player player = new Player().setUser(user).setClanMemberships(Collections.singletonList(new ClanMembership().setClan(new Clan().setTag("junit"))));
    instance.onPlayerOnlineEvent(new PlayerOnlineEvent(this, player));
    ArgumentCaptor<Set<String>> captor = ArgumentCaptor.forClass((Class) Set.class);
    verify(clientService).sendChatChannels(captor.capture(), any());
    Set<String> channels = captor.getValue();
    assertThat(channels, containsInAnyOrder(expectedChannels));
}
Also used : Player(com.faforever.server.entity.Player) User(com.faforever.server.entity.User) GroupAssociation(com.faforever.server.entity.GroupAssociation) Set(java.util.Set) Clan(com.faforever.server.entity.Clan) ClanMembership(com.faforever.server.entity.ClanMembership) PlayerOnlineEvent(com.faforever.server.player.PlayerOnlineEvent)

Aggregations

Clan (com.faforever.server.entity.Clan)2 ClanMembership (com.faforever.server.entity.ClanMembership)2 Avatar (com.faforever.server.entity.Avatar)1 AvatarAssociation (com.faforever.server.entity.AvatarAssociation)1 GlobalRating (com.faforever.server.entity.GlobalRating)1 GroupAssociation (com.faforever.server.entity.GroupAssociation)1 Ladder1v1Rating (com.faforever.server.entity.Ladder1v1Rating)1 Player (com.faforever.server.entity.Player)1 User (com.faforever.server.entity.User)1 PlayerOnlineEvent (com.faforever.server.player.PlayerOnlineEvent)1 PlayerResponse (com.faforever.server.player.PlayerResponse)1 Set (java.util.Set)1 Test (org.junit.Test)1