use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class RepositoryEntryRelationDAOTest method isMember.
@Test
public void isMember() {
Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("re-member-lc-" + UUID.randomUUID().toString());
Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("re-member-lc-" + UUID.randomUUID().toString());
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group = businessGroupService.createBusinessGroup(null, "memberg", "tg", null, null, false, false, re);
businessGroupRelationDao.addRole(id1, group, GroupRoles.coach.name());
dbInstance.commitAndCloseSession();
// id1 is member
boolean member1 = repositoryEntryRelationDao.isMember(id1, re);
Assert.assertTrue(member1);
// id2 is not member
boolean member2 = repositoryEntryRelationDao.isMember(id2, re);
Assert.assertFalse(member2);
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class RepositoryServiceImplTest method deleteCourseSoftly.
@Test
public void deleteCourseSoftly() {
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("re-soft-");
Identity coachGroup = JunitTestHelper.createAndPersistIdentityAsRndUser("re-soft-");
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("re-soft-");
Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("auth-del-1");
RepositoryEntry re = JunitTestHelper.deployDemoCourse(initialAuthor);
dbInstance.commitAndCloseSession();
// add business group
BusinessGroup group = businessGroupService.createBusinessGroup(coachGroup, "Relation 1", "tg", null, null, false, false, re);
businessGroupService.addResourceTo(group, re);
dbInstance.commit();
// catalog
List<CatalogEntry> rootEntries = catalogManager.getRootCatalogEntries();
CatalogEntry catEntry = catalogManager.createCatalogEntry();
catEntry.setName("Soft");
catEntry.setRepositoryEntry(re);
catEntry.setParent(rootEntries.get(0));
catEntry.setOwnerGroup(securityManager.createAndPersistSecurityGroup());
catalogManager.saveCatalogEntry(catEntry);
dbInstance.commit();
// check the catalog
List<CatalogEntry> catEntries = catalogManager.getCatalogCategoriesFor(re);
Assert.assertNotNull(catEntries);
Assert.assertEquals(1, catEntries.size());
// add owner, coach...
repositoryEntryRelationDao.addRole(coach, re, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(participant, re, GroupRoles.participant.name());
dbInstance.commit();
// kill it softly like A. Keys
repositoryService.deleteSoftly(re, initialAuthor, false);
dbInstance.commit();
// check that the members are removed
List<Identity> coachAndParticipants = repositoryEntryRelationDao.getMembers(re, RepositoryEntryRelationType.both, GroupRoles.coach.name(), GroupRoles.participant.name());
Assert.assertNotNull(coachAndParticipants);
Assert.assertEquals(0, coachAndParticipants.size());
// check the relations between course and business groups
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
List<BusinessGroup> groups = businessGroupService.findBusinessGroups(params, re, 0, -1);
Assert.assertNotNull(groups);
Assert.assertEquals(0, groups.size());
// check the catalog
List<CatalogEntry> removedCatEntries = catalogManager.getCatalogCategoriesFor(re);
Assert.assertNotNull(removedCatEntries);
Assert.assertEquals(0, removedCatEntries.size());
RepositoryEntry reloadEntry = repositoryService.loadByKey(re.getKey());
Assert.assertNotNull(reloadEntry);
Assert.assertEquals(0, reloadEntry.getAccess());
Assert.assertNotNull(reloadEntry.getDeletionDate());
Assert.assertEquals(initialAuthor, reloadEntry.getDeletedBy());
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class PoolDAOTest method isMemberOfPrivatePools_negativeTest.
@Test
public void isMemberOfPrivatePools_negativeTest() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsUser("Pool-owner-" + UUID.randomUUID().toString());
Identity somebody = JunitTestHelper.createAndPersistIdentityAsUser("Somebody-" + UUID.randomUUID().toString());
// pool
Pool pool = poolDao.createPool(owner, "NGC owned", false);
Assert.assertNotNull(pool);
// group without item
BusinessGroup group = businessGroupDao.createAndPersist(owner, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRole(somebody, group, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
boolean isMember = poolDao.isMemberOfPrivatePools(somebody);
Assert.assertFalse(isMember);
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class PoolDAOTest method isMemberOfPrivatePools_groupOnly.
@Test
public void isMemberOfPrivatePools_groupOnly() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsUser("Group-owner-" + UUID.randomUUID().toString());
Identity participant = JunitTestHelper.createAndPersistIdentityAsUser("Group-participant-" + UUID.randomUUID().toString());
// create a group to share 2 items
QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
BusinessGroup group = businessGroupDao.createAndPersist(owner, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
QuestionItem item = questionDao.createAndPersist(owner, "Shared-Item-1", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
questionDao.share(item, group.getResource());
businessGroupRelationDao.addRole(participant, group, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
Assert.assertNotNull(item);
Assert.assertNotNull(group);
// retrieve them
boolean isOwnerMember = poolDao.isMemberOfPrivatePools(owner);
Assert.assertTrue(isOwnerMember);
boolean isParticipantMember = poolDao.isMemberOfPrivatePools(participant);
Assert.assertTrue(isParticipantMember);
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method getSharedItemByResource.
@Test
public void getSharedItemByResource() {
// create a group to share 2 items
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("QShare-2-" + UUID.randomUUID());
BusinessGroup group1 = businessGroupDao.createAndPersist(id, "gdao-1", "gdao-desc", -1, -1, false, false, false, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(id, "gdao-2", "gdao-desc", -1, -1, false, false, false, false, false);
QuestionItem item = questionDao.createAndPersist(id, "Share-Item-3", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
dbInstance.commit();
// share them
List<OLATResource> resources = new ArrayList<>();
resources.add(group1.getResource());
resources.add(group2.getResource());
questionDao.share(item, resources, false);
// retrieve them
List<QuestionItemView> sharedItems1 = qItemQueriesDao.getSharedItemByResource(id, group1.getResource(), null, null, 0, -1);
Assert.assertNotNull(sharedItems1);
Assert.assertEquals(1, sharedItems1.size());
Assert.assertEquals(item.getKey(), sharedItems1.get(0).getKey());
List<QuestionItemView> sharedItems2 = qItemQueriesDao.getSharedItemByResource(id, group2.getResource(), null, null, 0, -1);
Assert.assertNotNull(sharedItems2);
Assert.assertEquals(1, sharedItems2.size());
Assert.assertEquals(item.getKey(), sharedItems2.get(0).getKey());
}
Aggregations