Search in sources :

Example 6 with PlayerOnlineEvent

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

PlayerOnlineEvent (com.faforever.server.player.PlayerOnlineEvent)6 User (com.faforever.server.entity.User)5 Player (com.faforever.server.entity.Player)4 FafUserDetails (com.faforever.server.security.FafUserDetails)3 Test (org.junit.Test)3 ClientService (com.faforever.server.client.ClientService)2 GroupAssociation (com.faforever.server.entity.GroupAssociation)2 SocialRelation (com.faforever.server.entity.SocialRelation)2 SocialRelationResponse (com.faforever.server.social.SocialRelationListResponse.SocialRelationResponse)2 Set (java.util.Set)2 Slf4j (lombok.extern.slf4j.Slf4j)2 EventListener (org.springframework.context.event.EventListener)2 Service (org.springframework.stereotype.Service)2 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 SocialRelationStatus (com.faforever.server.entity.SocialRelationStatus)1 ProgrammingError (com.faforever.server.error.ProgrammingError)1