use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroupsByOwner.
@Test
public void findBusinessGroupsByOwner() {
// 5 identities
String marker = UUID.randomUUID().toString();
Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser(marker);
Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("ddao-2-" + marker);
Identity id3 = JunitTestHelper.createAndPersistIdentityAsUser(marker + "-ddao-3");
Identity id4 = JunitTestHelper.createAndPersistIdentityAsUser("something-else-ddao-4");
BusinessGroup group1 = businessGroupDao.createAndPersist(id1, "fingbgown-1", "fingbgown-1-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(id2, "fingbgown-2", "fingbgown-2-desc", 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(id3, "fingbgown-3", "fingbgown-3-desc", 0, 5, true, false, true, false, false);
BusinessGroup group4 = businessGroupDao.createAndPersist(id4, "fingbgown-4", "fingbgown-4-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));
Assert.assertFalse(contains(groupViews, group4));
}
use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroupsByIdentity.
@Test
public void findBusinessGroupsByIdentity() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("is-in-grp-" + UUID.randomUUID().toString());
BusinessGroup group1 = businessGroupDao.createAndPersist(id, "is-in-grp-1", "is-in-grp-1-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "is-in-grp-2", "is-in-grp-2-desc", 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "is-in-grp-3", "is-in-grp-3-desc", 0, 5, true, false, true, false, false);
dbInstance.commitAndCloseSession();
businessGroupRelationDao.addRole(id, group2, GroupRoles.participant.name());
businessGroupRelationDao.addRole(id, group3, GroupRoles.waiting.name());
dbInstance.commitAndCloseSession();
// check owner
SearchBusinessGroupParams paramsOwner = new SearchBusinessGroupParams();
paramsOwner.setIdentity(id);
paramsOwner.setOwner(true);
List<BusinessGroup> ownedGroups = businessGroupDao.findBusinessGroups(paramsOwner, null, 0, 0);
Assert.assertNotNull(ownedGroups);
Assert.assertEquals(1, ownedGroups.size());
Assert.assertTrue(ownedGroups.contains(group1));
// check attendee
SearchBusinessGroupParams paramsAttendee = new SearchBusinessGroupParams();
paramsAttendee.setIdentity(id);
paramsAttendee.setAttendee(true);
List<BusinessGroup> attendeeGroups = businessGroupDao.findBusinessGroups(paramsAttendee, null, 0, 0);
Assert.assertNotNull(attendeeGroups);
Assert.assertEquals(1, attendeeGroups.size());
Assert.assertTrue(attendeeGroups.contains(group2));
// check waiting
SearchBusinessGroupParams paramsWaiting = new SearchBusinessGroupParams();
paramsWaiting.setIdentity(id);
paramsWaiting.setWaiting(true);
List<BusinessGroup> waitingGroups = businessGroupDao.findBusinessGroups(paramsWaiting, null, 0, 0);
Assert.assertNotNull(waitingGroups);
Assert.assertEquals(1, waitingGroups.size());
Assert.assertTrue(waitingGroups.contains(group3));
// check all
SearchBusinessGroupParams paramsAll = new SearchBusinessGroupParams();
paramsAll.setIdentity(id);
paramsAll.setOwner(true);
paramsAll.setAttendee(true);
paramsAll.setWaiting(true);
List<BusinessGroup> allGroups = businessGroupDao.findBusinessGroups(paramsAll, null, 0, 0);
Assert.assertNotNull(allGroups);
Assert.assertEquals(3, allGroups.size());
Assert.assertTrue(allGroups.contains(group1));
Assert.assertTrue(allGroups.contains(group2));
Assert.assertTrue(allGroups.contains(group3));
// The same tests with the views
// check owner on views
BusinessGroupQueryParams queryParamsOwner = new BusinessGroupQueryParams();
queryParamsOwner.setOwner(true);
List<BusinessGroupRow> ownedGroupViews = businessGroupDao.searchBusinessGroupsWithMemberships(queryParamsOwner, id);
Assert.assertNotNull(ownedGroupViews);
Assert.assertEquals(1, ownedGroupViews.size());
Assert.assertTrue(contains(ownedGroupViews, group1));
// check attendee on views
BusinessGroupQueryParams queryParamsAttendee = new BusinessGroupQueryParams();
queryParamsAttendee.setAttendee(true);
List<BusinessGroupRow> attendeeGroupViews = businessGroupDao.searchBusinessGroupsWithMemberships(queryParamsAttendee, id);
Assert.assertNotNull(attendeeGroupViews);
Assert.assertEquals(1, attendeeGroupViews.size());
Assert.assertTrue(contains(attendeeGroupViews, group2));
// check waiting on views
BusinessGroupQueryParams queryParamsWaiting = new BusinessGroupQueryParams();
queryParamsWaiting.setWaiting(true);
List<BusinessGroupRow> waitingGroupViews = businessGroupDao.searchBusinessGroupsWithMemberships(queryParamsWaiting, id);
Assert.assertNotNull(waitingGroupViews);
Assert.assertEquals(1, waitingGroupViews.size());
Assert.assertTrue(contains(waitingGroupViews, group3));
// check all on views
BusinessGroupQueryParams queryParamsAll = new BusinessGroupQueryParams();
queryParamsAll.setOwner(true);
queryParamsAll.setAttendee(true);
queryParamsAll.setWaiting(true);
List<BusinessGroupRow> allGroupViews = businessGroupDao.searchBusinessGroupsWithMemberships(queryParamsAll, id);
Assert.assertNotNull(allGroupViews);
Assert.assertEquals(3, allGroupViews.size());
Assert.assertTrue(contains(allGroupViews, group1));
Assert.assertTrue(contains(allGroupViews, group2));
Assert.assertTrue(contains(allGroupViews, group3));
}
use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupDAOTest method findPublicGroups.
@Test
public void findPublicGroups() {
// create a group with an access control
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-11");
BusinessGroup group = businessGroupDao.createAndPersist(null, "access-grp-1", "access-grp-1-desc", 0, 5, true, false, true, false, false);
// create and save an offer
Offer offer = acService.createOffer(group.getResource(), "TestBGWorkflow");
assertNotNull(offer);
offer = acService.save(offer);
acMethodManager.enableMethod(TokenAccessMethod.class, true);
List<AccessMethod> methods = acMethodManager.getAvailableMethodsByType(TokenAccessMethod.class);
AccessMethod method = methods.get(0);
OfferAccess access = acMethodManager.createOfferAccess(offer, method);
acMethodManager.save(access);
dbInstance.commitAndCloseSession();
// retrieve the offer
// check the search with the views
BusinessGroupQueryParams queryAllParams = new BusinessGroupQueryParams();
queryAllParams.setPublicGroups(Boolean.TRUE);
List<OpenBusinessGroupRow> accessGroupViews = businessGroupDao.searchPublishedBusinessGroups(queryAllParams, identity);
Assert.assertNotNull(accessGroupViews);
Assert.assertTrue(accessGroupViews.size() >= 1);
Assert.assertTrue(contains(accessGroupViews, group));
for (OpenBusinessGroupRow accessGroup : accessGroupViews) {
OLATResource resource = resourceManager.findResourceById(accessGroup.getResourceKey());
List<Offer> offers = acService.findOfferByResource(resource, true, new Date());
Assert.assertNotNull(offers);
Assert.assertFalse(offers.isEmpty());
}
}
use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroupsByNameFuzzy.
@Test
public void findBusinessGroupsByNameFuzzy() {
String marker = UUID.randomUUID().toString();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-3");
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);
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));
// 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));
}
use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroupsByNameOrDesc.
@Test
public void findBusinessGroupsByNameOrDesc() {
String marker = UUID.randomUUID().toString();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-6");
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "fingbg-1", marker.toUpperCase() + "-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "fingbg-2", "fingbg-2-desc", 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, marker.toUpperCase() + "-xxx", "desc-fingb-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(2, groups.size());
Assert.assertTrue(groups.contains(group1));
Assert.assertFalse(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(2, groupViews.size());
Assert.assertTrue(contains(groupViews, group1));
Assert.assertFalse(contains(groupViews, group2));
Assert.assertTrue(contains(groupViews, group3));
}
Aggregations