urn_perun_user_attribute_def_def_login_namespace_vsup extends urn_perun_user_attribute_def_def_login_namespace { @Override public void checkAttributeSyntax(PerunSessionImpl sess, User user, Attribute attribute) throws WrongAttributeValueException { Utils.notNull(attribute, "attribute"); if (unpermittedLogins.contains(attribute.valueAsString())) throw new WrongAttributeValueException(attribute, user, "Login '" + attribute.getValue() + "' is not permitted."); super.checkAttributeSyntax(sess, user, attribute); if (attribute.getValue() != null) { if ((attribute.valueAsString()).length() > 20) throw new WrongAttributeValueException(attribute, user, "Login '" + attribute.getValue() + "' exceeds 20 chars limit."); } }  @Override void checkAttributeSyntax(PerunSessionImpl sess, User user, Attribute attribute); @Override Attribute fillAttribute(PerunSessionImpl perunSession, User user, AttributeDefinition attribute); @Override void changedAttributeHook(PerunSessionImpl session, User user, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test public void testCorrectSyntax() throws Exception { System.out.println("testCorrectSyntax()"); String value = "my_example"; attributeToCheck.setValue(value); classInstance.checkAttributeSyntax(session, user, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeSyntaxWithWrongValue() throws Exception { System.out.println("testCheckAttributeSyntaxWithWrongValue()"); String value = "too_long_to_be_namespace"; attributeToCheck.setValue(value); classInstance.checkAttributeSyntax(session, user, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeSyntaxWithWrongValue2() throws Exception { System.out.println("testCheckAttributeSyntaxWithWrongValue2()"); String value = "admin"; attributeToCheck.setValue(value); classInstance.checkAttributeSyntax(session, user, attributeToCheck); }