use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class BusinessGroupRelationDAOTest method addRelation.
@Test
public void addRelation() {
// create a relation
RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group = businessGroupDao.createAndPersist(null, "gdbo", "gdbo-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group, resource);
dbInstance.commitAndCloseSession();
// check
List<RepositoryEntry> resources = businessGroupRelationDao.findRepositoryEntries(Collections.singletonList(group), 0, -1);
Assert.assertNotNull(resources);
Assert.assertEquals(1, resources.size());
Assert.assertTrue(resources.contains(resource));
int count = businessGroupRelationDao.countResources(group);
Assert.assertEquals(1, count);
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class BusinessGroupRelationDAOTest method addGroupsAndRelations.
@Test
public void addGroupsAndRelations() {
// create a relation
RepositoryEntry resource1 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry resource2 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry resource3 = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "rel-bg-1", "rel-bg-1-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group1, resource1);
businessGroupRelationDao.addRelationToResource(group1, resource2);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "rel-bg-2", "rel-bg-2-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group2, resource2);
businessGroupRelationDao.addRelationToResource(group2, resource3);
dbInstance.commitAndCloseSession();
// check group1
List<RepositoryEntry> resources1 = businessGroupRelationDao.findRepositoryEntries(Collections.singletonList(group1), 0, -1);
Assert.assertNotNull(resources1);
Assert.assertEquals(2, resources1.size());
Assert.assertTrue(resources1.contains(resource1));
Assert.assertTrue(resources1.contains(resource2));
Assert.assertFalse(resources1.contains(resource3));
// check group2
List<RepositoryEntry> resources2 = businessGroupRelationDao.findRepositoryEntries(Collections.singletonList(group2), 0, -1);
Assert.assertNotNull(resources2);
Assert.assertEquals(2, resources2.size());
Assert.assertFalse(resources2.contains(resource1));
Assert.assertTrue(resources2.contains(resource2));
Assert.assertTrue(resources2.contains(resource3));
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class BusinessGroupRelationDAOTest method countResourcesOfBusinessGroups.
@Test
public void countResourcesOfBusinessGroups() {
// create 3 entries and 1 group
RepositoryEntry re1 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry re2 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry re3 = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group = businessGroupDao.createAndPersist(null, "rel-repo", "rel-repo-desc", 0, 10, true, false, false, false, false);
dbInstance.commitAndCloseSession();
businessGroupRelationDao.addRelationToResource(group, re1);
businessGroupRelationDao.addRelationToResource(group, re2);
businessGroupRelationDao.addRelationToResource(group, re3);
dbInstance.commitAndCloseSession();
// check with empty list of groups
boolean numOfResources1 = businessGroupRelationDao.hasResources(Collections.<BusinessGroup>emptyList());
Assert.assertFalse(numOfResources1);
// check with the group
boolean numOfResources2 = businessGroupRelationDao.hasResources(Collections.singletonList(group));
Assert.assertTrue(numOfResources2);
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class BusinessGroupRelationDAOTest method getMembers_all.
@Test
public void getMembers_all() {
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("m-1");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("m-2");
Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("m-3");
BusinessGroup group = businessGroupDao.createAndPersist(null, "to-group-1", "to-group-1-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRole(id1, group, GroupRoles.coach.name());
businessGroupRelationDao.addRole(id2, group, GroupRoles.participant.name());
businessGroupRelationDao.addRole(id3, group, GroupRoles.waiting.name());
dbInstance.commitAndCloseSession();
// load all
List<Identity> members = businessGroupRelationDao.getMembers(group);
Assert.assertNotNull(members);
Assert.assertEquals(3, members.size());
Assert.assertTrue(members.contains(id1));
Assert.assertTrue(members.contains(id2));
Assert.assertTrue(members.contains(id3));
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class BusinessGroupRelationDAOTest method loadForUpdate.
@Test
public void loadForUpdate() {
BusinessGroup group = businessGroupDao.createAndPersist(null, "rel-repo", "rel-repo-desc", 0, 10, true, false, false, false, false);
dbInstance.commitAndCloseSession();
BusinessGroup groupToUpdate = businessGroupDao.loadForUpdate(group.getKey());
Assert.assertNotNull(groupToUpdate);
Assert.assertEquals(group, groupToUpdate);
}
Aggregations