Search in sources :

Example 41 with BusinessGroup

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);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 42 with BusinessGroup

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));
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 43 with BusinessGroup

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);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 44 with BusinessGroup

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));
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 45 with BusinessGroup

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);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) Test(org.junit.Test)

Aggregations

BusinessGroup (org.olat.group.BusinessGroup)1034 Test (org.junit.Test)536 Identity (org.olat.core.id.Identity)536 RepositoryEntry (org.olat.repository.RepositoryEntry)324 ArrayList (java.util.ArrayList)224 BusinessGroupService (org.olat.group.BusinessGroupService)116 SearchBusinessGroupParams (org.olat.group.model.SearchBusinessGroupParams)84 BGArea (org.olat.group.area.BGArea)70 CollaborationTools (org.olat.collaboration.CollaborationTools)58 OLATResource (org.olat.resource.OLATResource)56 Date (java.util.Date)54 HashSet (java.util.HashSet)50 File (java.io.File)46 Path (javax.ws.rs.Path)42 Group (org.olat.basesecurity.Group)42 HashMap (java.util.HashMap)38 Roles (org.olat.core.id.Roles)38 BusinessGroupQueryParams (org.olat.group.model.BusinessGroupQueryParams)38 BusinessGroupRow (org.olat.group.model.BusinessGroupRow)38 StatisticsBusinessGroupRow (org.olat.group.model.StatisticsBusinessGroupRow)38