urn_perun_user_attribute_def_def_elixirScopedAffiliation extends UserAttributesModuleAbstract implements UserAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl perunSession, User user, Attribute attribute) throws WrongAttributeValueException { List<String> values = attribute.valueAsList(); if (values != null && !values.isEmpty()) { for (String value : values) { Matcher matcher = pattern.matcher(value); if(!matcher.matches()) throw new WrongAttributeValueException(attribute, "Wrong format. List of \"(member|affiliate|faculty)@scope\" expected."); } } }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, User user, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test public void testCorrectSyntax() throws Exception { System.out.println("testCheckAttributeSyntax()"); List<String> value = new ArrayList<>(); value.add("member@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); }