urn_perun_group_attribute_def_def_groupExtSource extends GroupAttributesModuleAbstract implements GroupAttributesModuleImplApi { @Override public void checkAttributeSemantics(PerunSessionImpl sess, Group group, Attribute attribute) throws WrongReferenceAttributeValueException { String extSourceName = null; if(attribute.getValue() != null) extSourceName = attribute.valueAsString(); if (extSourceName != null) { try { Vo groupVo = sess.getPerunBl().getVosManagerBl().getVoById(sess, group.getVoId()); List<ExtSource> allowedExtSources = sess.getPerunBl().getExtSourcesManagerBl().getVoExtSources(sess, groupVo); for(ExtSource es: allowedExtSources) { if(extSourceName.equals(es.getName())) return; } throw new WrongReferenceAttributeValueException(attribute, null, group, null, "ExtSourceName " + extSourceName + " is not valid, because VO " + groupVo + " of this group has no such extSource assigned."); } catch (VoNotExistsException ex) { throw new ConsistencyErrorException("Vo of this group " + group + " not exists!"); } } }  @Override void checkAttributeSemantics(PerunSessionImpl sess, Group group, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongReferenceAttributeValueException.class) public void testWrongSemantics() throws Exception { System.out.println("testWrongSemantics()"); attributeToCheck.setValue("my_bad_example"); classInstance.checkAttributeSemantics(sess, group, attributeToCheck); }
@Test public void testCorrectSemantics() throws Exception { System.out.println("testCorrectSemantics()"); attributeToCheck.setValue("my_example"); classInstance.checkAttributeSemantics(sess, group, attributeToCheck); }