### Question:
OnJoinVerifier implements Reloadable { public void checkNameCasing(String connectingName, PlayerAuth auth) throws FailedVerificationException { if (auth != null && settings.getProperty(RegistrationSettings.PREVENT_OTHER_CASE)) { String realName = auth.getRealName(); if (StringUtils.isEmpty(realName) || "Player".equals(realName)) { dataSource.updateRealName(connectingName.toLowerCase(), connectingName); } else if (!realName.equals(connectingName)) { throw new FailedVerificationException(MessageKey.INVALID_NAME_CASE, realName, connectingName); } } } 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 shouldAllowProperlyCasedName() throws FailedVerificationException { String name = "Bobby"; PlayerAuth auth = PlayerAuth.builder().name("bobby").realName("Bobby").build(); given(settings.getProperty(RegistrationSettings.PREVENT_OTHER_CASE)).willReturn(true); onJoinVerifier.checkNameCasing(name, auth); verifyZeroInteractions(dataSource); }
@Test public void shouldRejectNameWithWrongCasing() throws FailedVerificationException { String name = "Tester"; PlayerAuth auth = PlayerAuth.builder().name("tester").realName("testeR").build(); given(settings.getProperty(RegistrationSettings.PREVENT_OTHER_CASE)).willReturn(true); expectValidationExceptionWith(MessageKey.INVALID_NAME_CASE, "testeR", "Tester"); onJoinVerifier.checkNameCasing(name, auth); verifyZeroInteractions(dataSource); }
@Test public void shouldUpdateMissingRealName() throws FailedVerificationException { String name = "Authme"; PlayerAuth auth = PlayerAuth.builder().name("authme").realName("").build(); given(settings.getProperty(RegistrationSettings.PREVENT_OTHER_CASE)).willReturn(true); onJoinVerifier.checkNameCasing(name, auth); verify(dataSource).updateRealName("authme", "Authme"); }
@Test public void shouldUpdateDefaultRealName() throws FailedVerificationException { String name = "SOMEONE"; PlayerAuth auth = PlayerAuth.builder().name("someone").realName("Player").build(); given(settings.getProperty(RegistrationSettings.PREVENT_OTHER_CASE)).willReturn(true); onJoinVerifier.checkNameCasing(name, auth); verify(dataSource).updateRealName("someone", "SOMEONE"); }
@Test public void shouldAcceptCasingMismatchForDisabledSetting() throws FailedVerificationException { String name = "Test"; PlayerAuth auth = PlayerAuth.builder().name("test").realName("TEST").build(); given(settings.getProperty(RegistrationSettings.PREVENT_OTHER_CASE)).willReturn(false); onJoinVerifier.checkNameCasing(name, auth); verifyZeroInteractions(dataSource); }
@Test public void shouldAcceptNameForUnregisteredAccount() throws FailedVerificationException { String name = "MyPlayer"; PlayerAuth auth = null; onJoinVerifier.checkNameCasing(name, auth); verifyZeroInteractions(dataSource); }