urn_perun_entityless_attribute_def_def_namespace_maxUID extends EntitylessAttributesModuleAbstract implements EntitylessAttributesModuleImplApi { @Override public void checkAttributeSemantics(PerunSessionImpl perunSession, String key, Attribute attribute) throws WrongReferenceAttributeValueException, WrongAttributeAssignmentException { Integer maxUID = attribute.valueAsInteger(); if (maxUID == null) return; try { Attribute minUIDAttr = perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, key, A_E_namespaceMinUID); Integer minUID = minUIDAttr.valueAsInteger(); if(minUID != null) { if(maxUID < minUID) throw new WrongReferenceAttributeValueException(attribute, minUIDAttr, key, null, key, null, "Attribute value must be more than minUID. MinUID = " + minUID + ", and maxUID try to set = " + maxUID); } } catch (AttributeNotExistsException ex) { throw new ConsistencyErrorException("Attribute namespace-minUID is supposed to exist.",ex); } }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, String key, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl perunSession, String key, Attribute attribute); @Override AttributeDefinition getAttributeDefinition(); @Override List<String> getDependencies();  }
@Test(expected = WrongReferenceAttributeValueException.class) public void testValueLesserThanMinUID() throws Exception { System.out.println("testValueLesserThanMinUID()"); attributeToCheck.setValue(1); reqAttribute.setValue(2); classInstance.checkAttributeSemantics(session, key, attributeToCheck); }
@Test public void testCorrectSemantics() throws Exception { System.out.println("testCorrectSemantics()"); attributeToCheck.setValue(2); reqAttribute.setValue(1); classInstance.checkAttributeSemantics(session, key, attributeToCheck); }