### Question:
ValidationService implements Reloadable { public boolean isEmailFreeForRegistration(String email, CommandSender sender) { return permissionsManager.hasPermission(sender, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS) || dataSource.countAuthsByEmail(email) < settings.getProperty(EmailSettings.MAX_REG_PER_EMAIL); } ValidationService(); @PostConstruct @Override void reload(); ValidationResult validatePassword(String password, String username); boolean validateEmail(String email); boolean isEmailFreeForRegistration(String email, CommandSender sender); boolean isCountryAdmitted(String hostAddress); boolean isUnrestricted(String name); boolean fulfillsNameRestrictions(Player player);  }### Answer:
@Test public void shouldAllowRegistration() { CommandSender sender = mock(CommandSender.class); String email = "my.address@example.org"; given(permissionsManager.hasPermission(sender, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)) .willReturn(false); given(dataSource.countAuthsByEmail(email)).willReturn(2); boolean result = validationService.isEmailFreeForRegistration(email, sender); assertThat(result, equalTo(true)); }
@Test public void shouldRejectEmailWithTooManyAccounts() { CommandSender sender = mock(CommandSender.class); String email = "mail@example.org"; given(permissionsManager.hasPermission(sender, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)) .willReturn(false); given(dataSource.countAuthsByEmail(email)).willReturn(5); boolean result = validationService.isEmailFreeForRegistration(email, sender); assertThat(result, equalTo(false)); }
@Test public void shouldAllowBypassForPresentPermission() { CommandSender sender = mock(CommandSender.class); String email = "mail-address@example.com"; given(permissionsManager.hasPermission(sender, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)) .willReturn(true); given(dataSource.countAuthsByEmail(email)).willReturn(7); boolean result = validationService.isEmailFreeForRegistration(email, sender); assertThat(result, equalTo(true)); }