Search in sources :

Example 6 with GroupsPageQuery

use of cz.metacentrum.perun.core.api.GroupsPageQuery in project perun by CESNET.

the class GroupsManagerEntryIntegrationTest method getGroupsPage_ParentGroup_all_totalCount_5.

@Test
public void getGroupsPage_ParentGroup_all_totalCount_5() throws Exception {
    System.out.println(CLASS_NAME + "getGroupsPage_ParentGroup_all");
    vo = setUpVo();
    perun.getGroupsManager().createGroup(sess, vo, group);
    perun.getGroupsManager().createGroup(sess, group, group2);
    perun.getGroupsManager().createGroup(sess, group2, group21);
    perun.getGroupsManager().createGroup(sess, group21, group3);
    perun.getGroupsManager().createGroup(sess, group, group4);
    perun.getGroupsManager().createGroup(sess, group, group5);
    perun.getGroupsManager().createGroup(sess, group, group6);
    perun.getGroupsManager().createGroup(sess, group, group7);
    GroupsPageQuery query = new GroupsPageQuery(5, 0, SortingOrder.ASCENDING, GroupsOrderColumn.ID);
    Paginated<RichGroup> subgroups = groupsManager.getSubgroupsPage(sess, group, query, List.of());
    assertNotNull(subgroups);
    assertEquals(subgroups.getData().size(), 5);
    assertEquals(subgroups.getTotalCount(), 7);
}
Also used : GroupsPageQuery(cz.metacentrum.perun.core.api.GroupsPageQuery) RichGroup(cz.metacentrum.perun.core.api.RichGroup) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 7 with GroupsPageQuery

use of cz.metacentrum.perun.core.api.GroupsPageQuery in project perun by CESNET.

the class GroupsManagerEntryIntegrationTest method getGroupsPage_ParentGroup_OrderByNameASC.

@Test
public void getGroupsPage_ParentGroup_OrderByNameASC() throws Exception {
    System.out.println(CLASS_NAME + "getGroupsPage_ParentGroup_OrderByNameASC");
    vo = setUpVo();
    perun.getGroupsManager().createGroup(sess, vo, group);
    perun.getGroupsManager().createGroup(sess, group, group2);
    perun.getGroupsManager().createGroup(sess, group2, group21);
    Group groupA = new Group("A_group", "testovaci_A");
    perun.getGroupsManager().createGroup(sess, group, groupA);
    Group groupZ = new Group("Z_group", "testovaci_Z");
    perun.getGroupsManager().createGroup(sess, group, groupZ);
    GroupsPageQuery query = new GroupsPageQuery(10, 0, SortingOrder.ASCENDING, GroupsOrderColumn.NAME);
    Paginated<RichGroup> subgroups = groupsManager.getSubgroupsPage(sess, group, query, List.of());
    assertNotNull(subgroups);
    assertEquals(subgroups.getData().size(), 4);
    assertEquals(subgroups.getData().get(0), groupsManagerBl.convertGroupToRichGroupWithAttributesByName(sess, groupA, List.of()));
    assertEquals(subgroups.getData().get(3), groupsManagerBl.convertGroupToRichGroupWithAttributesByName(sess, groupZ, List.of()));
}
Also used : Group(cz.metacentrum.perun.core.api.Group) RichGroup(cz.metacentrum.perun.core.api.RichGroup) GroupsPageQuery(cz.metacentrum.perun.core.api.GroupsPageQuery) RichGroup(cz.metacentrum.perun.core.api.RichGroup) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 8 with GroupsPageQuery

use of cz.metacentrum.perun.core.api.GroupsPageQuery in project perun by CESNET.

the class GroupsManagerEntryIntegrationTest method getGroupsPage_Vo_searchStringDescription.

@Test
public void getGroupsPage_Vo_searchStringDescription() throws Exception {
    System.out.println(CLASS_NAME + "getGroupsPage_Vo_searchStringDescription");
    vo = setUpVo();
    perun.getGroupsManager().createGroup(sess, vo, group);
    perun.getGroupsManager().createGroup(sess, vo, group2);
    perun.getGroupsManager().createGroup(sess, group2, group21);
    perun.getGroupsManager().createGroup(sess, group21, group3);
    GroupsPageQuery query = new GroupsPageQuery(10, 0, SortingOrder.ASCENDING, GroupsOrderColumn.ID, "testovaci2");
    Paginated<RichGroup> groups = groupsManager.getGroupsPage(sess, vo, query, List.of());
    assertNotNull(groups);
    assertEquals(groups.getData().size(), 2);
    assertTrue(groups.getData().contains(groupsManagerBl.convertGroupToRichGroupWithAttributesByName(sess, group2, List.of())));
    assertTrue(groups.getData().contains(groupsManagerBl.convertGroupToRichGroupWithAttributesByName(sess, group21, List.of())));
}
Also used : GroupsPageQuery(cz.metacentrum.perun.core.api.GroupsPageQuery) RichGroup(cz.metacentrum.perun.core.api.RichGroup) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 9 with GroupsPageQuery

use of cz.metacentrum.perun.core.api.GroupsPageQuery in project perun by CESNET.

the class GroupsManagerEntryIntegrationTest method getGroupsPageForMemberWithSpecifiedAttributes.

@Test
public void getGroupsPageForMemberWithSpecifiedAttributes() throws Exception {
    vo = setUpVo();
    perun.getGroupsManager().createGroup(sess, vo, group);
    perun.getGroupsManager().createGroup(sess, vo, group2);
    perun.getGroupsManager().createGroup(sess, vo, group3);
    Member member = setUpMember(vo);
    groupsManagerBl.addMember(sess, group, member);
    groupsManagerBl.addMember(sess, group2, member);
    List<String> attributeNames = new ArrayList<>();
    Map<UUID, List<Attribute>> memberGroupAttributes = new HashMap<>();
    AttributeDefinition attr = new AttributeDefinition();
    attr.setNamespace(AttributesManager.NS_MEMBER_GROUP_ATTR_VIRT);
    attr.setFriendlyName("groupStatus");
    attr.setDisplayName("Group membership status");
    attr.setType(String.class.getName());
    attr.setDescription("Whether member is VALID or EXPIRED in a group.");
    attributesManager.createAttribute(sess, attr);
    attributeNames.add(new Attribute(attr).getName());
    attributeNames.add(AttributesManager.NS_MEMBER_GROUP_ATTR_DEF + ":groupMembershipExpiration");
    memberGroupAttributes.put(group.getUuid(), new ArrayList<>());
    memberGroupAttributes.get(group.getUuid()).add(attributesManager.getAttribute(sess, member, group, attr.getName()));
    memberGroupAttributes.get(group.getUuid()).add(attributesManager.getAttribute(sess, member, group, AttributesManager.NS_MEMBER_GROUP_ATTR_DEF + ":groupMembershipExpiration"));
    memberGroupAttributes.put(group2.getUuid(), new ArrayList<>());
    memberGroupAttributes.get(group2.getUuid()).add(attributesManager.getAttribute(sess, member, group2, attr.getName()));
    memberGroupAttributes.get(group2.getUuid()).add(attributesManager.getAttribute(sess, member, group2, AttributesManager.NS_MEMBER_GROUP_ATTR_DEF + ":groupMembershipExpiration"));
    GroupsPageQuery query = new GroupsPageQuery(10, 0, SortingOrder.ASCENDING, GroupsOrderColumn.ID, "", member.getId());
    Paginated<RichGroup> groups = groupsManager.getGroupsPage(sess, vo, query, attributeNames);
    assertNotNull(groups);
    assertEquals(groups.getData().size(), 2);
    for (RichGroup g : groups.getData()) {
        assertTrue(g.getAttributes().containsAll(memberGroupAttributes.get(g.getUuid())));
    }
}
Also used : GroupsPageQuery(cz.metacentrum.perun.core.api.GroupsPageQuery) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Attribute(cz.metacentrum.perun.core.api.Attribute) RichGroup(cz.metacentrum.perun.core.api.RichGroup) ArrayList(java.util.ArrayList) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) List(java.util.List) ArrayList(java.util.ArrayList) UUID(java.util.UUID) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 10 with GroupsPageQuery

use of cz.metacentrum.perun.core.api.GroupsPageQuery in project perun by CESNET.

the class GroupsManagerEntryIntegrationTest method getGroupsPage_ParentGroup_searchStringDescription.

@Test
public void getGroupsPage_ParentGroup_searchStringDescription() throws Exception {
    System.out.println(CLASS_NAME + "getGroupsPage_ParentGroup_searchStringName");
    vo = setUpVo();
    perun.getGroupsManager().createGroup(sess, vo, group);
    perun.getGroupsManager().createGroup(sess, group, group2);
    perun.getGroupsManager().createGroup(sess, group2, group21);
    perun.getGroupsManager().createGroup(sess, group2, group3);
    perun.getGroupsManager().createGroup(sess, group21, group4);
    perun.getGroupsManager().createGroup(sess, group3, group5);
    GroupsPageQuery query = new GroupsPageQuery(10, 0, SortingOrder.ASCENDING, GroupsOrderColumn.ID, "testovaci2");
    Paginated<RichGroup> subgroups = groupsManager.getSubgroupsPage(sess, group, query, List.of());
    Paginated<RichGroup> subgroups2 = groupsManager.getSubgroupsPage(sess, group21, query, List.of());
    assertNotNull(subgroups);
    assertEquals(subgroups.getData().size(), 2);
    assertEquals(subgroups2.getData().size(), 0);
}
Also used : GroupsPageQuery(cz.metacentrum.perun.core.api.GroupsPageQuery) RichGroup(cz.metacentrum.perun.core.api.RichGroup) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)17 GroupsPageQuery (cz.metacentrum.perun.core.api.GroupsPageQuery)17 RichGroup (cz.metacentrum.perun.core.api.RichGroup)17 Test (org.junit.Test)17 Group (cz.metacentrum.perun.core.api.Group)4 LinkedHashMap (java.util.LinkedHashMap)4 Attribute (cz.metacentrum.perun.core.api.Attribute)3 Member (cz.metacentrum.perun.core.api.Member)3 RichMember (cz.metacentrum.perun.core.api.RichMember)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 UUID (java.util.UUID)2 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)1 PerunClient (cz.metacentrum.perun.core.api.PerunClient)1 PerunPrincipal (cz.metacentrum.perun.core.api.PerunPrincipal)1 PerunSession (cz.metacentrum.perun.core.api.PerunSession)1 User (cz.metacentrum.perun.core.api.User)1 PerunSessionImpl (cz.metacentrum.perun.core.impl.PerunSessionImpl)1