Search in sources :

Example 21 with Player

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

the class SocialServiceTest method onAuthenticationSuccessNullRelations.

@Test
public void onAuthenticationSuccessNullRelations() throws Exception {
    User user = (User) new User().setPlayer(new Player().setSocialRelations(null)).setPassword("pw").setLogin("junit");
    FafUserDetails userDetails = new FafUserDetails(user);
    instance.onPlayerOnlineEvent(new PlayerOnlineEvent(this, userDetails.getPlayer()));
    verify(clientService, never()).sendSocialRelations(any(), any());
}
Also used : Player(com.faforever.server.entity.Player) User(com.faforever.server.entity.User) FafUserDetails(com.faforever.server.security.FafUserDetails) PlayerOnlineEvent(com.faforever.server.player.PlayerOnlineEvent) Test(org.junit.Test)

Example 22 with Player

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

the class SocialServiceTest method setUp.

@Before
public void setUp() throws Exception {
    requester = (Player) new Player().setId(1);
    instance = new SocialService(socialRelationRepository, clientService);
}
Also used : Player(com.faforever.server.entity.Player) Before(org.junit.Before)

Example 23 with Player

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

the class TeamKillServiceTest method reportTeamKillWhenKillerDoesntExist.

@Test
public void reportTeamKillWhenKillerDoesntExist() throws Exception {
    Player player = new Player();
    player.setCurrentGame(new Game());
    player.setId(1);
    when(playerService.getOnlinePlayer(player.getId())).thenReturn(Optional.of(player));
    instance.reportTeamKill(player, Duration.ofMinutes(28), 991234, player.getId());
    verifyZeroInteractions(teamKillRepository);
}
Also used : Player(com.faforever.server.entity.Player) Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 24 with Player

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

the class TeamKillServiceTest method reportTeamKill.

@Test
public void reportTeamKill() throws Exception {
    Game game = new Game();
    game.setId(10);
    Player player = (Player) new Player().setCurrentGame(game).setId(1);
    Player killer = (Player) new Player().setId(2);
    when(playerService.getOnlinePlayer(player.getId())).thenReturn(Optional.of(player));
    when(playerService.getOnlinePlayer(killer.getId())).thenReturn(Optional.of(killer));
    instance.reportTeamKill(player, Duration.ofMinutes(28), killer.getId(), player.getId());
    ArgumentCaptor<TeamKill> captor = ArgumentCaptor.forClass(TeamKill.class);
    verify(teamKillRepository).save(captor.capture());
    TeamKill teamKill = captor.getValue();
    assertThat(teamKill.getGameId(), is(game.getId()));
    assertThat(teamKill.getTeamKiller(), is(killer.getId()));
    assertThat(teamKill.getVictim(), is(player.getId()));
    assertThat(teamKill.getGameTime(), is((int) Duration.ofMinutes(28).getSeconds()));
    assertThat(teamKill.getReportedAt().after(Timestamp.from(Instant.now().minusSeconds(10))), is(true));
}
Also used : Player(com.faforever.server.entity.Player) Game(com.faforever.server.entity.Game) TeamKill(com.faforever.server.entity.TeamKill) Test(org.junit.Test)

Example 25 with Player

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

the class TeamKillServiceTest method reportTeamKillWithoutGame.

@Test
public void reportTeamKillWithoutGame() throws Exception {
    Player player = (Player) new Player().setId(1);
    Player killer = (Player) new Player().setId(2);
    when(playerService.getOnlinePlayer(player.getId())).thenReturn(Optional.of(player));
    when(playerService.getOnlinePlayer(killer.getId())).thenReturn(Optional.of(killer));
    instance.reportTeamKill(player, Duration.ofMinutes(28), killer.getId(), player.getId());
    verifyZeroInteractions(teamKillRepository);
}
Also used : Player(com.faforever.server.entity.Player) 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