use of org.olat.portfolio.model.structel.PortfolioStructure in project openolat by klemens.
the class EPStructureToArtefactTest method moveUpArtefact.
@Test
public void moveUpArtefact() {
// save parent and 5 children
PortfolioStructure structureEl = epFrontendManager.createAndPersistPortfolioStructureElement(null, "move-up-structure-el-1", "move-up-structure-element");
List<AbstractArtefact> children = new ArrayList<AbstractArtefact>();
for (int i = 0; i < 5; i++) {
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(ident1, "Forum");
artefact.setTitle("move-up-artefact-1-" + i);
artefact = epFrontendManager.updateArtefact(artefact);
epFrontendManager.addArtefactToStructure(ident1, artefact, structureEl);
children.add(artefact);
}
dbInstance.commitAndCloseSession();
// move up the first place
epStructureManager.moveUp(structureEl, children.get(0));
dbInstance.commitAndCloseSession();
// check that all is the same
List<AbstractArtefact> persistedChildren1 = epFrontendManager.getArtefacts(structureEl);
assertNotNull(persistedChildren1);
assertEquals(5, persistedChildren1.size());
assertEquals(children.get(0).getKey(), persistedChildren1.get(0).getKey());
assertEquals(children.get(1).getKey(), persistedChildren1.get(1).getKey());
assertEquals(children.get(2).getKey(), persistedChildren1.get(2).getKey());
assertEquals(children.get(3).getKey(), persistedChildren1.get(3).getKey());
assertEquals(children.get(4).getKey(), persistedChildren1.get(4).getKey());
dbInstance.commitAndCloseSession();
// move the second to the first place
epStructureManager.moveUp(structureEl, children.get(1));
dbInstance.commitAndCloseSession();
// check that all is the same
List<AbstractArtefact> persistedChildren2 = epFrontendManager.getArtefacts(structureEl);
assertNotNull(persistedChildren2);
assertEquals(5, persistedChildren2.size());
assertEquals(children.get(1).getKey(), persistedChildren2.get(0).getKey());
assertEquals(children.get(0).getKey(), persistedChildren2.get(1).getKey());
assertEquals(children.get(2).getKey(), persistedChildren2.get(2).getKey());
assertEquals(children.get(3).getKey(), persistedChildren2.get(3).getKey());
assertEquals(children.get(4).getKey(), persistedChildren2.get(4).getKey());
dbInstance.commitAndCloseSession();
// move up the last
epStructureManager.moveUp(structureEl, children.get(4));
dbInstance.commitAndCloseSession();
// check that all is the same
List<AbstractArtefact> persistedChildren3 = epFrontendManager.getArtefacts(structureEl);
assertNotNull(persistedChildren3);
assertEquals(5, persistedChildren3.size());
assertEquals(children.get(1).getKey(), persistedChildren3.get(0).getKey());
assertEquals(children.get(0).getKey(), persistedChildren3.get(1).getKey());
assertEquals(children.get(2).getKey(), persistedChildren3.get(2).getKey());
assertEquals(children.get(4).getKey(), persistedChildren3.get(3).getKey());
assertEquals(children.get(3).getKey(), persistedChildren3.get(4).getKey());
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project openolat by klemens.
the class EPPolicyManagerTest method getOwners.
@Test
public void getOwners() {
// create a map
Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("Policy-User-1-");
PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(user, "Title", "Description");
PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
assertNotNull(page1);
dbInstance.commitAndCloseSession();
List<Identity> owners = policyManager.getOwners(originalMap);
Assert.assertNotNull(owners);
Assert.assertEquals(1, owners.size());
Assert.assertEquals(user, owners.get(0));
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project openolat by klemens.
the class EPStructureManagerTest method testGetStructureElementsForUser.
@Test
public void testGetStructureElementsForUser() {
Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-1-");
PortfolioStructure el = epFrontendManager.createAndPersistPortfolioDefaultMap(user, "users-test-map", "a-map-to-test-get-afterwards");
Assert.assertNotNull(el);
dbInstance.commitAndCloseSession();
List<SecurityGroup> secGroups = securityManager.getSecurityGroupsForIdentity(user);
Assert.assertNotNull(secGroups);
Assert.assertTrue(secGroups.size() >= 1);
List<PortfolioStructure> elRes = epStructureManager.getStructureElementsForUser(user, ElementType.DEFAULT_MAP);
Assert.assertNotNull(elRes);
Assert.assertEquals(1, elRes.size());
Assert.assertEquals("users-test-map", elRes.get(0).getTitle());
// get another map
PortfolioStructure el2 = epFrontendManager.createAndPersistPortfolioDefaultMap(user, "users-test-map-2", "2-a-map-to-test-get-afterwards");
Assert.assertNotNull(el2);
dbInstance.commitAndCloseSession();
List<PortfolioStructure> elRes2 = epStructureManager.getStructureElementsForUser(user);
Assert.assertNotNull(elRes2);
Assert.assertEquals(2, elRes2.size());
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project openolat by klemens.
the class EPStructureManagerTest method testGetStructureElementsForUser_byElementTypes.
@Test
public void testGetStructureElementsForUser_byElementTypes() {
Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-1-");
PortfolioStructure el = epFrontendManager.createAndPersistPortfolioDefaultMap(user, "users-def-map", "");
Assert.assertNotNull(el);
dbInstance.commitAndCloseSession();
// by default map
List<PortfolioStructure> defaultRes = epStructureManager.getStructureElementsForUser(user, ElementType.DEFAULT_MAP);
Assert.assertNotNull(defaultRes);
Assert.assertEquals(1, defaultRes.size());
Assert.assertEquals("users-def-map", defaultRes.get(0).getTitle());
// by default map and structured
List<PortfolioStructure> multipleRes = epStructureManager.getStructureElementsForUser(user, ElementType.DEFAULT_MAP, ElementType.STRUCTURED_MAP);
Assert.assertNotNull(multipleRes);
Assert.assertEquals(1, multipleRes.size());
Assert.assertEquals("users-def-map", multipleRes.get(0).getTitle());
// by structured
List<PortfolioStructure> structuredRes = epStructureManager.getStructureElementsForUser(user, ElementType.STRUCTURED_MAP);
Assert.assertNotNull(structuredRes);
Assert.assertTrue(structuredRes.isEmpty());
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project openolat by klemens.
the class EPStructureManagerTest method testCreateAndRetrieveElement.
@Test
public void testCreateAndRetrieveElement() {
PortfolioStructure el = epFrontendManager.createAndPersistPortfolioStructureElement(null, "structure-el-2", "structure-element-2");
dbInstance.commitAndCloseSession();
PortfolioStructure el2 = epStructureManager.loadPortfolioStructure(el.getOlatResource());
assertNotNull(el2);
}
Aggregations