use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class EPFrontendManagerTest method isTemplateInUse.
@Test
public void isTemplateInUse() {
// create a template
OLATResource resource = epStructureManager.createPortfolioMapTemplateResource();
// create a repository entry
RepositoryEntry addedEntry = repositoryService.create(ident1, null, "-", "Template in user", "Template in use", resource, RepositoryEntry.ACC_OWNERS);
// create the template owned by ident1
PortfolioStructureMap template = epStructureManager.createAndPersistPortfolioMapTemplateFromEntry(ident1, addedEntry);
dbInstance.commitAndCloseSession();
// add a page to it
PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(template, "Page title", "Page description");
assertNotNull(page1);
dbInstance.commitAndCloseSession();
// check: the template is not in use
assertFalse(epFrontendManager.isTemplateInUse(template, null, null, null));
// use the template: assign the template to ident2
PortfolioStructureMap map = epFrontendManager.assignStructuredMapToUser(ident2, template, addedEntry, null, null, null);
assertNotNull(map);
dbInstance.commitAndCloseSession();
// check: the template is in use
assertTrue(epFrontendManager.isTemplateInUse(template, null, null, null));
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class EPFrontendManagerTest method allUserPolicies.
@Test
public void allUserPolicies() {
// create a map
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Policies", "Description");
PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(map, "Page policies", "Page description");
assertNotNull(page1);
dbInstance.commitAndCloseSession();
// check visiblity (is owner)
assertTrue(epFrontendManager.isMapVisible(ident1, map.getOlatResource()));
// check visibility (no policy)
assertFalse(epFrontendManager.isMapVisible(ident2, map.getOlatResource()));
// check not visible (no policy)
assertFalse(epFrontendManager.isMapVisible(ident3, map.getOlatResource()));
// add all user policy
EPMapPolicy userPolicy = new EPMapPolicy();
userPolicy.setType(Type.allusers);
epFrontendManager.updateMapPolicies(map, Collections.singletonList(userPolicy));
dbInstance.commitAndCloseSession();
// one policy
List<EPMapPolicy> policies1 = epFrontendManager.getMapPolicies(map);
assertEquals(1, policies1.size());
// check visiblity (is owner)
assertTrue(epFrontendManager.isMapVisible(ident1, map.getOlatResource()));
// check visibility (is user)
assertTrue(epFrontendManager.isMapVisible(ident2, map.getOlatResource()));
// check not visible (is user)
assertTrue(epFrontendManager.isMapVisible(ident3, map.getOlatResource()));
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class EPFrontendManagerTest method isMapOwner.
@Test
public void isMapOwner() {
// create a map
PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title", "Description");
PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
assertNotNull(page1);
dbInstance.commitAndCloseSession();
// check if ident1 is owner
assertTrue(epFrontendManager.isMapOwner(ident1, originalMap.getOlatResource()));
// check if ident2 is not owner
assertFalse(epFrontendManager.isMapOwner(ident2, originalMap.getOlatResource()));
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class EPFrontendManagerTest method mergeTwoUserPolicies.
@Test
public void mergeTwoUserPolicies() {
// create a map
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Remove policies", "Description");
PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(map, "Page policies", "Page description");
assertNotNull(page1);
dbInstance.commitAndCloseSession();
// save a list of policies
List<EPMapPolicy> policies = new ArrayList<EPMapPolicy>();
// first user policy
EPMapPolicy userPolicy1 = new EPMapPolicy();
userPolicy1.setType(Type.user);
userPolicy1.getIdentities().add(ident2);
userPolicy1.getIdentities().add(ident3);
policies.add(userPolicy1);
// second user policy
EPMapPolicy userPolicy2 = new EPMapPolicy();
userPolicy2.setType(Type.user);
userPolicy2.getIdentities().add(ident1);
policies.add(userPolicy2);
epFrontendManager.updateMapPolicies(map, policies);
dbInstance.commitAndCloseSession();
// check if the policies are correctly merged
List<EPMapPolicy> mergedPolicies = epFrontendManager.getMapPolicies(map);
assertNotNull(mergedPolicies);
assertEquals(1, mergedPolicies.size());
EPMapPolicy mergedPolicy = mergedPolicies.get(0);
List<Identity> identities = mergedPolicy.getIdentities();
assertEquals(3, identities.size());
int count1, count2, count3;
count1 = count2 = count3 = 0;
for (Identity identity : identities) {
if (identity.equalsByPersistableKey(ident1)) {
count1++;
} else if (identity.equalsByPersistableKey(ident2)) {
count2++;
} else if (identity.equalsByPersistableKey(ident3)) {
count3++;
}
}
assertEquals(1, count1);
assertEquals(1, count2);
assertEquals(1, count3);
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class EPImportTest method testCopy.
@Test
public void testCopy() throws URISyntaxException {
Identity ident = JunitTestHelper.createAndPersistIdentityAsRndUser("ImPort-1");
// save the map
PortfolioStructureMap map = epStructureManager.createPortfolioMapTemplate(ident, "import-map-1", "map-template");
epStructureManager.savePortfolioStructure(map);
dbInstance.commitAndCloseSession();
// check that the author are in the
OLATResource resource = resourceManager.findResourceable(map.getResourceableId(), map.getResourceableTypeName());
RepositoryEntry re = repositoryManager.lookupRepositoryEntry(resource, false);
Assert.assertNotNull(re);
dbInstance.commitAndCloseSession();
RepositoryEntry copy = repositoryService.copy(re, ident, "ImPort - (Copy 1)");
Assert.assertNotNull(copy);
dbInstance.commitAndCloseSession();
PortfolioStructure copiedMap = epFrontendManager.loadPortfolioStructure(copy.getOlatResource());
Assert.assertNotNull(copiedMap);
}
Aggregations