use of cz.metacentrum.perun.core.api.UsersPageQuery in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method getUsersPage_facilityVoServiceOnlyAllowed.
@Test
public void getUsersPage_facilityVoServiceOnlyAllowed() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_facilityVoServiceOnlyAllowed");
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);
Service service = new Service(0, "dummy_service");
service = perun.getServicesManagerBl().createService(sess, service);
perun.getResourcesManagerBl().assignService(sess, r, service);
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(), service.getId(), 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)));
}
use of cz.metacentrum.perun.core.api.UsersPageQuery in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method getUsersPage_facilityVo.
@Test
public void getUsersPage_facilityVo() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_facilityVo");
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(), vo.getId(), null, null);
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_facilityServiceOnlyAllowed.
@Test
public void getUsersPage_facilityServiceOnlyAllowed() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_facilityServiceOnlyAllowed");
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);
Vo newVo = new Vo(2, "UserManagerTestV2o", "UMTestVo2");
Vo returnedVo = perun.getVosManager().createVo(sess, newVo);
Resource r2 = new Resource(1, "name1", "description1", facility.getId());
r2 = perun.getResourcesManager().createResource(sess, r2, returnedVo, facility);
Service service = new Service(0, "dummy_service");
service = perun.getServicesManagerBl().createService(sess, service);
perun.getResourcesManagerBl().assignService(sess, r, service);
perun.getResourcesManagerBl().assignService(sess, r2, service);
Member member = perun.getMembersManagerBl().createMember(sess, vo, user);
Member member2 = perun.getMembersManagerBl().createMember(sess, returnedVo, user2);
perun.getMembersManagerBl().setStatus(sess, member, Status.INVALID);
perun.getMembersManagerBl().setStatus(sess, member2, Status.VALID);
Group g1 = setUpGroup(vo, member, "group1");
Group g2 = setUpGroup(returnedVo, member2, "group2");
perun.getResourcesManager().assignGroupToResource(sess, g1, r, false, false, false);
perun.getResourcesManager().assignGroupToResource(sess, g2, r2, false, false, false);
UsersPageQuery query = new UsersPageQuery(3, 0, SortingOrder.ASCENDING, UsersOrderColumn.ID, "", facility.getId(), null, service.getId(), 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)));
}
use of cz.metacentrum.perun.core.api.UsersPageQuery in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method getUsersPage_withoutVo.
@Test
public void getUsersPage_withoutVo() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_withoutVo");
User user = setUpUser("john", "smith");
User user2 = setUpUser("jane", "smith");
UsersPageQuery query = new UsersPageQuery(10, 0, SortingOrder.ASCENDING, UsersOrderColumn.ID, true);
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_facilityVoService.
@Test
public void getUsersPage_facilityVoService() throws Exception {
System.out.println(CLASS_NAME + "getUsersPage_facilityVoService");
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);
Service service = new Service(0, "dummy_service");
service = perun.getServicesManagerBl().createService(sess, service);
perun.getResourcesManagerBl().assignService(sess, r, service);
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(), vo.getId(), service.getId(), null);
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()))));
}
Aggregations