urn_perun_user_attribute_def_def_kerberosLogins extends UserAttributesModuleAbstract implements UserAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl sess, User user, Attribute attribute) throws WrongAttributeValueException { if(attribute.getValue() == null) return; List<String> value = attribute.valueAsList(); for(String login : value) { Matcher matcher = pattern.matcher(login); if(!matcher.matches()) throw new WrongAttributeValueException(attribute, user, "Attribute's value is not in correct format. format: login@realm"); } }  @Override void checkAttributeSyntax(PerunSessionImpl sess, User user, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl sess, User user, Attribute attribute); @Override Attribute fillAttribute(PerunSessionImpl sess, User user, AttributeDefinition attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test public void testCorrectSyntax() throws Exception { System.out.println("testCorrectSyntax()"); List<String> value = new ArrayList<>(); value.add("my@example"); attributeToCheck.setValue(value); classInstance.checkAttributeSyntax(session, user, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeSyntaxWithWrongValue() throws Exception { System.out.println("testCheckAttributeSyntaxWithWrongValue()"); List<String> value = new ArrayList<>(); value.add("bad.example"); attributeToCheck.setValue(value); classInstance.checkAttributeSyntax(session, user, attributeToCheck); }