urn_perun_user_attribute_def_def_timezone extends UserAttributesModuleAbstract implements UserAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl perunSession, User user, Attribute attribute) throws WrongAttributeValueException { if (attribute.getValue() == null) return; String attributeValue = attribute.valueAsString(); if (!(timezones.contains(attributeValue))) throw new WrongAttributeValueException(attribute, user, "Timezone is not in the correct form."); }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, User user, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl perunSession, User user, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test public void testCheckAttributeSyntax() throws Exception { System.out.println("testCheckAttributeSyntax()"); Attribute attributeToCheck = new Attribute(); attributeToCheck.setValue("Europe/Prague"); classInstance.checkAttributeSyntax(session, user, attributeToCheck); attributeToCheck.setValue("Africa/Johannesburg"); classInstance.checkAttributeSyntax(session, user, attributeToCheck); attributeToCheck.setValue("Jamaica"); classInstance.checkAttributeSyntax(session, user, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeSyntaxWithWrongValue() throws Exception { System.out.println("testCheckAttributeSyntaxWithWrongValue()"); Attribute attributeToCheck = new Attribute(); attributeToCheck.setValue("123"); classInstance.checkAttributeSyntax(session, user, attributeToCheck); }