### Question:
OnJoinVerifier implements Reloadable { public void checkAntibot(JoiningPlayer joiningPlayer, boolean isAuthAvailable) throws FailedVerificationException { if (isAuthAvailable || permissionsManager.hasPermission(joiningPlayer, PlayerStatePermission.BYPASS_ANTIBOT)) { return; } if (antiBotService.shouldKick()) { antiBotService.addPlayerKick(joiningPlayer.getName()); throw new FailedVerificationException(MessageKey.KICK_ANTIBOT); } } OnJoinVerifier(); @PostConstruct @Override void reload(); void checkAntibot(JoiningPlayer joiningPlayer, boolean isAuthAvailable); void checkKickNonRegistered(boolean isAuthAvailable); void checkIsValidName(String name); boolean refusePlayerForFullServer(PlayerLoginEvent event); void checkNameCasing(String connectingName, PlayerAuth auth); void checkPlayerCountry(JoiningPlayer joiningPlayer, String address,
                                   boolean isAuthAvailable); void checkSingleSession(String name);  }### Answer:
@Test public void shouldAllowUser() throws FailedVerificationException { JoiningPlayer joiningPlayer = JoiningPlayer.fromName("Bobby"); boolean isAuthAvailable = false; given(permissionsManager.hasPermission(joiningPlayer, PlayerStatePermission.BYPASS_ANTIBOT)).willReturn(false); given(antiBotService.shouldKick()).willReturn(false); onJoinVerifier.checkAntibot(joiningPlayer, isAuthAvailable); verify(permissionsManager).hasPermission(joiningPlayer, PlayerStatePermission.BYPASS_ANTIBOT); verify(antiBotService).shouldKick(); }
@Test public void shouldAllowUserWithAuth() throws FailedVerificationException { JoiningPlayer joiningPlayer = JoiningPlayer.fromName("Lacey"); boolean isAuthAvailable = true; onJoinVerifier.checkAntibot(joiningPlayer, isAuthAvailable); verifyZeroInteractions(permissionsManager, antiBotService); }
@Test public void shouldAllowUserWithBypassPermission() throws FailedVerificationException { JoiningPlayer joiningPlayer = JoiningPlayer.fromName("Steward"); boolean isAuthAvailable = false; given(permissionsManager.hasPermission(joiningPlayer, PlayerStatePermission.BYPASS_ANTIBOT)).willReturn(true); onJoinVerifier.checkAntibot(joiningPlayer, isAuthAvailable); verify(permissionsManager).hasPermission(joiningPlayer, PlayerStatePermission.BYPASS_ANTIBOT); verifyZeroInteractions(antiBotService); }
@Test public void shouldKickUserForFailedAntibotCheck() throws FailedVerificationException { JoiningPlayer joiningPlayer = JoiningPlayer.fromName("D3"); boolean isAuthAvailable = false; given(permissionsManager.hasPermission(joiningPlayer, PlayerStatePermission.BYPASS_ANTIBOT)).willReturn(false); given(antiBotService.shouldKick()).willReturn(true); try { onJoinVerifier.checkAntibot(joiningPlayer, isAuthAvailable); fail("Expected exception to be thrown"); } catch (FailedVerificationException e) { verify(permissionsManager).hasPermission(joiningPlayer, PlayerStatePermission.BYPASS_ANTIBOT); verify(antiBotService).shouldKick(); } }