Search in sources :

Example 71 with Player

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

Example 72 with Player

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

the class ArmyStatisticsServiceTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() {
    instance = new ArmyStatisticsService(achievementService, eventService, clientService, modService);
    player = new Player();
    player.setLogin("TestUser");
    player.setId(42);
    game = new Game();
    game.setId(1);
    unitStats = new ArmyStatistics.CategoryStats().setAir(new ArmyStatistics.UnitStats()).setLand(new ArmyStatistics.UnitStats()).setNaval(new ArmyStatistics.UnitStats()).setExperimental(new ArmyStatistics.UnitStats()).setCdr(new ArmyStatistics.UnitStats()).setTech1(new ArmyStatistics.UnitStats()).setTech2(new ArmyStatistics.UnitStats()).setTech3(new ArmyStatistics.UnitStats()).setEngineer(new ArmyStatistics.UnitStats()).setTransportation(new ArmyStatistics.UnitStats()).setSacu(new ArmyStatistics.UnitStats());
    achievementUpdates = new ArrayList<>();
    eventUpdates = new ArrayList<>();
    doAnswer(invocation -> {
        achievementUpdates.addAll((Collection<? extends AchievementUpdate>) invocation.getArguments()[0]);
        return CompletableFuture.completedFuture(null);
    }).when(achievementService).executeBatchUpdate(any());
    doAnswer(invocation -> {
        eventUpdates.addAll((Collection<? extends EventUpdate>) invocation.getArguments()[0]);
        return CompletableFuture.completedFuture(null);
    }).when(eventService).executeBatchUpdate(any());
}
Also used : Player(com.faforever.server.entity.Player) Game(com.faforever.server.entity.Game) Before(org.junit.Before)

Example 73 with Player

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

the class LegacyServicesActivatorsTest method loginRequestCallsUniqueIdService.

@Test
public void loginRequestCallsUniqueIdService() throws Exception {
    createAuthentication(new Player());
    instance.loginRequest(new LegacyLoginRequest("JUnit", "password", "uniqueId"), clientConnection);
    verify(uniqueIdService).verify(any(), eq("uniqueId"));
}
Also used : Player(com.faforever.server.entity.Player) LegacyLoginRequest(com.faforever.server.client.LegacyLoginRequest) Test(org.junit.Test)

Aggregations

Player (com.faforever.server.entity.Player)73 Test (org.junit.Test)38 Game (com.faforever.server.entity.Game)25 Before (org.junit.Before)13 ServerProperties (com.faforever.server.config.ServerProperties)11 GamePlayerStats (com.faforever.server.entity.GamePlayerStats)11 PlayerOnlineEvent (com.faforever.server.player.PlayerOnlineEvent)11 List (java.util.List)11 Slf4j (lombok.extern.slf4j.Slf4j)11 Service (org.springframework.stereotype.Service)11 ClientService (com.faforever.server.client.ClientService)10 ConnectionAware (com.faforever.server.client.ConnectionAware)10 FeaturedMod (com.faforever.server.entity.FeaturedMod)10 Ladder1v1Rating (com.faforever.server.entity.Ladder1v1Rating)10 Optional (java.util.Optional)10 GlobalRating (com.faforever.server.entity.GlobalRating)9 ModService (com.faforever.server.mod.ModService)9 VisibleForTesting (com.google.common.annotations.VisibleForTesting)9 Duration (java.time.Duration)9 Map (java.util.Map)9