urn_perun_user_attribute_def_def_k4Staleakt extends UserAttributesModuleAbstract implements UserAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl perunSession, User user, Attribute attribute) throws WrongAttributeValueException { if (attribute.getValue() != null) { if (!Objects.equals(attribute.getValue(), "0") && !Objects.equals(attribute.getValue(), "1")) { throw new WrongAttributeValueException(attribute, user, "Flag of K4 permanent visit must be empty, 0 or 1."); } } }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, User user, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test public void testCorrectSyntax() throws Exception { System.out.println("testCorrectSyntax()"); attributeToCheck.setValue("0"); classInstance.checkAttributeSyntax(session, user, attributeToCheck); attributeToCheck.setValue("1"); classInstance.checkAttributeSyntax(session, user, attributeToCheck); attributeToCheck.setValue(null); classInstance.checkAttributeSyntax(session, user, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeSyntaxWithWrongValue() throws Exception { System.out.println("testCheckAttributeSyntaxWithWrongValue()"); attributeToCheck.setValue("5"); classInstance.checkAttributeSyntax(session, user, attributeToCheck); }