urn_perun_user_attribute_def_def_vsupPreferredMail extends UserAttributesModuleAbstract implements UserAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl sess, User user, Attribute attribute) throws WrongAttributeValueException { if (attribute.getValue() == null) return; Matcher emailMatcher = emailPattern.matcher((String)attribute.getValue()); if(!emailMatcher.find()) throw new WrongAttributeValueException(attribute, user, "School Preferred Mail is not in a correct form."); }  @Override void checkAttributeSyntax(PerunSessionImpl sess, User user, Attribute attribute); @Override Attribute fillAttribute(PerunSessionImpl session, User user, AttributeDefinition attribute); @Override void changedAttributeHook(PerunSessionImpl session, User user, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongAttributeValueException.class) public void testSyntaxWithIncorrectEmail() throws Exception { System.out.println("testSyntaxWithIncorrectEmail()"); attributeToCheck.setValue("bad@example"); classInstance.checkAttributeSyntax(session, user, attributeToCheck); }
@Test public void testCorrectSyntax() throws Exception { System.out.println("testCorrectSyntax()"); attributeToCheck.setValue("example@vsup.cz"); classInstance.checkAttributeSyntax(session, user, attributeToCheck); }