### Question:
TeleportationService implements Reloadable { public void teleportNewPlayerToFirstSpawn(final Player player) { if (settings.getProperty(RestrictionSettings.NO_TELEPORT)) { return; } Location firstSpawn = spawnLoader.getFirstSpawn(); if (firstSpawn == null) { return; } if (!player.hasPlayedBefore() || !dataSource.isAuthAvailable(player.getName())) { performTeleportation(player, new FirstSpawnTeleportEvent(player, firstSpawn)); } } TeleportationService(); @PostConstruct @Override void reload(); void teleportOnJoin(final Player player); Location prepareOnJoinSpawnLocation(final Player player); void teleportNewPlayerToFirstSpawn(final Player player); void teleportOnLogin(final Player player, PlayerAuth auth, LimboPlayer limbo);  }### Answer:
@Test public void shouldTeleportPlayerToFirstSpawn() { Player player = mock(Player.class); given(player.hasPlayedBefore()).willReturn(false); given(player.isOnline()).willReturn(true); Location firstSpawn = mockLocation(); given(spawnLoader.getFirstSpawn()).willReturn(firstSpawn); setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask(bukkitService); teleportationService.teleportNewPlayerToFirstSpawn(player); verify(player).teleport(firstSpawn); verify(bukkitService).callEvent(any(FirstSpawnTeleportEvent.class)); verify(spawnLoader).getFirstSpawn(); verify(spawnLoader, never()).getSpawnLocation(any(Player.class)); }
@Test public void shouldNotTeleportNewPlayer() { Player player = mock(Player.class); given(spawnLoader.getFirstSpawn()).willReturn(null); teleportationService.teleportNewPlayerToFirstSpawn(player); verify(player, never()).teleport(any(Location.class)); verify(spawnLoader).getFirstSpawn(); verify(spawnLoader, never()).getSpawnLocation(any(Player.class)); verifyZeroInteractions(bukkitService); }
@Test public void shouldNotTeleportPlayerToFirstSpawnIfNoTeleportEnabled() { Player player = mock(Player.class); given(settings.getProperty(RestrictionSettings.NO_TELEPORT)).willReturn(true); teleportationService.teleportNewPlayerToFirstSpawn(player); verify(player, never()).teleport(any(Location.class)); verifyZeroInteractions(bukkitService); }
@Test public void shouldNotTeleportNotNewPlayerToFirstSpawn() { Player player = mock(Player.class); given(settings.getProperty(RestrictionSettings.NO_TELEPORT)).willReturn(false); teleportationService.teleportNewPlayerToFirstSpawn(player); verify(player, never()).teleport(any(Location.class)); verifyZeroInteractions(bukkitService); }