use of cz.metacentrum.perun.core.api.UsersPageQuery in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method getUsersPage_facilityResourceOnlyAllowed.
@Test
public void getUsersPage_facilityResourceOnlyAllowed() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_facilityResourceOnlyAllowed");
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(), null, null, r.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_facilityResource.
@Test
public void getUsersPage_facilityResource() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_facilityResource");
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, "", facility.getId(), null, null, r.getId());
Paginated<RichUser> users = usersManager.getUsersPage(sess, query, List.of());
assertNotNull(users);
assertEquals(2, users.getData().size());
assertEquals(2, users.getTotalCount());
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_facility.
@Test
public void getUsersPage_facility() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_facility");
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, "", facility.getId());
Paginated<RichUser> users = usersManager.getUsersPage(sess, query, List.of());
assertNotNull(users);
assertEquals(2, users.getData().size());
assertEquals(2, users.getTotalCount());
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_userHasMembersInMultipleVos.
@Test
public void getUsersPage_userHasMembersInMultipleVos() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_userHasMembersInMultipleVos");
User user = setUpUser("jane", "smith");
Vo newVo = new Vo(1, "UserManagerTestV1o", "UMTestVo1");
Vo returnedVo = perun.getVosManager().createVo(sess, newVo);
Member member = perun.getMembersManagerBl().createMember(sess, returnedVo, user);
newVo = new Vo(2, "UserManagerTestV2o", "UMTestVo2");
returnedVo = perun.getVosManager().createVo(sess, newVo);
member = perun.getMembersManagerBl().createMember(sess, returnedVo, user);
newVo = new Vo(3, "UserManagerTestV3o", "UMTestVo3");
returnedVo = perun.getVosManager().createVo(sess, newVo);
member = perun.getMembersManagerBl().createMember(sess, returnedVo, user);
UsersPageQuery query = new UsersPageQuery(3, 0, SortingOrder.ASCENDING, UsersOrderColumn.ID, "jane");
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, user)));
}
use of cz.metacentrum.perun.core.api.UsersPageQuery in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method getUsersPage_facilityVoOnlyAllowed.
@Test
public void getUsersPage_facilityVoOnlyAllowed() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_facilityVoOnlyAllowed");
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(), vo.getId(), null, null, 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)));
}
Aggregations