use of cz.metacentrum.perun.core.api.MembersPageQuery in project perun by CESNET.
the class MembersManagerEntryIntegrationTest method getMembersPageOffsetWorks.
@Test
public void getMembersPageOffsetWorks() throws Exception {
System.out.println(CLASS_NAME + "getMembersPageOffsetWorks");
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, 1, 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(member2);
}
use of cz.metacentrum.perun.core.api.MembersPageQuery in project perun by CESNET.
the class MembersManagerEntryIntegrationTest method getMembersPageFindMemberById.
@Test
public void getMembersPageFindMemberById() throws Exception {
System.out.println(CLASS_NAME + "getMembersPageFindMemberById");
Vo vo = perun.getVosManager().createVo(sess, new Vo(0, "testPagination", "tp"));
Member member1 = setUpMember(vo, "Doe", "John");
setUpMember(vo, "Stinson", "Barney");
setUpMember(vo, "Doe", "Jane");
MembersPageQuery query = new MembersPageQuery(3, 0, SortingOrder.ASCENDING, MembersOrderColumn.NAME, String.valueOf(member1.getId()));
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());
}
use of cz.metacentrum.perun.core.api.MembersPageQuery in project perun by CESNET.
the class MembersManagerEntryIntegrationTest method getGroupMembersPage.
@Test
public void getGroupMembersPage() throws Exception {
System.out.println(CLASS_NAME + "getGroupMembersPage");
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");
Member member3 = setUpMember(vo, "Doe", "Jane");
perun.getGroupsManager().addMember(sess, group, member1);
perun.getGroupsManager().addMember(sess, group, member3);
MembersPageQuery query = new MembersPageQuery(3, 0, SortingOrder.ASCENDING, MembersOrderColumn.NAME, "doe", List.of(), group.getId(), List.of());
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(), member1.getId());
assertThat(result.getData().get(0).getMembershipType()).isEqualTo(MembershipType.DIRECT);
query.setSearchString("barn");
result = perun.getMembersManager().getMembersPage(sess, vo, query, List.of());
returnedMemberIds = result.getData().stream().map(PerunBean::getId).collect(toList());
assertThat(returnedMemberIds).isEmpty();
}
use of cz.metacentrum.perun.core.api.MembersPageQuery in project perun by CESNET.
the class MembersManagerEntryIntegrationTest method getMembersPageBasedOnStatuses.
@Test
public void getMembersPageBasedOnStatuses() throws Exception {
System.out.println(CLASS_NAME + "getMembersPageBasedOnStatuses");
Vo vo = perun.getVosManager().createVo(sess, new Vo(0, "testPagination", "tp"));
Member member1 = setUpMember(vo, "Doe", "John");
Member member2 = setUpMember(vo, "Stinson", "Barney");
perun.getMembersManager().setStatus(sess, member1, Status.EXPIRED);
perun.getMembersManager().setStatus(sess, member2, Status.INVALID);
MembersPageQuery query = new MembersPageQuery(3, 0, SortingOrder.ASCENDING, MembersOrderColumn.NAME, List.of(Status.EXPIRED));
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());
query.setStatuses(List.of(Status.INVALID));
result = perun.getMembersManager().getMembersPage(sess, vo, query, List.of());
returnedMemberIds = result.getData().stream().map(PerunBean::getId).collect(toList());
assertThat(returnedMemberIds).containsExactly(member2.getId());
}
Aggregations