Search in sources :

Example 1 with Player

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

the class MatchMakerServiceTest method startSearchBanned.

@Test
public void startSearchBanned() throws Exception {
    Player player = new Player();
    player.setMatchMakerBanDetails(new MatchMakerBanDetails());
    expectedException.expect(requestExceptionWithCode(ErrorCode.BANNED_FROM_MATCH_MAKER));
    instance.submitSearch(player, Faction.CYBRAN, QUEUE_NAME);
}
Also used : MatchMakerBanDetails(com.faforever.server.entity.MatchMakerBanDetails) Player(com.faforever.server.entity.Player) Test(org.junit.Test)

Example 2 with Player

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

the class MatchMakerServiceTest method submitSearchTwoPlayersDontMatchIfRatingsTooFarApart.

/**
 * Tests whether two players whose ratings are too far apart don't get matched.
 */
@Test
public void submitSearchTwoPlayersDontMatchIfRatingsTooFarApart() throws Exception {
    Player player1 = (Player) new Player().setLadder1v1Rating((Ladder1v1Rating) new Ladder1v1Rating().setMean(300d).setDeviation(50d)).setLogin(LOGIN_PLAYER_1).setId(1);
    Player player2 = (Player) new Player().setLadder1v1Rating((Ladder1v1Rating) new Ladder1v1Rating().setMean(1300d).setDeviation(50d)).setLogin(LOGIN_PLAYER_2).setId(2);
    instance.submitSearch(player1, Faction.CYBRAN, QUEUE_NAME);
    instance.submitSearch(player2, Faction.AEON, QUEUE_NAME);
    instance.processPools();
    verify(gameService, never()).createGame(any(), any(), any(), any(), any(), anyInt(), anyInt(), any());
    verify(gameService, never()).joinGame(anyInt(), eq(null), any());
}
Also used : Player(com.faforever.server.entity.Player) Ladder1v1Rating(com.faforever.server.entity.Ladder1v1Rating) Test(org.junit.Test)

Example 3 with Player

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

the class MatchMakerServiceTest method submitSearchTwoFreshPlayersDontMatchImmediately.

/**
 * Tests whether two players who never played a game (and thus have no rating associated) don't match immediately,
 * because such players always have a low game quality.
 */
@Test
public void submitSearchTwoFreshPlayersDontMatchImmediately() throws Exception {
    Player player1 = (Player) new Player().setLogin(LOGIN_PLAYER_1).setId(1);
    Player player2 = (Player) new Player().setLogin(LOGIN_PLAYER_2).setId(2);
    properties.getMatchMaker().setAcceptableQualityWaitTime(10);
    instance.submitSearch(player1, Faction.CYBRAN, QUEUE_NAME);
    instance.submitSearch(player2, Faction.AEON, QUEUE_NAME);
    instance.processPools();
    verify(gameService, never()).createGame(any(), any(), any(), any(), any(), anyInt(), anyInt(), any());
    verify(gameService, never()).joinGame(anyInt(), eq(null), any());
}
Also used : Player(com.faforever.server.entity.Player) Test(org.junit.Test)

Example 4 with Player

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

the class MatchMakerServiceTest method startSearchEmptyQueue.

@Test
public void startSearchEmptyQueue() throws Exception {
    FeaturedMod featuredMod = new FeaturedMod();
    when(modService.getFeaturedMod(1)).thenReturn(Optional.of(featuredMod));
    when(modService.isLadder1v1(featuredMod)).thenReturn(true);
    instance.submitSearch(new Player(), Faction.CYBRAN, QUEUE_NAME);
    instance.processPools();
    verifyZeroInteractions(gameService);
}
Also used : Player(com.faforever.server.entity.Player) FeaturedMod(com.faforever.server.entity.FeaturedMod) Test(org.junit.Test)

Example 5 with Player

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

the class MatchMakerServiceTest method startSearchAlreadyInGame.

@Test
public void startSearchAlreadyInGame() throws Exception {
    Player player = new Player();
    player.setCurrentGame(new Game());
    expectedException.expect(requestExceptionWithCode(ErrorCode.ALREADY_IN_GAME));
    instance.submitSearch(player, Faction.CYBRAN, QUEUE_NAME);
}
Also used : Player(com.faforever.server.entity.Player) Game(com.faforever.server.entity.Game) 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