use of org.olat.modules.fo.portfolio.ForumArtefact in project OpenOLAT by OpenOLAT.
the class EPArtefactManagerTest method testCreateForumArtefact.
@Test
public void testCreateForumArtefact() {
EPArtefactHandler<?> handler = portfolioModule.getArtefactHandler("Forum");
AbstractArtefact artefact = handler.createArtefact();
artefact.setAuthor(ident1);
assertNotNull(artefact);
assertTrue(artefact instanceof ForumArtefact);
// update the artefact
AbstractArtefact persistedArtefact = epFrontendManager.updateArtefact(artefact);
assertNotNull(persistedArtefact);
assertTrue(persistedArtefact instanceof ForumArtefact);
dbInstance.commitAndCloseSession();
// reload the artefact
AbstractArtefact loadedArtefact = epFrontendManager.loadArtefactByKey(artefact.getKey());
assertNotNull(loadedArtefact);
assertTrue(loadedArtefact instanceof ForumArtefact);
// get the VFS container of the artefact
VFSContainer container = epFrontendManager.getArtefactContainer(loadedArtefact);
assertNotNull(container);
if (container instanceof LocalFolderImpl) {
LocalFolderImpl folder = (LocalFolderImpl) container;
assertNotNull(folder.getBasefile());
assertTrue(folder.getBasefile().exists());
assertTrue(folder.getBasefile().isDirectory());
}
}
use of org.olat.modules.fo.portfolio.ForumArtefact in project OpenOLAT by OpenOLAT.
the class EPStructureToArtefactTest method createStructureToArtefactLink.
@Test
public void createStructureToArtefactLink() {
// create structure element
PortfolioStructure structure = epFrontendManager.createAndPersistPortfolioStructureElement(null, "struc-to-art-el", "structure-to-artefact-element");
// create artefact
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(ident1, "Forum");
dbInstance.commitAndCloseSession();
// test if all is ok
assertNotNull(structure);
assertNotNull(artefact);
assertTrue(artefact instanceof ForumArtefact);
// create the link
epFrontendManager.addArtefactToStructure(ident1, artefact, structure);
dbInstance.commitAndCloseSession();
// test if the link is persisted
List<AbstractArtefact> linkedArtfeacts = epFrontendManager.getArtefacts(structure);
assertNotNull(linkedArtfeacts);
assertEquals(1, linkedArtfeacts.size());
assertEquals(artefact.getKey(), linkedArtfeacts.get(0).getKey());
}
use of org.olat.modules.fo.portfolio.ForumArtefact in project openolat by klemens.
the class EPArtefactManagerTest method testCreateForumArtefact.
@Test
public void testCreateForumArtefact() {
EPArtefactHandler<?> handler = portfolioModule.getArtefactHandler("Forum");
AbstractArtefact artefact = handler.createArtefact();
artefact.setAuthor(ident1);
assertNotNull(artefact);
assertTrue(artefact instanceof ForumArtefact);
// update the artefact
AbstractArtefact persistedArtefact = epFrontendManager.updateArtefact(artefact);
assertNotNull(persistedArtefact);
assertTrue(persistedArtefact instanceof ForumArtefact);
dbInstance.commitAndCloseSession();
// reload the artefact
AbstractArtefact loadedArtefact = epFrontendManager.loadArtefactByKey(artefact.getKey());
assertNotNull(loadedArtefact);
assertTrue(loadedArtefact instanceof ForumArtefact);
// get the VFS container of the artefact
VFSContainer container = epFrontendManager.getArtefactContainer(loadedArtefact);
assertNotNull(container);
if (container instanceof LocalFolderImpl) {
LocalFolderImpl folder = (LocalFolderImpl) container;
assertNotNull(folder.getBasefile());
assertTrue(folder.getBasefile().exists());
assertTrue(folder.getBasefile().isDirectory());
}
}
use of org.olat.modules.fo.portfolio.ForumArtefact in project openolat by klemens.
the class EPStructureToArtefactTest method createStructureToArtefactLink.
@Test
public void createStructureToArtefactLink() {
// create structure element
PortfolioStructure structure = epFrontendManager.createAndPersistPortfolioStructureElement(null, "struc-to-art-el", "structure-to-artefact-element");
// create artefact
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(ident1, "Forum");
dbInstance.commitAndCloseSession();
// test if all is ok
assertNotNull(structure);
assertNotNull(artefact);
assertTrue(artefact instanceof ForumArtefact);
// create the link
epFrontendManager.addArtefactToStructure(ident1, artefact, structure);
dbInstance.commitAndCloseSession();
// test if the link is persisted
List<AbstractArtefact> linkedArtfeacts = epFrontendManager.getArtefacts(structure);
assertNotNull(linkedArtfeacts);
assertEquals(1, linkedArtfeacts.size());
assertEquals(artefact.getKey(), linkedArtfeacts.get(0).getKey());
}
use of org.olat.modules.fo.portfolio.ForumArtefact in project OpenOLAT by OpenOLAT.
the class EPArtefactManagerTest method testCreateForumArtefactAlternateVersion.
@Test
public void testCreateForumArtefactAlternateVersion() {
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(ident1, "Forum");
assertNotNull(artefact);
assertTrue(artefact instanceof ForumArtefact);
dbInstance.commitAndCloseSession();
assertNotNull(artefact.getKey());
// reload the artefact
AbstractArtefact persistedArtefact = epFrontendManager.loadArtefactByKey(artefact.getKey());
assertNotNull(persistedArtefact);
assertTrue(persistedArtefact instanceof ForumArtefact);
}
Aggregations