urn_perun_entityless_attribute_def_def_namespace_minUID extends EntitylessAttributesModuleAbstract implements EntitylessAttributesModuleImplApi { @Override public void checkAttributeSemantics(PerunSessionImpl perunSession, String key, Attribute attribute) throws WrongReferenceAttributeValueException, WrongAttributeAssignmentException { Integer minUID = attribute.valueAsInteger(); if (minUID == null) return; try { Attribute maxUIDAttr = perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, key, A_E_namespaceMaxUID); Integer maxUID = (Integer) maxUIDAttr.getValue(); if(maxUID != null) { if(minUID > maxUID) throw new WrongReferenceAttributeValueException(attribute, maxUIDAttr, key, null, key, null, "Attribute value must be less than maxUID. MaxUID = " + maxUID + ", and minUID try to set = " + minUID); } } catch (AttributeNotExistsException ex) { throw new ConsistencyErrorException("Attribute namespace-maxUID 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(2); reqAttribute.setValue(1); classInstance.checkAttributeSemantics(session, key, attributeToCheck); }
@Test public void testCorrectSemantics() throws Exception { System.out.println("testCorrectSemantics()"); attributeToCheck.setValue(1); reqAttribute.setValue(2); classInstance.checkAttributeSemantics(session, key, attributeToCheck); }