Search in sources :

Example 1 with MembersPageQuery

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

the class MembersManagerEntryIntegrationTest method getMembersPageIdSortDescendingWorks.

@Test
public void getMembersPageIdSortDescendingWorks() throws Exception {
    System.out.println(CLASS_NAME + "getMembersPageIdSortDescendingWorks");
    Vo vo = perun.getVosManager().createVo(sess, new Vo(0, "testPagination", "tp"));
    Member member1 = setUpMember(vo, "Doe", "John");
    Member member2 = setUpMember(vo, "Stinson", "Barney");
    Member member3 = setUpMember(vo, "Erickson", "Marshall");
    MembersPageQuery query = new MembersPageQuery(3, 0, SortingOrder.DESCENDING, MembersOrderColumn.ID);
    Paginated<RichMember> result = perun.getMembersManager().getMembersPage(sess, vo, query, List.of());
    List<Integer> returnedMemberIds = result.getData().stream().map(PerunBean::getId).collect(toList());
    assertThat(returnedMemberIds).containsExactly(member3.getId(), member2.getId(), member1.getId());
}
Also used : Vo(cz.metacentrum.perun.core.api.Vo) BanOnVo(cz.metacentrum.perun.core.api.BanOnVo) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member) RichMember(cz.metacentrum.perun.core.api.RichMember) MembersPageQuery(cz.metacentrum.perun.core.api.MembersPageQuery) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 2 with MembersPageQuery

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

the class MembersManagerEntryIntegrationTest method getGroupMembersPageOnDifferentSubgroupStatuses.

@Test
public void getGroupMembersPageOnDifferentSubgroupStatuses() throws Exception {
    System.out.println(CLASS_NAME + "getGroupMembersPageOnDifferentSubgroupStatuses");
    Vo vo = perun.getVosManager().createVo(sess, new Vo(0, "testPagination", "tp"));
    Group group = perun.getGroupsManager().createGroup(sess, vo, new Group("test", "testPaginationInGroup"));
    Group subgroup = perun.getGroupsManager().createGroup(sess, group, new Group("subgroup", "testPaginationInSubGroup"));
    Member member1 = setUpMember(vo, "Doe", "John");
    Member member2 = setUpMember(vo, "Stinson", "Barney");
    Member member3 = setUpMember(vo, "Wo", "Jane");
    perun.getGroupsManager().addMember(sess, group, member1);
    perun.getGroupsManager().addMember(sess, subgroup, member1);
    perun.getGroupsManager().addMember(sess, group, member2);
    perun.getGroupsManager().addMember(sess, subgroup, member2);
    perun.getGroupsManager().addMember(sess, subgroup, member3);
    perun.getGroupsManager().setMemberGroupStatus(sess, member1, group, MemberGroupStatus.VALID);
    perun.getGroupsManager().setMemberGroupStatus(sess, member1, subgroup, MemberGroupStatus.EXPIRED);
    perun.getGroupsManager().setMemberGroupStatus(sess, member2, group, MemberGroupStatus.EXPIRED);
    perun.getGroupsManager().setMemberGroupStatus(sess, member2, subgroup, MemberGroupStatus.EXPIRED);
    perun.getGroupsManager().setMemberGroupStatus(sess, member3, subgroup, MemberGroupStatus.VALID);
    MembersPageQuery query = new MembersPageQuery(3, 0, SortingOrder.ASCENDING, MembersOrderColumn.NAME, "", List.of(), group.getId(), List.of(MemberGroupStatus.VALID));
    Paginated<RichMember> result = perun.getMembersManager().getMembersPage(sess, vo, query, List.of());
    List<Integer> returnedMemberIds = result.getData().stream().map(PerunBean::getId).collect(toList());
    assertThat(returnedMemberIds).containsExactly(member1.getId(), member3.getId());
    assertThat(result.getData().get(0).getMembershipType()).isEqualTo(MembershipType.DIRECT);
    assertThat(result.getData().get(1).getMembershipType()).isEqualTo(MembershipType.INDIRECT);
    query.setGroupStatuses(List.of(MemberGroupStatus.EXPIRED));
    result = perun.getMembersManager().getMembersPage(sess, vo, query, List.of());
    returnedMemberIds = result.getData().stream().map(PerunBean::getId).collect(toList());
    assertThat(returnedMemberIds).containsExactly(member2.getId());
    assertThat(result.getData().get(0).getMembershipType()).isEqualTo(MembershipType.DIRECT);
}
Also used : Group(cz.metacentrum.perun.core.api.Group) PerunBean(cz.metacentrum.perun.core.api.PerunBean) Vo(cz.metacentrum.perun.core.api.Vo) BanOnVo(cz.metacentrum.perun.core.api.BanOnVo) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member) RichMember(cz.metacentrum.perun.core.api.RichMember) MembersPageQuery(cz.metacentrum.perun.core.api.MembersPageQuery) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 3 with MembersPageQuery

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

the class MembersManagerEntryIntegrationTest method getGroupMembersPageOnGroupStatuses.

@Test
public void getGroupMembersPageOnGroupStatuses() throws Exception {
    System.out.println(CLASS_NAME + "getGroupMembersPageOnGroupStatuses");
    Vo vo = perun.getVosManager().createVo(sess, new Vo(0, "testPagination", "tp"));
    Group group = perun.getGroupsManager().createGroup(sess, vo, new Group("test", "testPaginationInGroup"));
    Member member1 = setUpMember(vo, "Doe", "John");
    Member member2 = setUpMember(vo, "Stinson", "Barney");
    perun.getGroupsManager().addMember(sess, group, member1);
    perun.getGroupsManager().addMember(sess, group, member2);
    perun.getGroupsManager().setMemberGroupStatus(sess, member1, group, MemberGroupStatus.VALID);
    perun.getGroupsManager().setMemberGroupStatus(sess, member2, group, MemberGroupStatus.EXPIRED);
    MembersPageQuery query = new MembersPageQuery(3, 0, SortingOrder.ASCENDING, MembersOrderColumn.NAME, "", List.of(), group.getId(), List.of(MemberGroupStatus.VALID));
    Paginated<RichMember> result = perun.getMembersManager().getMembersPage(sess, vo, query, List.of());
    List<Integer> returnedMemberIds = result.getData().stream().map(PerunBean::getId).collect(toList());
    assertThat(returnedMemberIds).containsExactly(member1.getId());
    assertThat(result.getData().get(0).getMembershipType()).isEqualTo(MembershipType.DIRECT);
    query.setGroupStatuses(List.of(MemberGroupStatus.EXPIRED));
    result = perun.getMembersManager().getMembersPage(sess, vo, query, List.of());
    returnedMemberIds = result.getData().stream().map(PerunBean::getId).collect(toList());
    assertThat(returnedMemberIds).containsExactly(member2.getId());
    assertThat(result.getData().get(0).getMembershipType()).isEqualTo(MembershipType.DIRECT);
}
Also used : Group(cz.metacentrum.perun.core.api.Group) PerunBean(cz.metacentrum.perun.core.api.PerunBean) Vo(cz.metacentrum.perun.core.api.Vo) BanOnVo(cz.metacentrum.perun.core.api.BanOnVo) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member) RichMember(cz.metacentrum.perun.core.api.RichMember) MembersPageQuery(cz.metacentrum.perun.core.api.MembersPageQuery) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 4 with MembersPageQuery

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

the class MembersManagerEntryIntegrationTest method getMembersPagePageSizeWorks.

@Test
public void getMembersPagePageSizeWorks() throws Exception {
    System.out.println(CLASS_NAME + "getMembersPagePageSizeWorks");
    Vo vo = perun.getVosManager().createVo(sess, new Vo(0, "testPagination", "tp"));
    Member member1 = setUpMember(vo, "Doe", "John");
    Member member2 = setUpMember(vo, "Stinson", "Barney");
    MembersPageQuery query = new MembersPageQuery(1, 0, SortingOrder.ASCENDING, MembersOrderColumn.NAME);
    Paginated<RichMember> result = perun.getMembersManager().getMembersPage(sess, vo, query, List.of());
    assertThat(result.getData()).hasSize(1);
    assertThat(result.getData().get(0)).isEqualTo(member1);
}
Also used : Vo(cz.metacentrum.perun.core.api.Vo) BanOnVo(cz.metacentrum.perun.core.api.BanOnVo) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member) RichMember(cz.metacentrum.perun.core.api.RichMember) MembersPageQuery(cz.metacentrum.perun.core.api.MembersPageQuery) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 5 with MembersPageQuery

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

the class MembersManagerEntryIntegrationTest method getMembersPageBasedOnUserUuidSearchString.

@Test
public void getMembersPageBasedOnUserUuidSearchString() throws Exception {
    System.out.println(CLASS_NAME + "getMembersPageBasedOnUserUuidSearchString");
    Vo vo = perun.getVosManager().createVo(sess, new Vo(0, "testPagination", "tp"));
    Member member1 = setUpMember(vo, "Doe", "John");
    User user1 = perun.getUsersManager().getUserByMember(sess, member1);
    Member member2 = setUpMember(vo, "Stinson", "Barney");
    MembersPageQuery query = new MembersPageQuery(3, 0, SortingOrder.ASCENDING, MembersOrderColumn.NAME, user1.getUuid().toString());
    Paginated<RichMember> result = perun.getMembersManager().getMembersPage(sess, vo, query, List.of());
    List<Integer> returnedMemberIds = result.getData().stream().map(PerunBean::getId).collect(toList());
    assertThat(returnedMemberIds).containsExactly(member1.getId());
}
Also used : User(cz.metacentrum.perun.core.api.User) Vo(cz.metacentrum.perun.core.api.Vo) BanOnVo(cz.metacentrum.perun.core.api.BanOnVo) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member) RichMember(cz.metacentrum.perun.core.api.RichMember) MembersPageQuery(cz.metacentrum.perun.core.api.MembersPageQuery) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)14 BanOnVo (cz.metacentrum.perun.core.api.BanOnVo)14 Member (cz.metacentrum.perun.core.api.Member)14 MembersPageQuery (cz.metacentrum.perun.core.api.MembersPageQuery)14 RichMember (cz.metacentrum.perun.core.api.RichMember)14 Vo (cz.metacentrum.perun.core.api.Vo)14 Test (org.junit.Test)14 PerunBean (cz.metacentrum.perun.core.api.PerunBean)5 Group (cz.metacentrum.perun.core.api.Group)4 Attribute (cz.metacentrum.perun.core.api.Attribute)2 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)2 User (cz.metacentrum.perun.core.api.User)1