urn_perun_member_attribute_def_def_mail extends MemberAttributesModuleAbstract implements MemberAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl perunSession, Member member, Attribute attribute) throws WrongAttributeValueException { if (attribute.getValue() == null) return; Matcher emailMatcher = Utils.emailPattern.matcher(attribute.valueAsString()); if(!emailMatcher.find()) throw new WrongAttributeValueException(attribute, "Email is not in correct form."); }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, Member member, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl perunSession, Member member, Attribute attribute); @Override void changedAttributeHook(PerunSessionImpl session, Member member, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongAttributeValueException.class) public void testCheckEmailSyntax() throws Exception { System.out.println("testCheckEmailSyntax()"); attributeToCheck.setValue("a/-+"); classInstance.checkAttributeSyntax(session, member, attributeToCheck); }
@Test public void testCorrectSyntax() throws Exception { System.out.println("testCorrectSyntax()"); attributeToCheck.setValue("my@example.com"); classInstance.checkAttributeSyntax(session, member, attributeToCheck); }