urn_perun_facility_attribute_def_def_pbsServer extends FacilityAttributesModuleAbstract implements FacilityAttributesModuleImplApi { @Override public void checkAttributeSemantics(PerunSessionImpl perunSession, Facility facility, Attribute attribute) throws WrongReferenceAttributeValueException { String pbsServer = attribute.valueAsString(); if (pbsServer == null) throw new WrongReferenceAttributeValueException(attribute, "PbsServer cannot be null."); List<Facility> allFacilities = perunSession.getPerunBl().getFacilitiesManagerBl().getFacilities(perunSession); boolean success = false; for(Facility f: allFacilities) { if(f.getName().equals(pbsServer)) { success = true; break; } } try { Attribute name = new Attribute(perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, AttributesManager.NS_FACILITY_ATTR_CORE + ":name")); name.setValue(pbsServer); if(!success) throw new WrongReferenceAttributeValueException(attribute, name, facility, null, "There is no facility with attribute name same as the pbsServer attribute."); } catch (AttributeNotExistsException e) { throw new ConsistencyErrorException(e); } }  @Override void checkAttributeSemantics(PerunSessionImpl perunSession, Facility facility, Attribute attribute); @Override Attribute fillAttribute(PerunSessionImpl session, Facility facility, AttributeDefinition attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongReferenceAttributeValueException.class) public void testCheckAttributeSemanticsWithoutSameNameFacility() throws Exception { System.out.println("testCheckAttributeSemanticsWithoutSameNameFacility()"); attributeToCheck.setValue("domain"); when(session.getPerunBl().getFacilitiesManagerBl().getFacilities(session)).thenReturn(new ArrayList<>()); classInstance.checkAttributeSemantics(session, facility, attributeToCheck); }
@Test(expected = WrongReferenceAttributeValueException.class) public void testCheckAttributeSemanticsWithNullValue() throws Exception { System.out.println("testCheckAttributeSemanticsWithNullValue()"); attributeToCheck.setValue(null); classInstance.checkAttributeSemantics(session, facility, attributeToCheck); }