urn_perun_group_resource_attribute_def_def_vomsGroupName extends GroupResourceAttributesModuleAbstract implements GroupResourceAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl perunSession, Group group, Resource resource, Attribute attribute) throws WrongAttributeValueException { String vomsGroupName = attribute.valueAsString(); if(vomsGroupName == null) return; Matcher matcher = pattern.matcher(vomsGroupName); if(!matcher.matches()) { throw new WrongAttributeValueException(attribute, group, resource, "Bad format of attribute vomsGroupName. It should not contain '<>&=' characters."); } }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, Group group, Resource resource, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongAttributeValueException.class) public void testWrongValue() throws Exception { System.out.println("testWrongValue()"); attributeToCheck.setValue("<0"); classInstance.checkAttributeSyntax(sess, group, resource, attributeToCheck); attributeToCheck.setValue(">0"); classInstance.checkAttributeSyntax(sess, group, resource, attributeToCheck); attributeToCheck.setValue("&0"); classInstance.checkAttributeSyntax(sess, group, resource, attributeToCheck); attributeToCheck.setValue("=0"); classInstance.checkAttributeSyntax(sess, group, resource, attributeToCheck); }
@Test public void testCorrectSyntax() throws Exception { System.out.println("testCorrectSyntax()"); attributeToCheck.setValue("5"); classInstance.checkAttributeSyntax(sess, group, resource, attributeToCheck); }