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);
}
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);
}
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()));
}
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);
}
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())));
}
}
Aggregations