Search in sources :

Example 6 with MembersPageQuery

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

the class MembersManagerEntryIntegrationTest method getMembersPageIdSortWorks.

@Test
public void getMembersPageIdSortWorks() throws Exception {
    System.out.println(CLASS_NAME + "getMembersPageIdSortWorks");
    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.ASCENDING, 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(member1.getId(), member2.getId(), member3.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 7 with MembersPageQuery

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

the class MembersManagerEntryIntegrationTest method getMembersPageReturnsAttributes.

@Test
public void getMembersPageReturnsAttributes() throws Exception {
    System.out.println(CLASS_NAME + "getMembersPageReturnsAttributes");
    Vo vo = perun.getVosManager().createVo(sess, new Vo(0, "testPagination", "tp"));
    Member member1 = setUpMember(vo, "Doe", "John");
    AttributeDefinition prefMailAttrDef = perun.getAttributesManagerBl().getAttributeDefinition(sess, A_M_MAIL);
    Attribute prefMail = new Attribute(prefMailAttrDef);
    prefMail.setValue("mail@mail.com");
    perun.getAttributesManagerBl().setAttribute(sess, member1, prefMail);
    MembersPageQuery query = new MembersPageQuery(1, 0, SortingOrder.ASCENDING, MembersOrderColumn.ID);
    Paginated<RichMember> result = perun.getMembersManager().getMembersPage(sess, vo, query, List.of(prefMail.getName()));
    assertThat(result.getData().get(0).getMemberAttributes()).containsOnly(prefMail);
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) Vo(cz.metacentrum.perun.core.api.Vo) BanOnVo(cz.metacentrum.perun.core.api.BanOnVo) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) 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 8 with MembersPageQuery

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

the class MembersManagerEntryIntegrationTest method getMembersPageNameDescendingWorks.

@Test
public void getMembersPageNameDescendingWorks() throws Exception {
    System.out.println(CLASS_NAME + "getMembersPageNameDescendingWorks");
    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.DESCENDING, 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);
}
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 9 with MembersPageQuery

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

the class MembersManagerEntryIntegrationTest method getGroupMembersPageWithMemberGroupAttribute.

@Test
public void getGroupMembersPageWithMemberGroupAttribute() throws Exception {
    System.out.println(CLASS_NAME + "getGroupMembersPageWithMemberGroupAttribute");
    Vo vo = perun.getVosManager().createVo(sess, new Vo(0, "testPagination", "tp"));
    Group group = perun.getGroupsManager().createGroup(sess, vo, new Group("test", "testPaginationInGroup"));
    Member member = setUpMember(vo, "Doe", "John");
    perun.getGroupsManager().addMember(sess, group, member);
    AttributeDefinition expirationDef = perun.getAttributesManagerBl().getAttributeDefinition(sess, A_M_G_EXPIRATION);
    Attribute expiration = new Attribute(expirationDef);
    expiration.setValue("2021-11-11");
    perun.getAttributesManagerBl().setAttribute(sess, member, group, expiration);
    MembersPageQuery query = new MembersPageQuery(1, 0, SortingOrder.ASCENDING, MembersOrderColumn.NAME, "doe", List.of(), group.getId(), List.of());
    Paginated<RichMember> result = perun.getMembersManager().getMembersPage(sess, vo, query, List.of(expiration.getName()));
    List<Integer> returnedMemberIds = result.getData().stream().map(PerunBean::getId).collect(toList());
    assertThat(returnedMemberIds).containsExactly(member.getId());
    assertThat(result.getData().get(0).getMemberAttributes().size()).isEqualTo(1);
    assertThat(result.getData().get(0).getMemberAttributes().get(0)).isEqualTo(expiration);
}
Also used : Group(cz.metacentrum.perun.core.api.Group) Attribute(cz.metacentrum.perun.core.api.Attribute) Vo(cz.metacentrum.perun.core.api.Vo) BanOnVo(cz.metacentrum.perun.core.api.BanOnVo) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) 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 10 with MembersPageQuery

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

the class MembersManagerEntryIntegrationTest method getMembersPageBasedOnSearchString.

@Test
public void getMembersPageBasedOnSearchString() throws Exception {
    System.out.println(CLASS_NAME + "getMembersPageBasedOnSearchString");
    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, "Doe", "Jane");
    MembersPageQuery query = new MembersPageQuery(3, 0, SortingOrder.ASCENDING, MembersOrderColumn.NAME, "doe");
    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());
    query.setSearchString("barn");
    result = perun.getMembersManager().getMembersPage(sess, vo, query, List.of());
    returnedMemberIds = result.getData().stream().map(PerunBean::getId).collect(toList());
    assertThat(returnedMemberIds).containsExactly(member2.getId());
}
Also used : 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)

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