use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroupsByOwnerFuzzy.
@Test
public void findBusinessGroupsByOwnerFuzzy() {
String marker = UUID.randomUUID().toString();
Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser(marker);
Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("ddao-2-" + marker.toUpperCase());
Identity id3 = JunitTestHelper.createAndPersistIdentityAsUser(marker + "-ddao-3-");
BusinessGroup group1 = businessGroupDao.createAndPersist(id1, "fingbg-own-1-1", "fingbg-own-1-1-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(id2, "fingbg-own-1-2", "fingbg-own-1-2-desc", 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(id3, "fingbg-own-1-3", "fingbg-own-1-3-desc", 0, 5, true, false, true, false, false);
dbInstance.commitAndCloseSession();
// check the same with the views
BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
searchParams.setOwnerName("*" + marker + "*");
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, id1);
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 findBusinessGroupsByNameOrDescFuzzy.
@Test
public void findBusinessGroupsByNameOrDescFuzzy() {
String marker = UUID.randomUUID().toString();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-7");
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.setNameOrDesc("*" + 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 the same search with the views
BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
searchParams.setNameOrDesc("*" + 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 findMarkedBusinessGroupCrossContamination.
@Test
public void findMarkedBusinessGroupCrossContamination() {
Identity marker1 = JunitTestHelper.createAndPersistIdentityAsUser("marker-1-" + UUID.randomUUID().toString());
Identity marker2 = JunitTestHelper.createAndPersistIdentityAsUser("marker-2-" + UUID.randomUUID().toString());
// create a group with a mark and an other without as control
BusinessGroup group1 = businessGroupDao.createAndPersist(marker1, "marked-grp-3", "marked-grp-1-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(marker1, "marked-grp-4", "marked-grp-2-desc", 0, 5, true, false, true, false, false);
markManager.setMark(group1.getResource(), marker1, null, "[BusinessGroup:" + group1.getKey() + "]");
markManager.setMark(group2.getResource(), marker2, null, "[BusinessGroup:" + group2.getKey() + "]");
dbInstance.commitAndCloseSession();
// check the search with views
// check marked
BusinessGroupQueryParams queryParamsMarker1 = new BusinessGroupQueryParams();
queryParamsMarker1.setMarked(true);
List<BusinessGroupRow> markedGroupViews = businessGroupDao.searchBusinessGroupsWithMemberships(queryParamsMarker1, marker1);
Assert.assertNotNull(markedGroupViews);
Assert.assertEquals(1, markedGroupViews.size());
Assert.assertTrue(contains(markedGroupViews, group1));
}
use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroupsByName.
@Test
public void findBusinessGroupsByName() {
String marker = UUID.randomUUID().toString();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-2");
BusinessGroup group1 = businessGroupDao.createAndPersist(null, marker.toUpperCase(), "fingbg-1-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, marker + "xxx", "fingbg-2-desc", 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "yyy" + marker.toUpperCase(), "fingbg-3-desc", 0, 5, true, false, true, false, false);
BusinessGroup group4 = businessGroupDao.createAndPersist(null, "yyyyZZZxxx", "fingbg-3-desc", 0, 5, true, false, true, false, false);
dbInstance.commitAndCloseSession();
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setName(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));
Assert.assertFalse(groups.contains(group4));
// check the same with the views
BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
searchParams.setName(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));
Assert.assertFalse(contains(groupViews, group4));
}
use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroupsByRepositoryEntry.
@Test
public void findBusinessGroupsByRepositoryEntry() {
// 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.setRepositoryEntry(re);
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(params, id);
Assert.assertNotNull(groupViews);
Assert.assertEquals(1, groupViews.size());
Assert.assertEquals(group.getKey(), groupViews.get(0).getKey());
}
Aggregations