urn_perun_group_attribute_def_def_o365EmailAddresses_o365mu extends GroupAttributesModuleAbstract implements GroupAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl sess, Group group, Attribute attribute) throws WrongAttributeValueException { log.trace("checkAttributeSyntax(group={},attribute={})", group, attribute); List<String> emails = attribute.valueAsList(); if (emails == null) return; for (String email : emails) { Matcher emailMatcher = emailPattern.matcher(email); if (!emailMatcher.matches()) throw new WrongAttributeValueException(attribute, group, "Email " + email + " is not in correct form."); Matcher ucoEmailMatcher = ucoEmailPattern.matcher(email); if (ucoEmailMatcher.matches()) throw new WrongAttributeValueException(attribute, group, "Email " + email + " is based on UCO which is not supported."); } if (hasDuplicate(emails)) { throw new WrongAttributeValueException(attribute, group, "duplicate values"); } }  @Override void checkAttributeSyntax(PerunSessionImpl sess, Group group, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl sess, Group group, Attribute attribute); @Override Attribute fillAttribute(PerunSessionImpl sess, Group group, AttributeDefinition attrDef); @Override List<String> getDependencies(); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongAttributeValueException.class) public void testCheckEmailSyntax() throws Exception { System.out.println("testCheckEmailSyntax()"); attributeToCheck.setValue(Lists.newArrayList("my@example.com", "a/-+")); classInstance.checkAttributeSyntax(session, group, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckUcoEmailSyntax() throws Exception { System.out.println("testCheckUcoEmailSyntax()"); attributeToCheck.setValue(Lists.newArrayList("my@example.com", "451570@muni.cz")); classInstance.checkAttributeSyntax(session, group, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckDuplicates() throws Exception { System.out.println("testCheckDuplicates()"); attributeToCheck.setValue(Lists.newArrayList("my@example.com", "aaa@bbb.com", "my@example.com")); classInstance.checkAttributeSyntax(session, group, attributeToCheck); }