urn_perun_group_attribute_def_virt_adDisplayName_o365mu extends GroupVirtualAttributesModuleAbstract implements GroupVirtualAttributesModuleImplApi { @Override public Attribute getAttributeValue(PerunSessionImpl sess, Group group, AttributeDefinition attributeDefinition) { Attribute attribute = new Attribute(attributeDefinition); String defaultAdDisplayName = getStringValueOfGroupAttribute(sess, group, A_G_D_AD_DISPLAY_NAME_O365MU); if(defaultAdDisplayName != null) { attribute.setValue(defaultAdDisplayName); return attribute; } String cispr = getStringValueOfGroupAttribute(sess, group, A_G_D_INET_CISPR); if (cispr == null) return attribute; String typeOfWorkplaces = getStringValueOfGroupAttribute(sess, group, A_G_D_INET_WORKPLACES_TYPE_CS); if (typeOfWorkplaces == null) return attribute; String finalName = null; Matcher partOfUniversityMatcher = partOfUniversityPattern.matcher(cispr); Matcher otherWorkplacesMatcher = otherWorkplacesPattern.matcher(cispr); if (cispr.equals(TOP_LEVEL_GROUP_CISPR)) { finalName = TOP_LEVEL_PREFIX + ", " + typeOfWorkplaces; } else if (partOfUniversityMatcher.matches()) { String groupNameCS = getStringValueOfGroupAttribute(sess, group, A_G_D_INET_GROUP_NAME_CS); if(groupNameCS == null) return attribute; finalName = groupNameCS + ", " + typeOfWorkplaces; } else if (otherWorkplacesMatcher.matches()) { String groupNameCS = getStringValueOfGroupAttribute(sess, group, A_G_D_INET_GROUP_NAME_CS); if (groupNameCS != null) { String abbreviation = getParentGroupAbbreviation(sess, group); if (abbreviation != null) { finalName = groupNameCS + ", " + abbreviation + ", " + typeOfWorkplaces; } else { finalName = groupNameCS + ", " + typeOfWorkplaces; } } } attribute.setValue(finalName); return attribute; }  @Override Attribute getAttributeValue(PerunSessionImpl sess, Group group, AttributeDefinition attributeDefinition); @Override AttributeDefinition getAttributeDefinition();  }
@Test public void getAttributeValueForGroupA() { String attributeValue = classInstance.getAttributeValue(sess, groupA, adDisplayNameO365MuAttrDef).valueAsString(); assertNotNull(attributeValue); assertEquals("MUNI, typeA", attributeValue); }
@Test public void getAttributeValueForGroupB(){ String attributeValue = classInstance.getAttributeValue(sess, groupB, adDisplayNameO365MuAttrDef).valueAsString(); assertNull(attributeValue); }
@Test public void getAttributeValueForGroupC() { String attributeValue = classInstance.getAttributeValue(sess, groupC, adDisplayNameO365MuAttrDef).valueAsString(); assertNotNull(attributeValue); assertEquals(groupC.getName() + ", " + typeOfWorkplacesB, attributeValue); }
@Test public void getAttributeValueForGroupD() { String attributeValue = classInstance.getAttributeValue(sess, groupD, adDisplayNameO365MuAttrDef).valueAsString(); assertNotNull(attributeValue); assertEquals(predefinedDisplayName, attributeValue); }
@Test public void getAttributeValueForGroupE() { String attributeValue = classInstance.getAttributeValue(sess, groupE, adDisplayNameO365MuAttrDef).valueAsString(); assertNotNull(attributeValue); assertEquals(groupE.getName() + ", " + groupC.getDescription() + ", " + typeOfWorkplacesC, attributeValue); }
@Test public void getAttributeValueForGroupF() { String attributeValue = classInstance.getAttributeValue(sess, groupF, adDisplayNameO365MuAttrDef).valueAsString(); assertNotNull(attributeValue); assertEquals(groupF.getName() + ", " + typeOfWorkplacesB, attributeValue); }
@Test public void getAttributeValueForUnknownGroup() { String attributeValue = classInstance.getAttributeValue(sess, groupWithoutAttributes, adDisplayNameO365MuAttrDef).valueAsString(); assertNull(attributeValue); }