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