### Question:
PurgePlayerCommand implements ExecutableCommand { @Override public void executeCommand(CommandSender sender, List<String> arguments) { String option = arguments.size() > 1 ? arguments.get(1) : null; bukkitService.runTaskOptionallyAsync( () -> executeCommand(sender, arguments.get(0), option)); }  @Override void executeCommand(CommandSender sender, List<String> arguments);  }### Answer:
@Test public void shouldNotExecutePurgeForRegisteredPlayer() { String name = "Bobby"; given(dataSource.isAuthAvailable(name)).willReturn(true); CommandSender sender = mock(CommandSender.class); setBukkitServiceToRunTaskOptionallyAsync(bukkitService); command.executeCommand(sender, singletonList(name)); verify(sender).sendMessage(argThat(containsString("This player is still registered"))); verifyZeroInteractions(purgeExecutor); }
@Test public void shouldExecutePurge() { String name = "Frank"; given(dataSource.isAuthAvailable(name)).willReturn(false); OfflinePlayer player = mock(OfflinePlayer.class); given(bukkitService.getOfflinePlayer(name)).willReturn(player); CommandSender sender = mock(CommandSender.class); setBukkitServiceToRunTaskOptionallyAsync(bukkitService); command.executeCommand(sender, singletonList(name)); verify(dataSource).isAuthAvailable(name); verify(purgeExecutor).executePurge(singletonList(player), singletonList(name.toLowerCase())); }
@Test public void shouldExecutePurgeOfRegisteredPlayer() { String name = "GhiJKlmn7"; OfflinePlayer player = mock(OfflinePlayer.class); given(bukkitService.getOfflinePlayer(name)).willReturn(player); CommandSender sender = mock(CommandSender.class); setBukkitServiceToRunTaskOptionallyAsync(bukkitService); command.executeCommand(sender, asList(name, "force")); verify(purgeExecutor).executePurge(singletonList(player), singletonList(name.toLowerCase())); }