Search in sources :

Example 16 with GroupsPageQuery

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

the class GroupsManagerEntryIntegrationTest method getGroupsPage_Vo_searchStringName.

@Test
public void getGroupsPage_Vo_searchStringName() throws Exception {
    System.out.println(CLASS_NAME + "getGroupsPage_Vo_searchStringName");
    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, "GroupsManagerTestGroup");
    Paginated<RichGroup> groups = groupsManager.getGroupsPage(sess, vo, query, List.of());
    assertNotNull(groups);
    assertEquals(groups.getData().size(), 4);
}
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 17 with GroupsPageQuery

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

the class GroupsManagerEntryIntegrationTest method getGroupsPage_Vo_ReturnsAttributes.

@Test
public void getGroupsPage_Vo_ReturnsAttributes() throws Exception {
    System.out.println(CLASS_NAME + "getGroupsPage_Vo_ReturnsAttributes");
    vo = setUpVo();
    perun.getGroupsManager().createGroup(sess, vo, group);
    // 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, group, extendMembershipRulesAttribute);
    GroupsPageQuery query = new GroupsPageQuery(10, 0, SortingOrder.ASCENDING, GroupsOrderColumn.ID);
    Paginated<RichGroup> groups = groupsManager.getGroupsPage(sess, vo, query, List.of(extendMembershipRulesAttribute.getName()));
    assertNotNull(groups);
    assertEquals(groups.getData().size(), 2);
    assertEquals(groups.getData().get(1), groupsManagerBl.convertGroupToRichGroupWithAttributesByName(sess, group, List.of(extendMembershipRulesAttribute.getName())));
    assertThat(groups.getData().get(1).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)

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