urn_perun_group_attribute_def_def_flatGroupStructureEnabled extends GroupAttributesModuleAbstract implements GroupAttributesModuleImplApi { @Override public void checkAttributeSemantics(PerunSessionImpl perunSession, Group group, Attribute attribute) throws WrongReferenceAttributeValueException, WrongAttributeAssignmentException { if(attribute.getValue() == null) return; AttributesManagerBl attributeManager = perunSession.getPerunBl().getAttributesManagerBl(); try { Attribute foundAttribute = attributeManager.getAttribute(perunSession, group, MANDATORY_ATTRIBUTE_NAME); if(foundAttribute == null || foundAttribute.getValue() == null) { throw new WrongReferenceAttributeValueException(attribute, foundAttribute, group, null, group, null, "Attribute " + MANDATORY_ATTRIBUTE_NAME + " must be defined first."); } } catch (AttributeNotExistsException exc) { throw new ConsistencyErrorException("Attribute " + MANDATORY_ATTRIBUTE_NAME + " is supposed to exist", exc); } }  @Override void checkAttributeSemantics(PerunSessionImpl perunSession, Group group, Attribute attribute); @Override List<String> getDependencies(); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongReferenceAttributeValueException.class) public void testCheckWithoutMandatoryAttributeSemantics() throws Exception { System.out.println("testCheckWithoutMandatoryAttributeSemantics()"); when(attributesManagerBl.getAttribute(sess, group, GroupsManager.GROUPS_STRUCTURE_SYNCHRO_ENABLED_ATTRNAME)).thenReturn(null); attributeToCheck.setValue(true); classInstance.checkAttributeSemantics(sess, group, attributeToCheck); }
@Test public void testCorrectSemantics() throws Exception { System.out.println("testCorrectSemantics()"); when(attributesManagerBl.getAttribute(sess, group, GroupsManager.GROUPS_STRUCTURE_SYNCHRO_ENABLED_ATTRNAME)).thenReturn(attributeToCheck); attributeToCheck.setValue(true); classInstance.checkAttributeSemantics(sess, group, attributeToCheck); }