urn_perun_user_facility_attribute_def_virt_login extends UserFacilityVirtualAttributesModuleAbstract implements UserFacilityVirtualAttributesModuleImplApi { @Override public void checkAttributeSemantics(PerunSessionImpl sess, User user, Facility facility, Attribute attribute) throws WrongReferenceAttributeValueException, WrongAttributeAssignmentException { try { Attribute loginNamespaceAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, facility, AttributesManager.NS_FACILITY_ATTR_DEF + ":login-namespace"); Attribute loginAttribute; if (loginNamespaceAttribute.getValue() != null) { loginAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, user, AttributesManager.NS_USER_ATTR_DEF + ":login-namespace:" + loginNamespaceAttribute.getValue()); if(attribute.getValue() == null) throw new WrongReferenceAttributeValueException(loginAttribute, null, user, facility, "Login can't be null"); loginAttribute.setValue(attribute.getValue()); sess.getPerunBl().getAttributesManagerBl().checkAttributeSemantics(sess, user, loginAttribute); } else { throw new WrongReferenceAttributeValueException(attribute, loginNamespaceAttribute, user, facility, facility, null, "Login-namespace for facility can not be empty."); } } catch (AttributeNotExistsException e) { throw new ConsistencyErrorException(e); } }  @Override void checkAttributeSemantics(PerunSessionImpl sess, User user, Facility facility, Attribute attribute); @Override Attribute fillAttribute(PerunSessionImpl sess, User user, Facility facility, AttributeDefinition attributeDefinition); @Override Attribute getAttributeValue(PerunSessionImpl sess, User user, Facility facility, AttributeDefinition attributeDefinition); @Override boolean setAttributeValue(PerunSessionImpl sess, User user, Facility facility, Attribute attribute); @Override List<String> getDependencies(); @Override List<String> getStrongDependencies(); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongReferenceAttributeValueException.class) public void testSemanticsWithoutFacilityLoginNamespaceAttribute() throws Exception { System.out.println("testSemanticsWithoutFacilityLoginNamespaceAttribute()"); attributeToCheck.setValue("login"); facilityLoginNamespace.setValue(null); classInstance.checkAttributeSemantics(sess, user, facility, attributeToCheck); }
@Test(expected = WrongReferenceAttributeValueException.class) public void testSemanticsWithoutUserLoginNamespaceAttribute() throws Exception { System.out.println("testSemanticsWithoutUserLoginNamespaceAttribute()"); attributeToCheck.setValue(null); classInstance.checkAttributeSemantics(sess, user, facility, attributeToCheck); }
@Test public void testSemanticsCorrect() throws Exception { System.out.println("testSemanticsCorrect()"); attributeToCheck.setValue("login"); classInstance.checkAttributeSemantics(sess, user, facility, attributeToCheck); }