Search in sources :

Example 11 with GroupsPageQuery

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

the class GroupsManagerEntryIntegrationTest method getGroupsPage_ParentGroup_all.

@Test
public void getGroupsPage_ParentGroup_all() 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);
    GroupsPageQuery query = new GroupsPageQuery(10, 0, SortingOrder.ASCENDING, GroupsOrderColumn.ID);
    Paginated<RichGroup> subgroups = groupsManager.getSubgroupsPage(sess, group, query, List.of());
    Paginated<RichGroup> subgroups2 = groupsManager.getSubgroupsPage(sess, group2, query, List.of());
    assertNotNull(subgroups);
    assertEquals(subgroups.getData().size(), 5);
    assertNotNull(subgroups2);
    assertEquals(subgroups2.getData().size(), 2);
}
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 12 with GroupsPageQuery

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

the class GroupsManagerEntryIntegrationTest method getGroupsPage_Vo_all_totalCount_5.

@Test
public void getGroupsPage_Vo_all_totalCount_5() 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);
    perun.getGroupsManager().createGroup(sess, group21, group4);
    perun.getGroupsManager().createGroup(sess, group21, group5);
    perun.getGroupsManager().createGroup(sess, group21, group6);
    GroupsPageQuery query = new GroupsPageQuery(5, 0, SortingOrder.ASCENDING, GroupsOrderColumn.ID);
    Paginated<RichGroup> groups = groupsManager.getGroupsPage(sess, vo, query, List.of());
    assertNotNull(groups);
    assertEquals(groups.getData().size(), 5);
    assertEquals(groups.getTotalCount(), 8);
}
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 13 with GroupsPageQuery

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

the class GroupsManagerEntryIntegrationTest method getGroupsPage_Vo_OrderByNameASC.

@Test
public void getGroupsPage_Vo_OrderByNameASC() throws Exception {
    System.out.println(CLASS_NAME + "getGroupsPage_Vo_OrderByNameASC");
    vo = setUpVo();
    perun.getGroupsManager().createGroup(sess, vo, group);
    Group groupA = new Group("A_group", "testovaci_A");
    perun.getGroupsManager().createGroup(sess, vo, groupA);
    Group groupZ = new Group("Z_group", "testovaci_Z");
    perun.getGroupsManager().createGroup(sess, vo, groupZ);
    GroupsPageQuery query = new GroupsPageQuery(10, 0, SortingOrder.ASCENDING, GroupsOrderColumn.NAME);
    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, groupA, List.of()));
    assertEquals(groups.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 14 with GroupsPageQuery

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

the class GroupsManagerEntryIntegrationTest method getGroupsPage_ParentGroup_ReturnsAttributes.

@Test
public void getGroupsPage_ParentGroup_ReturnsAttributes() throws Exception {
    System.out.println(CLASS_NAME + "getGroupsPage_Vo_ReturnsAttributes");
    vo = setUpVo();
    perun.getGroupsManager().createGroup(sess, vo, group);
    perun.getGroupsManager().createGroup(sess, group, group2);
    // set membershipExpirationRules attribute
    HashMap<String, String> extendMembershipRules = new LinkedHashMap<>();
    extendMembershipRules.put(AbstractMembershipExpirationRulesModule.membershipPeriodKeyName, "+10d");
    Attribute extendMembershipRulesAttribute = new Attribute(attributesManager.getAttributeDefinition(sess, AttributesManager.NS_GROUP_ATTR_DEF + ":groupMembershipExpirationRules"));
    extendMembershipRulesAttribute.setValue(extendMembershipRules);
    attributesManager.setAttribute(sess, group2, extendMembershipRulesAttribute);
    GroupsPageQuery query = new GroupsPageQuery(10, 0, SortingOrder.ASCENDING, GroupsOrderColumn.ID);
    Paginated<RichGroup> groups = groupsManager.getSubgroupsPage(sess, group, query, List.of(extendMembershipRulesAttribute.getName()));
    assertNotNull(groups);
    assertEquals(groups.getData().size(), 1);
    assertEquals(groups.getData().get(0), groupsManagerBl.convertGroupToRichGroupWithAttributesByName(sess, group2, List.of(extendMembershipRulesAttribute.getName())));
    assertThat(groups.getData().get(0).getAttributes()).containsOnly(extendMembershipRulesAttribute);
}
Also used : GroupsPageQuery(cz.metacentrum.perun.core.api.GroupsPageQuery) Attribute(cz.metacentrum.perun.core.api.Attribute) RichGroup(cz.metacentrum.perun.core.api.RichGroup) LinkedHashMap(java.util.LinkedHashMap) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 15 with GroupsPageQuery

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

the class GroupsManagerEntryIntegrationTest method getGroupsPageForMemberWithAllAttributes.

@Test
public void getGroupsPageForMemberWithAllAttributes() 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);
    Map<UUID, List<Attribute>> attributes = new HashMap<>();
    setUpMemberGroupAttributes();
    attributes.put(group.getUuid(), new ArrayList<>());
    attributes.get(group.getUuid()).addAll(attributesManager.getAttributes(sess, group));
    attributes.get(group.getUuid()).addAll(attributesManager.getAttributes(sess, member, group));
    attributes.put(group2.getUuid(), new ArrayList<>());
    attributes.get(group2.getUuid()).addAll(attributesManager.getAttributes(sess, group2));
    attributes.get(group2.getUuid()).addAll(attributesManager.getAttributes(sess, member, group2));
    GroupsPageQuery query = new GroupsPageQuery(10, 0, SortingOrder.ASCENDING, GroupsOrderColumn.ID, "", member.getId());
    Paginated<RichGroup> groups = groupsManager.getGroupsPage(sess, vo, query, null);
    assertNotNull(groups);
    assertEquals(groups.getData().size(), 2);
    for (RichGroup g : groups.getData()) {
        assertEquals(new HashSet<>(g.getAttributes()), new HashSet<>(attributes.get(g.getUuid())));
    }
}
Also used : GroupsPageQuery(cz.metacentrum.perun.core.api.GroupsPageQuery) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) RichGroup(cz.metacentrum.perun.core.api.RichGroup) 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)

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