Search in sources :

Example 1 with RichGroup

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));
}
Also used : RichGroup(cz.metacentrum.perun.core.api.RichGroup) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 2 with RichGroup

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));
}
Also used : Group(cz.metacentrum.perun.core.api.Group) RichGroup(cz.metacentrum.perun.core.api.RichGroup) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException)

Example 3 with RichGroup

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));
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) RichGroup(cz.metacentrum.perun.core.api.RichGroup) ArrayList(java.util.ArrayList) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 4 with RichGroup

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)));
}
Also used : RichGroup(cz.metacentrum.perun.core.api.RichGroup) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 5 with RichGroup

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));
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) RichGroup(cz.metacentrum.perun.core.api.RichGroup) ArrayList(java.util.ArrayList) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

RichGroup (cz.metacentrum.perun.core.api.RichGroup)5 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)4 Test (org.junit.Test)4 Attribute (cz.metacentrum.perun.core.api.Attribute)2 ArrayList (java.util.ArrayList)2 Group (cz.metacentrum.perun.core.api.Group)1 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)1