use of org.olat.repository.model.SearchRepositoryEntryParameters in project openolat by klemens.
the class RepositoryManagerQueryTest method testOneShootWithInstitution.
@Test
public void testOneShootWithInstitution() {
List<String> types = Collections.singletonList(TEST_RES_NAME);
// roles: institution manager
Roles role3 = new Roles(false, false, false, true, false, true, false);
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(null, null, null, types, null, role3, "Volks");
List<RepositoryEntry> resultOneShootInstitut3 = rm.genericANDQueryWithRolesRestriction(params, 0, -1, true);
assertNotNull(resultOneShootInstitut3);
assertFalse(resultOneShootInstitut3.isEmpty());
}
use of org.olat.repository.model.SearchRepositoryEntryParameters in project openolat by klemens.
the class RepositoryManagerQueryTest method testOneShootQueryPaging.
@Test
public void testOneShootQueryPaging() {
List<String> types = Collections.singletonList(TEST_RES_NAME);
// roles: institution manager search: authorname
Roles role4 = new Roles(false, false, false, false, false, true, false);
// test paging
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(null, "kan", null, types, null, role4, "Volks");
List<RepositoryEntry> resultOneShootInstitut6 = rm.genericANDQueryWithRolesRestriction(params, 0, 50, true);
rm.countGenericANDQueryWithRolesRestriction(params);
assertNotNull(resultOneShootInstitut6);
assertEquals(50, resultOneShootInstitut6.size());
}
use of org.olat.repository.model.SearchRepositoryEntryParameters in project openolat by klemens.
the class RepositoryManagerQueryTest method testOneShootQueryWithRoles.
@Test
public void testOneShootQueryWithRoles() {
List<String> types = Collections.singletonList(TEST_RES_NAME);
// roles: author + institution manager
Roles role2 = new Roles(false, false, false, true, false, true, false);
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(null, null, null, types, admin, role2, "Volks");
List<RepositoryEntry> resultOneShootInstitut = rm.genericANDQueryWithRolesRestriction(params, 0, -1, true);
assertNotNull(resultOneShootInstitut);
assertFalse(resultOneShootInstitut.isEmpty());
}
use of org.olat.repository.model.SearchRepositoryEntryParameters in project openolat by klemens.
the class RepositoryManagerQueryTest method testOneShootWithInstitutionAndSearchByAuthorName.
@Test
public void testOneShootWithInstitutionAndSearchByAuthorName() {
List<String> types = Collections.singletonList(TEST_RES_NAME);
// roles: institution manager search: authorname
Roles role4 = new Roles(false, false, false, false, false, true, false);
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(null, "kan", null, types, null, role4, "Volks");
List<RepositoryEntry> resultOneShootInstitut4 = rm.genericANDQueryWithRolesRestriction(params, 0, -1, true);
assertNotNull(resultOneShootInstitut4);
assertFalse(resultOneShootInstitut4.isEmpty());
}
use of org.olat.repository.model.SearchRepositoryEntryParameters in project openolat by klemens.
the class RepositoryManagerTest method genericANDQueryWithRolesWithStandardUser.
@Test
public void genericANDQueryWithRolesWithStandardUser() {
// create 2 identities (repo owner and tutor)
Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("re-gen-1-" + UUID.randomUUID().toString());
Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("re-gen-2-" + UUID.randomUUID().toString());
RepositoryEntry re1 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry re2 = JunitTestHelper.createAndPersistRepositoryEntry(true);
repositoryEntryRelationDao.addRole(id1, re2, GroupRoles.participant.name());
BusinessGroup group = businessGroupService.createBusinessGroup(null, "teacherg", "tg", null, null, false, false, re1);
businessGroupRelationDao.addRole(id2, group, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// check for guest (negative test)
SearchRepositoryEntryParameters params1 = new SearchRepositoryEntryParameters();
params1.setRoles(new Roles(false, false, false, false, true, false, false));
List<RepositoryEntry> entries1 = repositoryManager.genericANDQueryWithRolesRestriction(params1, 0, -1, true);
Assert.assertNotNull(entries1);
Assert.assertFalse(entries1.contains(re1));
Assert.assertFalse(entries1.contains(re2));
for (RepositoryEntry entry : entries1) {
Assert.assertTrue(entry.getAccess() >= RepositoryEntry.ACC_USERS_GUESTS);
}
// check for identity 1 (participant re2 + re1 accessible to all users)
SearchRepositoryEntryParameters params2 = new SearchRepositoryEntryParameters();
params2.setIdentity(id1);
params2.setRoles(new Roles(false, false, false, false, false, false, false));
List<RepositoryEntry> entries2 = repositoryManager.genericANDQueryWithRolesRestriction(params2, 0, -1, true);
Assert.assertNotNull(entries2);
Assert.assertFalse(entries2.isEmpty());
Assert.assertTrue(entries2.contains(re1));
Assert.assertTrue(entries2.contains(re2));
for (RepositoryEntry entry : entries2) {
if (!entry.equals(re2)) {
Assert.assertTrue(entry.getAccess() >= RepositoryEntry.ACC_USERS);
}
}
// check for identity 1 (re1 accessible to all users)
SearchRepositoryEntryParameters params3 = new SearchRepositoryEntryParameters();
params3.setIdentity(id2);
params3.setRoles(new Roles(false, false, false, false, false, false, false));
List<RepositoryEntry> entries3 = repositoryManager.genericANDQueryWithRolesRestriction(params3, 0, -1, true);
Assert.assertNotNull(entries3);
Assert.assertFalse(entries3.isEmpty());
Assert.assertTrue(entries3.contains(re1));
Assert.assertFalse(entries3.contains(re2));
for (RepositoryEntry entry : entries3) {
Assert.assertTrue(entry.getAccess() >= RepositoryEntry.ACC_USERS);
}
}
Aggregations