@Test public void onDropOut() { Game game = mock(Game.class); Teams teams = mock(Teams.class); GamePlayerStorage<TeamPlayer> storage = mock(GamePlayerStorage.class); UUID uuid = UUID.randomUUID(); PlayerDropOutEvent dropOutEvent = new PlayerDropOutEvent(uuid); TeamDropOutListener dropOutListener = new TeamDropOutListener(game, teams, storage); TeamPlayer teamPlayer = mock(TeamPlayer.class); when(teamPlayer.getTeam()).thenAnswer(invocationOnMock -> { Team team = mock(Team.class); when(team.isAlive()).thenReturn(false); return team; }); when(teams.getAliveTeams()).thenReturn(1); when(storage.getPlayer(eq(uuid))).thenReturn(teamPlayer); dropOutListener.onDropOut(dropOutEvent); verify(game).end(); }
@EventHandler public void onDropOut(PlayerDropOutEvent event) { TeamPlayer player = teamPlayerStorage.getPlayer(event.getPlayerId()); if (!player.getTeam().isAlive()) { if (teams.getAliveTeams() == 1) { game.end(); } } }
TeamDropOutListener implements Listener { @EventHandler public void onDropOut(PlayerDropOutEvent event) { TeamPlayer player = teamPlayerStorage.getPlayer(event.getPlayerId()); if (!player.getTeam().isAlive()) { if (teams.getAliveTeams() == 1) { game.end(); } } } }
TeamDropOutListener implements Listener { @EventHandler public void onDropOut(PlayerDropOutEvent event) { TeamPlayer player = teamPlayerStorage.getPlayer(event.getPlayerId()); if (!player.getTeam().isAlive()) { if (teams.getAliveTeams() == 1) { game.end(); } } }  }
TeamDropOutListener implements Listener { @EventHandler public void onDropOut(PlayerDropOutEvent event) { TeamPlayer player = teamPlayerStorage.getPlayer(event.getPlayerId()); if (!player.getTeam().isAlive()) { if (teams.getAliveTeams() == 1) { game.end(); } } }  @EventHandler void onDropOut(PlayerDropOutEvent event); }
TeamDropOutListener implements Listener { @EventHandler public void onDropOut(PlayerDropOutEvent event) { TeamPlayer player = teamPlayerStorage.getPlayer(event.getPlayerId()); if (!player.getTeam().isAlive()) { if (teams.getAliveTeams() == 1) { game.end(); } } }  @EventHandler void onDropOut(PlayerDropOutEvent event);  }