Search in sources :

Example 66 with BGArea

use of org.olat.group.area.BGArea in project OpenOLAT by OpenOLAT.

the class BGAreaManagerTest method addAndFindByResource.

@Test
public void addAndFindByResource() {
    // create a resource, an area, a group
    RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
    String areaName = UUID.randomUUID().toString();
    BGArea area1 = areaManager.createAndPersistBGArea("area-1-" + areaName, "description:" + areaName, resource.getOlatResource());
    BGArea area2 = areaManager.createAndPersistBGArea("area-2-" + areaName, "description:" + areaName, resource.getOlatResource());
    BGArea area3 = areaManager.createAndPersistBGArea("area-3-" + areaName, "description:" + areaName, resource.getOlatResource());
    BusinessGroup group1 = businessGroupService.createBusinessGroup(null, "area-1-group", "area-group-desc", 0, -1, false, false, resource);
    BusinessGroup group2 = businessGroupService.createBusinessGroup(null, "area-2-group", "area-group-desc", 0, -1, false, false, resource);
    dbInstance.commitAndCloseSession();
    // add the relation
    areaManager.addBGToBGArea(group1, area1);
    areaManager.addBGToBGArea(group2, area2);
    areaManager.addBGToBGArea(group1, area3);
    areaManager.addBGToBGArea(group2, area3);
    dbInstance.commitAndCloseSession();
    // count
    int numOfAreas = areaManager.countBGAreasInContext(resource.getOlatResource());
    Assert.assertEquals(3, numOfAreas);
    // find areas
    List<BGArea> areas = areaManager.findBGAreasInContext(resource.getOlatResource());
    Assert.assertNotNull(areas);
    Assert.assertEquals(3, areas.size());
    Assert.assertTrue(areas.contains(area1));
    Assert.assertTrue(areas.contains(area2));
    Assert.assertTrue(areas.contains(area3));
}
Also used : BGArea(org.olat.group.area.BGArea) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 67 with BGArea

use of org.olat.group.area.BGArea in project OpenOLAT by OpenOLAT.

the class BGAreaManagerTest method addAndFindByGroup.

@Test
public void addAndFindByGroup() {
    // create a resource, an area, a group
    RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
    String areaName = UUID.randomUUID().toString();
    BGArea area1 = areaManager.createAndPersistBGArea("area-1-" + areaName, "description:" + areaName, resource.getOlatResource());
    BGArea area2 = areaManager.createAndPersistBGArea("area-2-" + areaName, "description:" + areaName, resource.getOlatResource());
    BusinessGroup group1 = businessGroupService.createBusinessGroup(null, "area-1-group", "area-group-desc", 0, -1, false, false, resource);
    BusinessGroup group2 = businessGroupService.createBusinessGroup(null, "area-2-group", "area-group-desc", 0, -1, false, false, resource);
    BusinessGroup group3 = businessGroupService.createBusinessGroup(null, "area-3-group", "area-group-desc", 0, -1, false, false, resource);
    dbInstance.commitAndCloseSession();
    // add the relation
    areaManager.addBGToBGArea(group1, area1);
    areaManager.addBGToBGArea(group2, area2);
    areaManager.addBGToBGArea(group3, area1);
    areaManager.addBGToBGArea(group3, area2);
    dbInstance.commitAndCloseSession();
    // check find group 1
    List<BGArea> areasGroup1 = areaManager.findBGAreasOfBusinessGroup(group1);
    Assert.assertNotNull(areasGroup1);
    Assert.assertEquals(1, areasGroup1.size());
    Assert.assertTrue(areasGroup1.contains(area1));
    // check find group 3
    List<BGArea> areasGroup3 = areaManager.findBGAreasOfBusinessGroup(group3);
    Assert.assertNotNull(areasGroup3);
    Assert.assertEquals(2, areasGroup3.size());
    Assert.assertTrue(areasGroup3.contains(area1));
    Assert.assertTrue(areasGroup3.contains(area2));
}
Also used : BGArea(org.olat.group.area.BGArea) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 68 with BGArea

use of org.olat.group.area.BGArea in project OpenOLAT by OpenOLAT.

the class BGAreaManagerTest method testCreateLoadBGArea.

@Test
public void testCreateLoadBGArea() {
    OLATResource resource = JunitTestHelper.createRandomResource();
    String areaName = UUID.randomUUID().toString();
    String description = "description:" + areaName;
    BGArea area = areaManager.createAndPersistBGArea(areaName, description, resource);
    Assert.assertNotNull(area);
    dbInstance.commitAndCloseSession();
    // check by reloading the area
    BGArea reloadedArea = areaManager.reloadArea(area);
    Assert.assertNotNull(reloadedArea);
    Assert.assertNotNull(reloadedArea.getCreationDate());
    Assert.assertNotNull(reloadedArea.getResource());
    Assert.assertEquals(areaName, reloadedArea.getName());
    Assert.assertEquals(description, reloadedArea.getDescription());
    Assert.assertEquals(resource, reloadedArea.getResource());
}
Also used : BGArea(org.olat.group.area.BGArea) OLATResource(org.olat.resource.OLATResource) Test(org.junit.Test)

Example 69 with BGArea

use of org.olat.group.area.BGArea in project OpenOLAT by OpenOLAT.

the class BGAreaManagerTest method testExistArea.

@Test
public void testExistArea() {
    // create a resource with areas
    OLATResource resource = JunitTestHelper.createRandomResource();
    String areaName = UUID.randomUUID().toString();
    BGArea area = areaManager.createAndPersistBGArea("exists-" + areaName, "description:" + areaName, resource);
    dbInstance.commitAndCloseSession();
    // check exist by key
    boolean exist1 = areaManager.existArea(area.getKey().toString(), resource);
    Assert.assertTrue(exist1);
    // check by name
    boolean exist2 = areaManager.existArea(area.getName(), resource);
    Assert.assertTrue(exist2);
    // check negative by key
    boolean exist3 = areaManager.existArea("120", resource);
    Assert.assertFalse(exist3);
    // check negative by key
    boolean exist4 = areaManager.existArea("dummy", resource);
    Assert.assertFalse(exist4);
}
Also used : BGArea(org.olat.group.area.BGArea) OLATResource(org.olat.resource.OLATResource) Test(org.junit.Test)

Example 70 with BGArea

use of org.olat.group.area.BGArea in project OpenOLAT by OpenOLAT.

the class BGAreaManagerTest method deleteBGArea.

@Test
public void deleteBGArea() {
    RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
    String areaName = UUID.randomUUID().toString();
    BGArea area1 = areaManager.createAndPersistBGArea("area-1-" + areaName, "description:" + areaName, resource.getOlatResource());
    BGArea area2 = areaManager.createAndPersistBGArea("area-2-" + areaName, "description:" + areaName, resource.getOlatResource());
    BusinessGroup group1 = businessGroupService.createBusinessGroup(null, "area-1-group", "area-group-desc", 0, -1, false, false, resource);
    BusinessGroup group2 = businessGroupService.createBusinessGroup(null, "area-2-group", "area-group-desc", 0, -1, false, false, resource);
    dbInstance.commitAndCloseSession();
    // add the relations
    areaManager.addBGToBGArea(group1, area1);
    areaManager.addBGToBGArea(group2, area1);
    areaManager.addBGToBGArea(group2, area2);
    dbInstance.commitAndCloseSession();
    // delete area 1
    areaManager.deleteBGArea(area1);
    dbInstance.commitAndCloseSession();
    // check that it's really deleted
    BGArea deletedArea = areaManager.loadArea(area1.getKey());
    Assert.assertNull(deletedArea);
    // but not all areas are deleted
    BGArea reloadedArea2 = areaManager.loadArea(area2.getKey());
    Assert.assertNotNull(reloadedArea2);
}
Also used : BGArea(org.olat.group.area.BGArea) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Aggregations

BGArea (org.olat.group.area.BGArea)124 BusinessGroup (org.olat.group.BusinessGroup)70 Test (org.junit.Test)68 RepositoryEntry (org.olat.repository.RepositoryEntry)52 ArrayList (java.util.ArrayList)22 Identity (org.olat.core.id.Identity)22 BGAreaReference (org.olat.group.model.BGAreaReference)18 AssessmentModeToArea (org.olat.course.assessment.AssessmentModeToArea)16 CourseEnvironmentMapper (org.olat.course.export.CourseEnvironmentMapper)16 HashSet (java.util.HashSet)14 AssessmentMode (org.olat.course.assessment.AssessmentMode)12 BusinessGroupReference (org.olat.group.model.BusinessGroupReference)12 OLATResource (org.olat.resource.OLATResource)12 AssessmentModeToGroup (org.olat.course.assessment.AssessmentModeToGroup)10 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)8 CollaborationTools (org.olat.collaboration.CollaborationTools)6 BusinessGroupShort (org.olat.group.BusinessGroupShort)6 File (java.io.File)4 IOException (java.io.IOException)4 Field (java.lang.reflect.Field)4