urn_perun_vo_attribute_def_def_toEmail extends VoAttributesModuleAbstract implements VoAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl sess, Vo vo, Attribute attribute) throws WrongAttributeValueException { if (attribute.getValue() == null) return; List<String> toEmails = attribute.valueAsList(); for (String email : toEmails) { if (!(sess.getPerunBl().getModulesUtilsBl().isNameOfEmailValid(sess, email))) throw new WrongAttributeValueException(attribute, "Vo : " + vo.getName() +" has toEmail " + email +" which is not valid."); } }  @Override void checkAttributeSyntax(PerunSessionImpl sess, Vo vo, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl sess, Vo vo, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongAttributeValueException.class) public void testCheckValueWithIncorrectEmail() throws Exception { System.out.println("testCheckValueWithIncorrectEmail()"); List<String> value = new ArrayList<>(); value.add(incorrectEmail); attributeToCheck.setValue(value); classInstance.checkAttributeSyntax(session, vo, attributeToCheck); }
@Test public void testCorrectSyntax() throws Exception { System.out.println("testCorrectSyntax()"); List<String> value = new ArrayList<>(); value.add(correctEmail); attributeToCheck.setValue(value); classInstance.checkAttributeSyntax(session, vo, attributeToCheck); }