urn_perun_user_attribute_def_def_timezone extends UserAttributesModuleAbstract implements UserAttributesModuleImplApi { @Override public void checkAttributeSemantics(PerunSessionImpl perunSession, User user, Attribute attribute) throws WrongReferenceAttributeValueException { if (attribute.getValue() == null) throw new WrongReferenceAttributeValueException(attribute, null, user, null, "Timezone must be set"); }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, User user, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl perunSession, User user, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test public void testCheckAttributeSemantics() throws Exception { System.out.println("testCheckAttributeSemantics()"); 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.checkAttributeSemantics(session, user, attributeToCheck); }
@Test(expected = WrongReferenceAttributeValueException.class) public void testCheckAttributeSemanticsWithNullValue() throws Exception { System.out.println("testCheckAttributeSemanticsWithNullValue()"); Attribute attributeToCheck = new Attribute(); attributeToCheck.setValue(null); classInstance.checkAttributeSemantics(session, user, attributeToCheck); }