Search in sources :

Example 1 with GroupsPageQuery

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

the class GroupsManagerEntryIntegrationTest method getGroupsPage_ParentGroup_OrderByDescriptionDSC.

@Test
public void getGroupsPage_ParentGroup_OrderByDescriptionDSC() throws Exception {
    System.out.println(CLASS_NAME + "getGroupsPage_ParentGroup_OrderByDescriptionDSC");
    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", "A_testovaci");
    perun.getGroupsManager().createGroup(sess, group, groupA);
    Group groupZ = new Group("Z_group", "Z_testovaci");
    perun.getGroupsManager().createGroup(sess, group, groupZ);
    GroupsPageQuery query = new GroupsPageQuery(10, 0, SortingOrder.DESCENDING, GroupsOrderColumn.DESCRIPTION);
    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, groupZ, List.of()));
    assertEquals(subgroups.getData().get(3), groupsManagerBl.convertGroupToRichGroupWithAttributesByName(sess, groupA, 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 2 with GroupsPageQuery

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

the class GroupsManagerEntryIntegrationTest method getGroupsPage_Vo_all.

@Test
public void getGroupsPage_Vo_all() throws Exception {
    System.out.println(CLASS_NAME + "getGroupsPage_Vo_all");
    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);
    Paginated<RichGroup> groups = groupsManager.getGroupsPage(sess, vo, query, List.of());
    assertNotNull(groups);
    assertEquals(groups.getData().size(), 5);
    assertTrue(groups.getData().containsAll(groupsManager.getAllRichGroupsWithAttributesByNames(sess, vo, 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 3 with GroupsPageQuery

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

the class GroupsManagerEntryIntegrationTest method getGroupsPage_Vo_OrderByDescriptionDSC.

@Test
public void getGroupsPage_Vo_OrderByDescriptionDSC() throws Exception {
    System.out.println(CLASS_NAME + "getGroupsPage_Vo_OrderByDescriptionDSC");
    vo = setUpVo();
    perun.getGroupsManager().createGroup(sess, vo, group);
    Group groupA = new Group("A_group", "A_testovaci");
    perun.getGroupsManager().createGroup(sess, vo, groupA);
    Group groupZ = new Group("Z_group", "Z_testovaci");
    perun.getGroupsManager().createGroup(sess, vo, groupZ);
    GroupsPageQuery query = new GroupsPageQuery(10, 0, SortingOrder.DESCENDING, GroupsOrderColumn.DESCRIPTION);
    Paginated<RichGroup> groups = groupsManager.getGroupsPage(sess, vo, query, List.of());
    assertNotNull(groups);
    assertEquals(groups.getData().size(), 4);
    assertEquals(groups.getData().get(0), groupsManagerBl.convertGroupToRichGroupWithAttributesByName(sess, groupZ, List.of()));
    assertEquals(groups.getData().get(3), groupsManagerBl.convertGroupToRichGroupWithAttributesByName(sess, groupA, 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 4 with GroupsPageQuery

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

the class GroupsManagerEntryIntegrationTest method getGroupsPage_ParentGroup_searchStringName.

@Test
public void getGroupsPage_ParentGroup_searchStringName() 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, "GroupsManagerTestGroup");
    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(), 5);
    assertNotNull(subgroups2);
    assertEquals(subgroups2.getData().size(), 1);
}
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 5 with GroupsPageQuery

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

the class GroupsManagerEntryIntegrationTest method getGroupsPage_filterByPolicyForGroupAdmin.

@Test
public void getGroupsPage_filterByPolicyForGroupAdmin() throws Exception {
    System.out.println(CLASS_NAME + "getGroupsPage_checkPolicy");
    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);
    perun.getGroupsManager().createGroup(sess, group21, group4);
    perun.getGroupsManager().createGroup(sess, group4, group5);
    perun.getGroupsManager().createGroup(sess, group5, group6);
    Member member1 = setUpMember(vo);
    User user1 = perun.getUsersManagerBl().getUserByMember(sess, member1);
    groupsManager.addAdmin(sess, group4, user1);
    PerunSession sess2 = new PerunSessionImpl(perun, new PerunPrincipal("groupAdmin1", ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL), new PerunClient());
    sess2.getPerunPrincipal().setUser(user1);
    GroupsPageQuery query = new GroupsPageQuery(10, 0, SortingOrder.ASCENDING, GroupsOrderColumn.ID);
    Paginated<RichGroup> groups = groupsManager.getGroupsPage(sess2, vo, query, List.of());
    assertNotNull(groups);
    assertEquals(groups.getData().size(), 3);
}
Also used : User(cz.metacentrum.perun.core.api.User) PerunSession(cz.metacentrum.perun.core.api.PerunSession) GroupsPageQuery(cz.metacentrum.perun.core.api.GroupsPageQuery) RichGroup(cz.metacentrum.perun.core.api.RichGroup) PerunClient(cz.metacentrum.perun.core.api.PerunClient) PerunPrincipal(cz.metacentrum.perun.core.api.PerunPrincipal) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) 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