### Question:
AsynchronousUnregister implements AsynchronousProcess { public void adminUnregister(CommandSender initiator, String name, Player player) { if (dataSource.removeAuth(name)) { performPostUnregisterActions(name, player); bukkitService.createAndCallEvent(isAsync -> new UnregisterByAdminEvent(player, name, isAsync, initiator)); if (initiator == null) { ConsoleLogger.info(name + " was unregistered"); } else { ConsoleLogger.info(name + " was unregistered by " + initiator.getName()); service.send(initiator, MessageKey.UNREGISTERED_SUCCESS); } } else if (initiator != null) { service.send(initiator, MessageKey.ERROR); } } AsynchronousUnregister(); void unregister(Player player, String password); void adminUnregister(CommandSender initiator, String name, Player player);  }### Answer:
@Test public void shouldPerformAdminUnregister() { Player player = mock(Player.class); String name = "Frank21"; given(player.isOnline()).willReturn(true); given(dataSource.removeAuth(name)).willReturn(true); given(service.getProperty(RegistrationSettings.FORCE)).willReturn(true); given(service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)).willReturn(false); CommandSender initiator = mock(CommandSender.class); setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask(bukkitService); asynchronousUnregister.adminUnregister(initiator, name, player); verify(service).send(player, MessageKey.UNREGISTERED_SUCCESS); verify(service).send(initiator, MessageKey.UNREGISTERED_SUCCESS); verify(dataSource).removeAuth(name); verify(playerCache).removePlayer(name); verify(teleportationService).teleportOnJoin(player); verifyCalledUnregisterEventFor(player); verify(commandManager).runCommandsOnUnregister(player); verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); }
@Test public void shouldPerformAdminUnregisterWithoutInitiatorOrPlayer() { String name = "billy"; given(dataSource.removeAuth(name)).willReturn(true); asynchronousUnregister.adminUnregister(null, name, null); verify(dataSource).removeAuth(name); verify(playerCache).removePlayer(name); verifyZeroInteractions(teleportationService); verifyCalledUnregisterEventFor(null); verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); }
@Test public void shouldHandleDatabaseErrorForAdminUnregister() { String name = "TtOoLl"; CommandSender initiator = mock(CommandSender.class); given(dataSource.removeAuth(name)).willReturn(false); asynchronousUnregister.adminUnregister(initiator, name, null); verify(dataSource).removeAuth(name); verify(service).send(initiator, MessageKey.ERROR); verifyZeroInteractions(playerCache, teleportationService, bukkitService, bungeeSender); }