urn_perun_user_attribute_def_def_preferredUnixGroupName_namespace extends UserAttributesModuleAbstract implements UserAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl sess, User user, Attribute attribute) throws WrongAttributeValueException { if(attribute.getValue()!= null) { for(String groupName: attribute.valueAsList()) { Matcher matcher = pattern.matcher(groupName); if (!matcher.matches()) throw new WrongAttributeValueException(attribute, user, "GroupName: " + groupName + " content invalid characters. Allowed are only letters, numbers and characters _ and - and ."); } } }  @Override void checkAttributeSyntax(PerunSessionImpl sess, User user, Attribute attribute);  }
@Test public void testCheckCorrectAttributeSyntax() throws Exception { System.out.println("testCheckCorrectAttributeSyntax()"); List<String> value = new ArrayList<>(); value.add("_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); }