use of cz.metacentrum.perun.core.api.UsersPageQuery in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method getUsersPage_orderByName.
@Test
public void getUsersPage_orderByName() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_orderByName");
User user = setUpUser("john", "smith");
User user2 = setUpUser("jane", "smith");
UsersPageQuery query = new UsersPageQuery(10, 0, SortingOrder.ASCENDING, UsersOrderColumn.NAME, "smith");
Paginated<RichUser> users = usersManager.getUsersPage(sess, query, List.of());
assertNotNull(users);
assertEquals(2, users.getData().size());
assertEquals(users.getData().get(0), usersManager.getRichUser(sess, user2));
assertEquals(users.getData().get(1), usersManager.getRichUser(sess, user));
}
use of cz.metacentrum.perun.core.api.UsersPageQuery in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method getUsersPage_facilitySearchString.
@Test
public void getUsersPage_facilitySearchString() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_facilitySearchString");
User user = setUpUser("john", "smith");
User user2 = setUpUser("jane", "smith");
Facility facility = new Facility();
facility.setName("UsersManagerTestFacility");
facility = perun.getFacilitiesManager().createFacility(sess, facility);
Resource r = new Resource(0, "name", "description", facility.getId());
r = perun.getResourcesManager().createResource(sess, r, vo, facility);
Member member = perun.getMembersManagerBl().createMember(sess, vo, user);
Member member2 = perun.getMembersManagerBl().createMember(sess, vo, user2);
Group g1 = setUpGroup(vo, member, "group1");
Group g2 = setUpGroup(vo, member2, "group2");
perun.getResourcesManager().assignGroupToResource(sess, g1, r, false, false, false);
perun.getResourcesManager().assignGroupToResource(sess, g2, r, false, false, false);
UsersPageQuery query = new UsersPageQuery(3, 0, SortingOrder.ASCENDING, UsersOrderColumn.ID, "jane", facility.getId());
Paginated<RichUser> users = usersManager.getUsersPage(sess, query, List.of());
assertNotNull(users);
assertEquals(1, users.getData().size());
assertEquals(1, users.getTotalCount());
assertTrue(users.getData().contains(usersManager.getRichUser(sess, user2)));
}
use of cz.metacentrum.perun.core.api.UsersPageQuery in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method getUsersPage_facilityOnlyAllowed.
@Test
public void getUsersPage_facilityOnlyAllowed() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_facilityOnlyAllowed");
User user = setUpUser("john", "smith");
User user2 = setUpUser("jane", "smith");
Facility facility = new Facility();
facility.setName("UsersManagerTestFacility");
facility = perun.getFacilitiesManager().createFacility(sess, facility);
Resource r = new Resource(0, "name", "description", facility.getId());
r = perun.getResourcesManager().createResource(sess, r, vo, facility);
Member member = perun.getMembersManagerBl().createMember(sess, vo, user);
Member member2 = perun.getMembersManagerBl().createMember(sess, vo, user2);
perun.getMembersManagerBl().setStatus(sess, member, Status.INVALID);
perun.getMembersManagerBl().setStatus(sess, member2, Status.VALID);
Group g1 = setUpGroup(vo, member, "group1");
Group g2 = setUpGroup(vo, member2, "group2");
perun.getResourcesManager().assignGroupToResource(sess, g1, r, false, false, false);
perun.getResourcesManager().assignGroupToResource(sess, g2, r, false, false, false);
UsersPageQuery query = new UsersPageQuery(3, 0, SortingOrder.ASCENDING, UsersOrderColumn.ID, "", facility.getId(), true);
Paginated<RichUser> users = usersManager.getUsersPage(sess, query, List.of());
assertNotNull(users);
assertEquals(1, users.getData().size());
assertEquals(1, users.getTotalCount());
assertTrue(users.getData().contains(usersManager.getRichUser(sess, user2)));
}
use of cz.metacentrum.perun.core.api.UsersPageQuery in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method getUsersPage_all.
@Test
public void getUsersPage_all() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_all");
User user = setUpUser("john", "smith");
User user2 = setUpUser("jane", "smith");
UsersPageQuery query = new UsersPageQuery(10, 0, SortingOrder.ASCENDING, UsersOrderColumn.ID);
Paginated<RichUser> users = usersManager.getUsersPage(sess, query, List.of());
assertNotNull(users);
assertTrue(users.getData().size() > 1);
assertTrue(users.getData().containsAll(usersManager.getRichUsersByIds(sess, List.of(user.getId(), user2.getId()))));
}
use of cz.metacentrum.perun.core.api.UsersPageQuery in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method getUsersPage_withAttributes.
@Test
public void getUsersPage_withAttributes() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_withAttributes");
User user = setUpUser("john", "smith");
AttributeDefinition prefMailAttrDef = perun.getAttributesManagerBl().getAttributeDefinition(sess, URN_ATTR_USER_PREFERRED_MAIL);
Attribute prefMail = new Attribute(prefMailAttrDef);
prefMail.setValue("mail@mail.com");
perun.getAttributesManagerBl().setAttribute(sess, user, prefMail);
UsersPageQuery query = new UsersPageQuery(1, 0, SortingOrder.ASCENDING, UsersOrderColumn.ID, "smith");
Paginated<RichUser> users = usersManager.getUsersPage(sess, query, List.of(URN_ATTR_USER_PREFERRED_MAIL));
assertNotNull(users);
assertEquals(1, users.getData().size());
assertTrue(users.getData().contains(usersManager.getRichUser(sess, user)));
assertThat(users.getData().get(0).getUserAttributes()).containsOnly(prefMail);
}
Aggregations