urn_perun_resource_attribute_def_def_defaultHomeMountPoint 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 value cannot be null."); } Attribute resourceAttribute; try { resourceAttribute = perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, resource, A_R_homeMountPoints); } catch (AttributeNotExistsException ex) { throw new InternalErrorException(ex); } if(resourceAttribute.getValue() == null) throw new WrongReferenceAttributeValueException(attribute, resourceAttribute, resource, null, resource, null, "HomeMountPoints attribute cannot be null."); List<?> homeMntPoints = resourceAttribute.valueAsList(); if (!homeMntPoints.contains(attribute.getValue())) { throw new WrongReferenceAttributeValueException(attribute, resourceAttribute, resource, null, resource, null, "Attribute value ins't defined in underlying resource. Attribute name=" + A_R_homeMountPoints); } }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, Resource resource, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl perunSession, Resource resource, Attribute attribute); @Override Attribute fillAttribute(PerunSessionImpl perunSession, Resource resource, AttributeDefinition 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()"); attributeToCheck.setValue("/example"); reqAttribute.setValue(null); classInstance.checkAttributeSemantics(sess, resource, attributeToCheck); }
@Test(expected = WrongReferenceAttributeValueException.class) public void testSemanticsReqAttributeWithoutNeededValue() throws Exception { System.out.println("testSemanticsReqAttributeWithoutNeededValue()"); attributeToCheck.setValue("/example"); List<String> value = new ArrayList<>(); value.add("something"); reqAttribute.setValue(value); classInstance.checkAttributeSemantics(sess, resource, attributeToCheck); }
@Test public void testSemanticsCorrect() throws Exception { System.out.println("testSemanticsCorrect()"); attributeToCheck.setValue("/example"); List<String> value = new ArrayList<>(); value.add("/example"); reqAttribute.setValue(value); classInstance.checkAttributeSemantics(sess, resource, attributeToCheck); }