### Question:
Respawn { public void markForRespawn(GamePlayer gamePlayer) { GamePlayerStatus status = gamePlayer.getStatus(); status.setSpectator(true); taskFactory.newSyncDelayedTask(() -> { status.setSpectator(false); game.getMap().teleportPlayer(gamePlayer.getId()); }, gameOptions.getRespawnTime()).execute(); }  void markForRespawn(GamePlayer gamePlayer);  }### Answer:
@Test public void markForRespawn() { Game game = mock(Game.class); GameMap gameMap = mock(GameMap.class); when(game.getMap()).thenReturn(gameMap); GameOptions gameOptions = mock(GameOptions.class); TaskFactory taskFactory = mock(TaskFactory.class); Respawn respawn = new Respawn(game, taskFactory, gameOptions); when(taskFactory.newSyncDelayedTask(any(Runnable.class), anyInt())).thenAnswer(invocationOnMock -> (Task) () -> { Runnable argument = invocationOnMock.getArgument(0); argument.run(); }); UUID uuid = UUID.randomUUID(); GamePlayer gamePlayer = mock(GamePlayer.class); when(gamePlayer.getId()).thenReturn(uuid); GamePlayerStatus gamePlayerStatus = mock(GamePlayerStatus.class); when(gamePlayer.getStatus()).thenReturn(gamePlayerStatus); respawn.markForRespawn(gamePlayer); verify(gamePlayerStatus).setSpectator(eq(true)); verify(gamePlayerStatus).setSpectator(eq(false)); verify(gameMap).teleportPlayer(eq(uuid)); }