urn_perun_resource_attribute_def_def_homeMountPoints extends ResourceAttributesModuleAbstract implements ResourceAttributesModuleImplApi { @Override public void checkAttributeSemantics(PerunSessionImpl perunSession, Resource resource, Attribute attribute) throws WrongReferenceAttributeValueException, WrongAttributeAssignmentException { if (attribute.getValue() == null) { throw new WrongReferenceAttributeValueException(attribute, null, resource, null, "Attribute cannot be null!"); } Facility facility = perunSession.getPerunBl().getResourcesManagerBl().getFacility(perunSession, resource); Attribute facilityAttr; try { facilityAttr = perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, facility, A_F_homeMountPoints); } catch (AttributeNotExistsException ex) { throw new InternalErrorException(ex); } if(facilityAttr.getValue() == null) throw new WrongReferenceAttributeValueException(attribute, facilityAttr, resource, null, facility, null, "Reference attribute has null value."); if (!(facilityAttr.valueAsList()).containsAll(attribute.valueAsList())) { throw new WrongReferenceAttributeValueException(attribute, facilityAttr, resource, null, facility, null, "Facility does not contain all of the attribute homeMountPoints!"); } }  @Override Attribute fillAttribute(PerunSessionImpl perunSession, Resource resource, AttributeDefinition attribute); @Override void checkAttributeSyntax(PerunSessionImpl perunSession, Resource resource, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl perunSession, Resource resource, Attribute attribute); @Override List<String> getDependencies(); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongReferenceAttributeValueException.class) public void testSemanticsWithNullValue() throws Exception { System.out.println("testSemanticsWithNullValue()"); attributeToCheck.setValue(null); classInstance.checkAttributeSemantics(sess, resource, attributeToCheck); }
@Test(expected = WrongReferenceAttributeValueException.class) public void testSemanticsReqAttributeWithNullValue() throws Exception { System.out.println("testSemanticsReqAttributeWithNullValue()"); reqAttribute.setValue(null); classInstance.checkAttributeSemantics(sess, resource, attributeToCheck); }
@Test(expected = WrongReferenceAttributeValueException.class) public void testSemanticsReqAttributeWithDifferentValues() throws Exception { System.out.println("testSemanticsReqAttributeWithNullValue()"); List<String> badValue = new ArrayList<>(); badValue.add("bad_example"); reqAttribute.setValue(badValue); classInstance.checkAttributeSemantics(sess, resource, attributeToCheck); }
@Test public void testSemanticsCorrect() throws Exception { System.out.println("testSemanticsCorrect()"); classInstance.checkAttributeSemantics(sess, resource, attributeToCheck); }