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));
}
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));
}
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());
}
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);
}
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);
}
Aggregations