urn_perun_facility_attribute_def_def_reqAups extends FacilityAttributesModuleAbstract implements FacilityAttributesModuleImplApi { @Override public void checkAttributeSemantics(PerunSessionImpl perunSession, Facility facility, Attribute attribute) throws WrongReferenceAttributeValueException { List<String> aups = attribute.valueAsList(); if (aups == null || aups.isEmpty()) return; List<Attribute> allAUPS = perunSession.getPerunBl().getAttributesManagerBl().getEntitylessAttributes(perunSession, availableAups); if (allAUPS.isEmpty()) return; Set<String> keys = new HashSet<>(); for (Attribute a : allAUPS) { if (a != null && a.getValue() != null && a.getValue() instanceof LinkedHashMap) { LinkedHashMap<String,String> map = a.valueAsMap(); keys.addAll(map.keySet()); } } for (String aup : aups) { if (!keys.contains(aup)) throw new WrongReferenceAttributeValueException(attribute, null, facility, null, aup+" AUP doesn't exist in available organization AUPs."); } }  @Override void checkAttributeSemantics(PerunSessionImpl perunSession, Facility facility, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongReferenceAttributeValueException.class) public void testCheckAttributeSemanticsWithoutAUPInOrganization() throws Exception { System.out.println("testCheckAttributeSyntaxWithoutAUPInOrganization()"); List<String> value = new ArrayList<>(); value.add("bad_example"); attributeToCheck.setValue(value); Map<String, String> value2 = new LinkedHashMap<>(); value2.put("example", "example"); reqAttribute.setValue(value2); classInstance.checkAttributeSemantics(session, facility, attributeToCheck); }
@Test public void testCheckAttributeSemanticsCorrect() throws Exception { System.out.println("testCheckAttributeSemanticsCorrect()"); List<String> value = new ArrayList<>(); value.add("example"); attributeToCheck.setValue(value); Map<String, String> value2 = new LinkedHashMap<>(); value2.put("example", "example"); reqAttribute.setValue(value2); classInstance.checkAttributeSemantics(session, facility, attributeToCheck); }