### Question:
OnJoinVerifier implements Reloadable { public void checkSingleSession(String name) throws FailedVerificationException { if (!settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)) { return; } Player onlinePlayer = bukkitService.getPlayerExact(name); if (onlinePlayer != null) { throw new FailedVerificationException(MessageKey.USERNAME_ALREADY_ONLINE_ERROR); } } 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 shouldAcceptNameThatIsNotOnline() throws FailedVerificationException { String name = "bobby"; given(settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)).willReturn(true); given(bukkitService.getPlayerExact("bobby")).willReturn(null); onJoinVerifier.checkSingleSession(name); verify(bukkitService).getPlayerExact(name); }
@Test public void shouldRejectNameAlreadyOnline() throws FailedVerificationException { String name = "Charlie"; Player onlinePlayer = mock(Player.class); given(bukkitService.getPlayerExact("Charlie")).willReturn(onlinePlayer); given(settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)).willReturn(true); expectValidationExceptionWith(MessageKey.USERNAME_ALREADY_ONLINE_ERROR); onJoinVerifier.checkSingleSession(name); }
@Test public void shouldAcceptAlreadyOnlineNameForDisabledSetting() throws FailedVerificationException { String name = "Felipe"; given(settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)).willReturn(false); onJoinVerifier.checkSingleSession(name); verifyZeroInteractions(bukkitService); }