use of com.faforever.server.client.GameResponses in project faf-java-server by FAForever.
the class GameService method onPlayerOnlineEvent.
@EventListener
public void onPlayerOnlineEvent(PlayerOnlineEvent event) {
counterService.increment(String.format(Metrics.PLAYER_GAMES_STATE_FORMAT, event.getPlayer().getGameState()));
clientService.sendGameList(new GameResponses(activeGamesById.values().stream().map(this::toResponse).collect(Collectors.toList())), event.getPlayer());
}
use of com.faforever.server.client.GameResponses in project faf-java-server by FAForever.
the class GameServiceTest method onAuthenticationSuccess.
@Test
@SuppressWarnings("unchecked")
public void onAuthenticationSuccess() throws Exception {
player1.setCurrentGame(null);
instance.createGame("Test game", FAF_TECHNICAL_NAME, MAP_NAME, null, GameVisibility.PUBLIC, GAME_MIN_RATING, GAME_MAX_RATING, player1);
TestingAuthenticationToken authentication = new TestingAuthenticationToken("JUnit", "foo");
authentication.setDetails(new TestingAuthenticationToken(new FafUserDetails((User) new User().setPlayer(player2).setPassword("pw").setLogin("JUnit")), null));
instance.onPlayerOnlineEvent(new PlayerOnlineEvent(this, player2));
ArgumentCaptor<GameResponses> captor = ArgumentCaptor.forClass((Class) Collection.class);
verify(clientService).sendGameList(captor.capture(), eq(player2));
GameResponses games = captor.getValue();
assertThat(games.getResponses(), hasSize(1));
assertThat(games.getResponses().iterator().next().getTitle(), is("Test game"));
}
Aggregations