use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class RepositoryManagerTest method getLearningResourcesAsStudentWithGroups.
@Test
public void getLearningResourcesAsStudentWithGroups() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("re-stud-lb-" + UUID.randomUUID().toString());
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group = businessGroupService.createBusinessGroup(null, "studg", "tg", null, null, false, false, re);
businessGroupRelationDao.addRole(id, group, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
List<RepositoryEntry> entries = repositoryManager.getLearningResourcesAsStudent(id, null, 0, -1);
Assert.assertNotNull(entries);
Assert.assertFalse(entries.isEmpty());
Assert.assertTrue(entries.contains(re));
Set<Long> duplicates = new HashSet<Long>();
for (RepositoryEntry entry : entries) {
Assert.assertTrue(duplicates.add(entry.getKey()));
if (!entry.equals(re)) {
Assert.assertTrue(entry.getAccess() >= RepositoryEntry.ACC_USERS);
}
}
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class RepositoryManagerTest method queryByTypeLimitAccess.
@Test
public void queryByTypeLimitAccess() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("qbtla-1-" + UUID.randomUUID().toString());
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry(true);
BusinessGroup group = businessGroupService.createBusinessGroup(null, "qbtla-1", "tg", null, null, false, false, re);
businessGroupRelationDao.addRole(id, group, GroupRoles.coach.name());
dbInstance.commitAndCloseSession();
// check
List<String> types = Collections.singletonList(re.getOlatResource().getResourceableTypeName());
List<RepositoryEntry> entries = repositoryManager.queryByTypeLimitAccess(id, types, new Roles(false, false, false, false, false, false, false));
Assert.assertNotNull(entries);
Assert.assertFalse(entries.isEmpty());
Assert.assertTrue(entries.contains(re));
for (RepositoryEntry entry : entries) {
if (!entry.equals(re)) {
Assert.assertTrue(entry.getAccess() >= RepositoryEntry.ACC_USERS);
}
}
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class RepositoryEntryMembershipProcessorTest method testRemoveCoach_withBusinessGroups.
@Test
public void testRemoveCoach_withBusinessGroups() {
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
// create a group with members
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("remp-proc-1");
Identity member = JunitTestHelper.createAndPersistIdentityAsRndUser("remp-proc-2");
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("mbr-proc-3");
repositoryEntryRelationDao.addRole(owner, re, GroupRoles.owner.name());
repositoryEntryRelationDao.addRole(member, re, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(coach, re, GroupRoles.coach.name());
BusinessGroup businessGroup = businessGroupDao.createAndPersist(coach, "mbr-proc-1", "mbr-proc-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRelationToResource(businessGroup, re);
// create a publisher
SubscriptionContext context = new SubscriptionContext(re.getOlatResource(), "");
PublisherData publisherData = new PublisherData("testGroupPublishers", "e.g. something", null);
Publisher publisher = notificationManager.getOrCreatePublisher(context, publisherData);
Assert.assertNotNull(publisher);
dbInstance.commitAndCloseSession();
// subscribe
notificationManager.subscribe(owner, context, publisherData);
notificationManager.subscribe(member, context, publisherData);
notificationManager.subscribe(coach, context, publisherData);
dbInstance.commitAndCloseSession();
// remove member and coach as coach of the repo entry
List<Identity> removeIdentities = new ArrayList<>(2);
removeIdentities.add(member);
removeIdentities.add(coach);
repositoryManager.removeTutors(owner, removeIdentities, re, new MailPackage(false));
// wait for the remove of subscription
waitForCondition(new CheckUnsubscription(member, context, dbInstance, notificationManager), 5000);
sleep(1000);
// check that subscription of id1 was deleted but not the ones of id2 and coach
boolean subscribedMember = notificationManager.isSubscribed(member, context);
Assert.assertFalse(subscribedMember);
boolean subscribedCoach = notificationManager.isSubscribed(coach, context);
Assert.assertTrue(subscribedCoach);
boolean subscribedOwner = notificationManager.isSubscribed(owner, context);
Assert.assertTrue(subscribedOwner);
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class RepositoryEntryRelationDAOTest method getMembers_follow.
@Test
public void getMembers_follow() {
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("member-1-");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("member-2-");
Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("member-3-");
Identity id4 = JunitTestHelper.createAndPersistIdentityAsRndUser("member-4-");
RepositoryEntry re1 = repositoryService.create("Rei Ayanami", "rel", "rel", null, null);
RepositoryEntry re2 = repositoryService.create("Rei Ayanami (alt)", "rel", "rel", null, null);
dbInstance.commit();
repositoryEntryRelationDao.addRole(id1, re1, GroupRoles.owner.name());
repositoryEntryRelationDao.addRole(id2, re1, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(id3, re2, GroupRoles.participant.name());
dbInstance.commit();
BusinessGroup group = businessGroupService.createBusinessGroup(null, "group", "tg", null, null, true, false, re2);
businessGroupRelationDao.addRole(id4, group, GroupRoles.coach.name());
dbInstance.commit();
List<RepositoryEntry> res = new ArrayList<>();
res.add(re1);
res.add(re2);
// all members
List<Identity> coaches = repositoryEntryRelationDao.getMembers(res, RepositoryEntryRelationType.both, GroupRoles.coach.name());
Assert.assertNotNull(coaches);
Assert.assertEquals(1, coaches.size());
Assert.assertTrue(coaches.contains(id4));
// participant
List<Identity> participants = repositoryEntryRelationDao.getMembers(res, RepositoryEntryRelationType.defaultGroup, GroupRoles.participant.name());
Assert.assertNotNull(participants);
Assert.assertEquals(2, participants.size());
Assert.assertTrue(participants.contains(id2));
Assert.assertTrue(participants.contains(id3));
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class RepositoryEntryRelationDAOTest method removeRelation_byGroup.
@Test
public void removeRelation_byGroup() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("re-member-lc-" + UUID.randomUUID().toString());
RepositoryEntry re1 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry re2 = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group = businessGroupService.createBusinessGroup(null, "remove relation by group", "tg", null, null, false, false, re1);
businessGroupRelationDao.addRole(id, group, GroupRoles.coach.name());
businessGroupService.addResourceTo(group, re2);
dbInstance.commitAndCloseSession();
int numOfRelations = repositoryEntryRelationDao.removeRelation(group.getBaseGroup());
Assert.assertEquals(2, numOfRelations);
dbInstance.commitAndCloseSession();
List<Group> groups = Collections.singletonList(group.getBaseGroup());
List<RepositoryEntryToGroupRelation> relations = repositoryEntryRelationDao.getRelations(groups);
Assert.assertEquals(0, relations.size());
}
Aggregations