use of org.olat.group.area.BGArea in project openolat by klemens.
the class KeyAndNameConverterTest method convertGroupAndAreaNameToKey_sameName.
/**
* Test with same name for area and group
*/
@Test
public void convertGroupAndAreaNameToKey_sameName() {
CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
BGArea newArea = new MockArea(567l, "Test 1");
BGAreaReference areaRef = new BGAreaReference(newArea, 345l, "Test 1");
envMapper.getAreas().add(areaRef);
MockBusinessGroup newGroup = new MockBusinessGroup(568l, "Test 1");
BusinessGroupReference bgRef = new BusinessGroupReference(newGroup, 346l, "Test 1");
envMapper.getGroups().add(bgRef);
String convertedExp = convertExpressionNameToKey("inLearningArea(\"Test 1\") & inLearningGroup(\"Test 1\")", envMapper);
Assert.assertEquals("inLearningArea(\"567\") & inLearningGroup(\"568\")", convertedExp);
}
use of org.olat.group.area.BGArea in project openolat by klemens.
the class KeyAndNameConverterTest method convertGroupAndAreaKeyToName_sameKey.
@Test
public void convertGroupAndAreaKeyToName_sameKey() {
CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
BGArea newArea = new MockArea(567l, "Area 1");
BGAreaReference areaRef = new BGAreaReference(newArea, null, null);
envMapper.getAreas().add(areaRef);
MockBusinessGroup newGroup = new MockBusinessGroup(567l, "Group 1");
BusinessGroupReference bgRef = new BusinessGroupReference(newGroup, null, null);
envMapper.getGroups().add(bgRef);
String convertedExp = convertExpressionKeyToName("inLearningArea(\"567\") & isLearningGroupFull(\"567\")", envMapper);
Assert.assertEquals("inLearningArea(\"Area 1\") & isLearningGroupFull(\"Group 1\")", convertedExp);
}
use of org.olat.group.area.BGArea in project openolat by klemens.
the class KeyAndNameConverterTest method convertAreaKeyToName.
@Test
public void convertAreaKeyToName() {
CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
BGArea newArea = new MockArea(567l, "Area 1");
BGAreaReference areaRef = new BGAreaReference(newArea, null, null);
envMapper.getAreas().add(areaRef);
String convertedExp = convertExpressionKeyToName("inLearningArea(\"567\")", envMapper);
Assert.assertEquals("inLearningArea(\"Area 1\")", convertedExp);
}
use of org.olat.group.area.BGArea in project openolat by klemens.
the class KeyAndNameConverterTest method convertGroupAndAreaKeyToKey_sameKey.
@Test
public void convertGroupAndAreaKeyToKey_sameKey() {
CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
BGArea newArea = new MockArea(567l, "Area 1");
BGAreaReference areaRef = new BGAreaReference(newArea, 345l, "Area 1");
envMapper.getAreas().add(areaRef);
MockBusinessGroup newGroup = new MockBusinessGroup(568l, "Group 1");
BusinessGroupReference bgRef = new BusinessGroupReference(newGroup, 345l, "Group 1");
envMapper.getGroups().add(bgRef);
String convertedExp = convertExpressionKeyToKey("inLearningArea(\"345\") & inRightGroup(\"345\")", envMapper);
Assert.assertEquals("inLearningArea(\"567\") & inRightGroup(\"568\")", convertedExp);
}
use of org.olat.group.area.BGArea in project openolat by klemens.
the class BusinessGroupImportExportTest method importLearningGroupsAndAreasWithResource.
@Test
public void importLearningGroupsAndAreasWithResource() throws URISyntaxException {
RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
URL input = BusinessGroupImportExportTest.class.getResource("learninggroupexport_3.xml");
File importXml = new File(input.toURI());
businessGroupService.importGroups(resource, importXml);
dbInstance.commitAndCloseSession();
// check if all three groups are imported
List<BusinessGroup> groups = businessGroupService.findBusinessGroups(null, resource, 0, -1);
Assert.assertNotNull(groups);
Assert.assertEquals(3, groups.size());
// check if all three areas are imported
List<BGArea> areas = areaManager.findBGAreasInContext(resource.getOlatResource());
Assert.assertNotNull(areas);
Assert.assertEquals(3, areas.size());
// check first area
BGArea area1 = areaManager.findBGArea("Area 1", resource.getOlatResource());
Assert.assertNotNull(area1);
Assert.assertEquals("Area 1", area1.getName());
Assert.assertEquals("<p>Area 1 description</p>", area1.getDescription());
// check relation to groups
List<BusinessGroup> groupArea1 = areaManager.findBusinessGroupsOfArea(area1);
Assert.assertNotNull(groupArea1);
Assert.assertEquals(2, groupArea1.size());
Assert.assertTrue(groupArea1.get(0).getName().equals("Export group 1") || groupArea1.get(1).getName().equals("Export group 1"));
Assert.assertTrue(groupArea1.get(0).getName().equals("Export group 2") || groupArea1.get(1).getName().equals("Export group 2"));
// check empty area
BGArea area3 = areaManager.findBGArea("Area 3", resource.getOlatResource());
Assert.assertNotNull(area1);
Assert.assertEquals("Area 3", area3.getName());
// check relation to groups
List<BusinessGroup> groupArea3 = areaManager.findBusinessGroupsOfArea(area3);
Assert.assertNotNull(groupArea3);
Assert.assertEquals(0, groupArea3.size());
}
Aggregations