Search in sources :

Example 21 with User

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

the class SocialServiceTest method onAuthenticationSuccess.

@Test
public void onAuthenticationSuccess() throws Exception {
    User user = (User) new User().setPlayer(new Player().setSocialRelations(Arrays.asList(new SocialRelation(1, null, 10, SocialRelationStatus.FRIEND), new SocialRelation(2, null, 11, SocialRelationStatus.FOE)))).setPassword("pw").setLogin("junit");
    FafUserDetails userDetails = new FafUserDetails(user);
    instance.onPlayerOnlineEvent(new PlayerOnlineEvent(this, userDetails.getPlayer()));
    ArgumentCaptor<SocialRelationListResponse> captor = ArgumentCaptor.forClass(SocialRelationListResponse.class);
    verify(clientService).sendSocialRelations(captor.capture(), any());
    SocialRelationListResponse response = captor.getValue();
    assertThat(response, instanceOf(SocialRelationListResponse.class));
    assertThat(response.getSocialRelations(), hasSize(2));
    assertThat(response.getSocialRelations().get(0), is(new SocialRelationResponse(10, RelationType.FRIEND)));
    assertThat(response.getSocialRelations().get(1), is(new SocialRelationResponse(11, RelationType.FOE)));
}
Also used : SocialRelation(com.faforever.server.entity.SocialRelation) Player(com.faforever.server.entity.Player) User(com.faforever.server.entity.User) FafUserDetails(com.faforever.server.security.FafUserDetails) PlayerOnlineEvent(com.faforever.server.player.PlayerOnlineEvent) SocialRelationResponse(com.faforever.server.social.SocialRelationListResponse.SocialRelationResponse) Test(org.junit.Test)

Aggregations

User (com.faforever.server.entity.User)21 FafUserDetails (com.faforever.server.security.FafUserDetails)12 Test (org.junit.Test)12 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)10 Player (com.faforever.server.entity.Player)9 ClientConnection (com.faforever.server.client.ClientConnection)6 PlayerOnlineEvent (com.faforever.server.player.PlayerOnlineEvent)5 Before (org.junit.Before)5 GroupAssociation (com.faforever.server.entity.GroupAssociation)4 InetAddress (java.net.InetAddress)4 BanDetails (com.faforever.server.entity.BanDetails)2 Game (com.faforever.server.entity.Game)2 Set (java.util.Set)2 ClientService (com.faforever.server.client.ClientService)1 GameResponses (com.faforever.server.client.GameResponses)1 ServerProperties (com.faforever.server.config.ServerProperties)1 Chat (com.faforever.server.config.ServerProperties.Chat)1 Clan (com.faforever.server.entity.Clan)1 ClanMembership (com.faforever.server.entity.ClanMembership)1 SocialRelation (com.faforever.server.entity.SocialRelation)1