use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroupsByDescriptionFuzzy.
@Test
public void findBusinessGroupsByDescriptionFuzzy() {
String marker = UUID.randomUUID().toString();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-5");
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "fingbg-1", marker + "-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "fingbg-2", "desc-" + marker.toUpperCase(), 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "fingbg-3", "desc-" + marker + "-desc", 0, 5, true, false, true, false, false);
dbInstance.commitAndCloseSession();
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setDescription("*" + marker + "*");
List<BusinessGroup> groups = businessGroupDao.findBusinessGroups(params, null, 0, -1);
Assert.assertNotNull(groups);
Assert.assertEquals(3, groups.size());
Assert.assertTrue(groups.contains(group1));
Assert.assertTrue(groups.contains(group2));
Assert.assertTrue(groups.contains(group3));
// check same search with the views
BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
searchParams.setDescription("*" + marker + "*");
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, identity);
Assert.assertNotNull(groupViews);
Assert.assertEquals(3, groupViews.size());
Assert.assertTrue(contains(groupViews, group1));
Assert.assertTrue(contains(groupViews, group2));
Assert.assertTrue(contains(groupViews, group3));
}
use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroupsByCourseTitle.
@Test
public void findBusinessGroupsByCourseTitle() {
// create a repository entry with a relation to a group
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("re-grp-1-" + UUID.randomUUID().toString());
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group = businessGroupDao.createAndPersist(id, "grp-course-1", "grp-course-1-desc", 0, 5, true, false, true, false, false);
businessGroupRelationDao.addRole(id, group, GroupRoles.participant.name());
businessGroupRelationDao.addRelationToResource(group, re);
dbInstance.commitAndCloseSession();
// retrieve the group through its relation
BusinessGroupQueryParams params = new BusinessGroupQueryParams();
params.setOwner(true);
params.setAttendee(true);
params.setWaiting(true);
params.setCourseTitle(re.getDisplayname());
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(params, id);
Assert.assertNotNull(groupViews);
Assert.assertEquals(1, groupViews.size());
Assert.assertEquals(group.getKey(), groupViews.get(0).getKey());
}
use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroups.
@Test
public void findBusinessGroups() {
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search");
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "gduo", "gduo-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "gdvo", "gdvo-desc", 0, 5, true, false, true, false, false);
dbInstance.commitAndCloseSession();
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
List<BusinessGroup> groups = businessGroupDao.findBusinessGroups(params, null, 0, -1);
Assert.assertNotNull(groups);
Assert.assertTrue(groups.size() >= 2);
Assert.assertTrue(groups.contains(group1));
Assert.assertTrue(groups.contains(group2));
BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, identity);
Assert.assertNotNull(groupViews);
Assert.assertTrue(groupViews.size() >= 2);
Assert.assertTrue(contains(groupViews, group1));
Assert.assertTrue(contains(groupViews, group2));
List<StatisticsBusinessGroupRow> groupToSelect = businessGroupDao.searchBusinessGroupsForSelection(searchParams, identity);
Assert.assertNotNull(groupToSelect);
Assert.assertTrue(groupToSelect.size() >= 2);
List<OpenBusinessGroupRow> openGroups = businessGroupDao.searchPublishedBusinessGroups(searchParams, identity);
Assert.assertNotNull(openGroups);
}
use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroupWithAuthorConnection.
@Test
public void findBusinessGroupWithAuthorConnection() {
Identity author = JunitTestHelper.createAndPersistIdentityAsUser("bdao-5-" + UUID.randomUUID().toString());
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
repositoryEntryRelationDao.addRole(author, re, GroupRoles.owner.name());
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "gdlo", "gdlo-desc", 0, 5, true, false, false, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(author, "gdmo", "gdmo-desc", 0, 5, true, false, false, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(author, "gdmo", "gdmo-desc", 0, 5, true, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group1, re);
businessGroupRelationDao.addRelationToResource(group3, re);
dbInstance.commitAndCloseSession();
// check
BusinessGroupQueryParams params = new BusinessGroupQueryParams();
params.setAuthorConnection(true);
List<StatisticsBusinessGroupRow> groups = businessGroupDao.searchBusinessGroupsForSelection(params, author);
Assert.assertNotNull(groups);
Assert.assertEquals(2, groups.size());
Set<Long> retrievedGroupkey = new HashSet<Long>();
for (StatisticsBusinessGroupRow group : groups) {
retrievedGroupkey.add(group.getKey());
}
Assert.assertTrue(retrievedGroupkey.contains(group1.getKey()));
Assert.assertTrue(retrievedGroupkey.contains(group3.getKey()));
Assert.assertFalse(retrievedGroupkey.contains(group2.getKey()));
}
use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroupsByDescription.
@Test
public void findBusinessGroupsByDescription() {
String marker = UUID.randomUUID().toString();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-4");
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "fingbg-1", marker.toUpperCase() + "-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "fingbg-2", "desc-" + marker, 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "fingbg-3", "desc-other-one", 0, 5, true, false, true, false, false);
dbInstance.commitAndCloseSession();
// check find business group
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setDescription(marker);
List<BusinessGroup> groups = businessGroupDao.findBusinessGroups(params, null, 0, -1);
Assert.assertNotNull(groups);
Assert.assertEquals(2, groups.size());
Assert.assertTrue(groups.contains(group1));
Assert.assertTrue(groups.contains(group2));
Assert.assertFalse(groups.contains(group3));
// check find business group
BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
searchParams.setDescription(marker);
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, identity);
Assert.assertNotNull(groupViews);
Assert.assertEquals(2, groupViews.size());
Assert.assertTrue(contains(groupViews, group1));
Assert.assertTrue(contains(groupViews, group2));
Assert.assertFalse(contains(groupViews, group3));
}
Aggregations