urn_perun_resource_attribute_def_def_redmineRole extends ResourceAttributesModuleAbstract implements ResourceAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl perunSession, Resource resource, Attribute attribute) throws WrongAttributeValueException { String role = attribute.valueAsString(); if (role == null) return; if (!role.equals("Manager") && !role.equals("Reporter") && !role.equals("Developer")) { throw new WrongAttributeValueException(attribute, resource, "Attribute value is invalid. The role can be either Manager, Reporter or Developer"); } }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, Resource resource, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl perunSession, Resource resource, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongAttributeValueException.class) public void testSyntaxWithWrongValue() throws Exception { System.out.println("testSyntaxWithWrongValue()"); attributeToCheck.setValue("bad_example"); classInstance.checkAttributeSyntax(sess, resource, attributeToCheck); }
@Test public void testSyntaxCorrect() throws Exception { System.out.println("testSyntaxCorrect()"); attributeToCheck.setValue("Manager"); classInstance.checkAttributeSyntax(sess, resource, attributeToCheck); attributeToCheck.setValue("Reporter"); classInstance.checkAttributeSyntax(sess, resource, attributeToCheck); attributeToCheck.setValue("Developer"); classInstance.checkAttributeSyntax(sess, resource, attributeToCheck); }
@Test public void testSemanticsWithNullValue() throws Exception { System.out.println("testSemanticsWithNullValue()"); attributeToCheck.setValue(null); classInstance.checkAttributeSyntax(sess, resource, attributeToCheck); }