use of cz.metacentrum.perun.core.api.RichGroup in project perun by CESNET.
the class GroupsManagerEntryIntegrationTest method convertGroupToRichGroupWithAttributesTest.
@Test
public void convertGroupToRichGroupWithAttributesTest() throws Exception {
System.out.println("GroupsManagerBl.convertGroupToRichGroupWithAttributes");
vo = setUpVo();
attributesList = setUpGroupAttributes();
setUpGroup(vo);
attributesManager.setAttributes(sess, group, attributesList);
RichGroup richGroup = new RichGroup(group, attributesManager.getAttributes(sess, group));
assertEquals("Both rich groups should be same", richGroup, groupsManagerBl.convertGroupToRichGroupWithAttributes(sess, group));
}
use of cz.metacentrum.perun.core.api.RichGroup in project perun by CESNET.
the class GroupsManagerEntry method getRichGroupByIdWithAttributesByNames.
public RichGroup getRichGroupByIdWithAttributesByNames(PerunSession sess, int groupId, List<String> attrNames) throws InternalErrorException, GroupNotExistsException, VoNotExistsException, PrivilegeException {
Utils.checkPerunSession(sess);
Group group = groupsManagerBl.getGroupById(sess, groupId);
// Authorization
if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, group) && !AuthzResolver.isAuthorized(sess, Role.VOOBSERVER, group) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, group)) {
throw new PrivilegeException(sess, "getRichGroupByIdWithAttributesByNames");
}
return getGroupsManagerBl().filterOnlyAllowedAttributes(sess, getGroupsManagerBl().getRichGroupByIdWithAttributesByNames(sess, groupId, attrNames));
}
use of cz.metacentrum.perun.core.api.RichGroup in project perun by CESNET.
the class GroupsManagerEntryIntegrationTest method convertGroupToRichGroupWithAttributesByNameTest.
@Test
public void convertGroupToRichGroupWithAttributesByNameTest() throws Exception {
System.out.println("GroupsManagerBl.convertGroupToRichGroupWithAttributesByName");
vo = setUpVo();
attributesList = setUpGroupAttributes();
this.groupsManager.createGroup(sess, vo, group);
attributesManager.setAttributes(sess, group, attributesList);
List<String> attrNames = new ArrayList<>();
//take names from this list of attributes
for (Attribute a : attributesList) {
attrNames.add(a.getName());
}
RichGroup richGroup = new RichGroup(group, attributesList);
assertEquals("Both rich groups should be same", richGroup, groupsManagerBl.convertGroupToRichGroupWithAttributesByName(sess, group, attrNames));
}
use of cz.metacentrum.perun.core.api.RichGroup in project perun by CESNET.
the class GroupsManagerEntryIntegrationTest method convertGroupsToRichGroupsWithAttributesTest.
@Test
public void convertGroupsToRichGroupsWithAttributesTest() throws Exception {
System.out.println("groupsManagerBl.convertGroupsToRichGroupsWithAttributes");
vo = setUpVo();
attributesList = setUpGroupAttributes();
this.groupsManager.createGroup(sess, vo, group);
attributesManager.setAttributes(sess, group, attributesList);
this.groupsManager.createGroup(sess, vo, group2);
attributesManager.setAttributes(sess, group2, attributesList);
RichGroup richGroup1 = new RichGroup(group, attributesManager.getAttributes(sess, group));
RichGroup richGroup2 = new RichGroup(group2, attributesManager.getAttributes(sess, group2));
assertEquals("Both lists should be same", Arrays.asList(richGroup1, richGroup2), groupsManagerBl.convertGroupsToRichGroupsWithAttributes(sess, Arrays.asList(group, group2)));
}
use of cz.metacentrum.perun.core.api.RichGroup in project perun by CESNET.
the class GroupsManagerEntryIntegrationTest method convertGroupsToRichGroupsWithAttributesWithListOfNamesTest.
@Test
public void convertGroupsToRichGroupsWithAttributesWithListOfNamesTest() throws Exception {
System.out.println("GroupsManagerBl.convertGroupsToRichGroupsWithAttributesWithListOfNamesTest");
vo = setUpVo();
attributesList = setUpGroupAttributes();
this.groupsManager.createGroup(sess, vo, group);
attributesManager.setAttributes(sess, group, attributesList);
this.groupsManager.createGroup(sess, vo, group2);
attributesManager.setAttributes(sess, group2, attributesList);
List<String> attrNames = new ArrayList<>();
RichGroup richGroup1 = new RichGroup(group, attributesList);
RichGroup richGroup2 = new RichGroup(group2, attributesList);
//take names from this list of attributes
for (Attribute a : attributesList) {
attrNames.add(a.getName());
}
assertEquals("Both lists should be same", Arrays.asList(richGroup1, richGroup2), groupsManagerBl.convertGroupsToRichGroupsWithAttributes(sess, Arrays.asList(group, group2), attrNames));
}
Aggregations