urn_perun_user_attribute_def_def_phone extends UserAttributesModuleAbstract implements UserAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl perunSession, User user, Attribute attribute) throws WrongAttributeValueException { if (attribute.getValue() == null) return; String phone = attribute.valueAsString(); Matcher matcher = pattern.matcher(phone); if (!matcher.matches()) { throw new WrongAttributeValueException(attribute, "Phone is not in correct format!"); } }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, User user, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl perunSession, User user, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test public void testCorrectSyntax() throws Exception { System.out.println("testCorrectSyntax()"); attributeToCheck.setValue("+420123456789"); classInstance.checkAttributeSyntax(session, user, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeSyntaxWithWrongValue() throws Exception { System.out.println("testCheckAttributeSyntaxWithWrongValue()"); attributeToCheck.setValue("123456789"); classInstance.checkAttributeSyntax(session, user, attributeToCheck); }