use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.
the class EPFrontendManagerTest method isStructuredMapOwner.
/**
* Same workflow as the repository. This workflow is pretty critical.
*/
@Test
public void isStructuredMapOwner() {
OLATResource resource = epStructureManager.createPortfolioMapTemplateResource();
// create a repository entry
RepositoryEntry addedEntry = repositoryService.create(ident1, null, "-", "test repo", "desc repo", resource, RepositoryEntry.ACC_OWNERS);
dbInstance.commitAndCloseSession();
// create the template owned by ident1
PortfolioStructureMap template = epStructureManager.createAndPersistPortfolioMapTemplateFromEntry(ident1, addedEntry);
PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(template, "Page title", "Page description");
assertNotNull(page1);
dbInstance.commitAndCloseSession();
// assign the template to ident2
PortfolioStructureMap map = epFrontendManager.assignStructuredMapToUser(ident2, template, addedEntry, null, null, null);
assertNotNull(map);
dbInstance.commitAndCloseSession();
// check if ident2 is owner of the map
assertTrue(epFrontendManager.isMapOwner(ident2, map.getOlatResource()));
// check if ident1 is not the owner of the map
assertFalse(epFrontendManager.isMapOwner(ident1, map.getOlatResource()));
// check if ident1 is owner of the template
assertTrue(epFrontendManager.isMapOwner(ident1, template.getOlatResource()));
}
use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.
the class EPFrontendManagerTest method deleteMap_template.
/**
* Delete a portfolio template
*/
@Test
public void deleteMap_template() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("frtuse-6");
// save parent and 20 children
OLATResource resource = epStructureManager.createPortfolioMapTemplateResource();
RepositoryEntry re = repositoryService.create(id, null, "", "Template to delete", "", resource, RepositoryEntry.ACC_OWNERS);
PortfolioStructureMap template = epStructureManager.createAndPersistPortfolioMapTemplateFromEntry(id, re);
PortfolioStructure page = epFrontendManager.createAndPersistPortfolioPage(template, "Page while be deleted", "Page description");
dbInstance.commitAndCloseSession();
// reload and check
PortfolioStructure reloadedTemplate = epFrontendManager.loadPortfolioStructureByKey(template.getKey());
Assert.assertNotNull(reloadedTemplate);
OLATResource reloadedResource = reloadedTemplate.getOlatResource();
Assert.assertNotNull(reloadedResource);
Assert.assertEquals(template, reloadedTemplate);
List<PortfolioStructure> reloadedPages = epFrontendManager.loadStructureChildren(reloadedTemplate);
Assert.assertNotNull(reloadedPages);
Assert.assertEquals(1, reloadedPages.size());
Assert.assertEquals(page, reloadedPages.get(0));
// delete
RepositoryEntry reloadedRe = repositoryService.loadByKey(re.getKey());
Roles roles = new Roles(true, false, false, false, false, false, false);
repositoryService.deletePermanently(reloadedRe, id, roles, Locale.GERMAN);
dbInstance.commit();
}
use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.
the class EPStructureManagerTest method testCreateAndSaveElement.
@Test
public void testCreateAndSaveElement() {
PortfolioStructure el = epFrontendManager.createAndPersistPortfolioStructureElement(null, "structure-el", "structure-element");
dbInstance.commitAndCloseSession();
assertNotNull(el);
assertNotNull(el.getOlatResource());
PortfolioStructure retrievedEl = epFrontendManager.loadPortfolioStructureByKey(el.getKey());
assertNotNull(retrievedEl);
assertNotNull(retrievedEl.getOlatResource());
OLATResource resource = resourceManager.findResourceable(el.getResourceableId(), el.getResourceableTypeName());
assertNotNull(resource);
}
use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.
the class EPStructureManagerTest method testAddAuthorToMap.
@Test
public void testAddAuthorToMap() {
// save the map
PortfolioStructureMap map = epStructureManager.createPortfolioMapTemplate(ident1, "add-author-map-1", "add-an-author-to-map-template");
epStructureManager.savePortfolioStructure(map);
dbInstance.commitAndCloseSession();
// add an author
epStructureManager.addAuthor(map, ident2);
dbInstance.commitAndCloseSession();
// check that the author are in the
OLATResource resource = resourceManager.findResourceable(map.getResourceableId(), map.getResourceableTypeName());
assertNotNull(resource);
RepositoryEntry re = repositoryManager.lookupRepositoryEntry(resource, false);
assertNotNull(re);
List<Identity> authors = repositoryService.getMembers(re, GroupRoles.owner.name());
assertEquals(2, authors.size());
// owner
assertTrue(authors.contains(ident1));
// owner
assertTrue(authors.contains(ident2));
}
use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.
the class PropertyTest method testFindWithIdentityList.
@Test
public void testFindWithIdentityList() {
// create identities, resource and properties
Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("cat-id-1-" + UUID.randomUUID().toString());
Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("cat-id-2-" + UUID.randomUUID().toString());
Identity id3 = JunitTestHelper.createAndPersistIdentityAsUser("cat-id-3-" + UUID.randomUUID().toString());
OLATResource ores = JunitTestHelper.createRandomResource();
Property p1 = pm.createPropertyInstance(id1, null, ores, "catidentlist", "TestProperty", new Float(1.1), new Long(123456), "stringValue", "textValue");
pm.saveProperty(p1);
Property p2 = pm.createPropertyInstance(id2, null, ores, "catidentlist", "TestProperty", new Float(1.1), new Long(123456), "stringValue", "textValue");
pm.saveProperty(p2);
Property p3 = pm.createPropertyInstance(id3, null, ores, "catidentlist", "TestProperty", new Float(1.1), new Long(123456), "stringValue", "textValue");
pm.saveProperty(p3);
dbInstance.commitAndCloseSession();
// check with empty list
List<Property> emptyProps = pm.findProperties(Collections.<Identity>emptyList(), ores, "catidentlist", "TestProperty");
assertNotNull(emptyProps);
Assert.assertTrue(emptyProps.isEmpty());
// check with a real value and a dummy
List<Identity> identities = new ArrayList<Identity>();
identities.add(id1);
identities.add(id2);
List<Property> props = pm.findProperties(identities, ores, "catidentlist", "TestProperty");
assertNotNull(props);
Assert.assertEquals(2, props.size());
Assert.assertTrue(props.contains(p1));
Assert.assertTrue(props.contains(p2));
}
Aggregations