### Question:
Player extends PersistentEntity { public void setEmail(String email) { this.email = email; } Player(); @PostLoad void postLoad(); PaymentServiceProvider getPaymentServiceProviderWithCode(PspCode pspCode); PaymentServiceProvider getPaymentServiceProviderWithCode(String pspCodeString); boolean isBlocked(); void setBlocked(boolean blocked); boolean isNew(); @Override void validate(); void validateRegistrationFields(); void validateLoginFields(); String getPwHash(); void setPwHash(final String pwHash); String getEmail(); void setEmail(String email); void addRole(RoleId roleId); Set<RoleId> getRoles(); boolean hasRole(RoleId role); UserActivation getActivation(); void setActivation(UserActivation activation); UserState getState(); void setState(UserState state); String getLocaleCode(); void setLocaleCode(String localeCode); String getPwRenewHash(); void setPwRenewHash(String pwRenewHash); OAuthData getoAuthData(); void setoAuthData(OAuthData oAuthData); String getOldPassword(); void setOldPassword(String oldPassword); String getPassword(); void setPassword(String password); String getPasswordAgain(); void setPasswordAgain(String passwordAgain); String getRegistrationIpAddress(); void setRegistrationIpAddress(String registrationIpAddress); void setPaymentLimits(PaymentLimits paymentLimits); PaymentLimits getPaymentLimits(); List<PaymentServiceProvider> getPaymentServiceProviderList(); void setPaymentServiceProviderList(List<PaymentServiceProvider> paymentServiceProviderList); void addPaymentServiceProvider(PaymentServiceProvider newPaymentServiceProvider); List<Token> getTokenList(); void addToken(Token newToken); void removeToken(Token token); boolean isRememberMe(); void setRememberMe(boolean rememberMe); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testEmailValidation() { Player player = new Player(); try { ValidationController.get(Player.class).processBeanValidationForProperty(player,"email"); fail("Invalid email not recognized"); } catch (ConstraintViolationException ex) { List<ConstraintViolation> errors = new ArrayList<>(ex.getConstraintViolations()); errors.sort(Comparator.comparing(ConstraintViolation::getMessageTemplate)); assertThat(errors.get(0).getMessageTemplate(), is("{email_not_empty}")); } player.setEmail(""); try { ValidationController.get(Player.class).processBeanValidationForProperty(player,"email"); fail("Invalid email not recognized"); } catch (ConstraintViolationException ex) { List<ConstraintViolation> errors = new ArrayList<>(ex.getConstraintViolations()); errors.sort(Comparator.comparing(ConstraintViolation::getMessageTemplate)); assertThat(errors.get(0).getMessageTemplate(), is("{email_not_empty}")); assertThat(errors.get(1).getMessageTemplate(), is("{email_not_valid}")); } player.setEmail("invalid@email"); try { ValidationController.get(Player.class).processBeanValidationForProperty(player,"email"); fail("Invalid email not recognized"); } catch (ConstraintViolationException ex) { List<ConstraintViolation> l = new ArrayList<>(ex.getConstraintViolations()); assertThat(l.get(0).getMessageTemplate(), is("{email_not_valid}")); } player.setEmail("correct@example.com"); try { ValidationController.get(Player.class).processBeanValidationForProperty(player,"email"); } catch (ConstraintViolationException ex) { fail("Correct email not recognized"); } }