Search in sources :

Example 1 with ForumArtefact

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());
    }
}
Also used : ForumArtefact(org.olat.modules.fo.portfolio.ForumArtefact) VFSContainer(org.olat.core.util.vfs.VFSContainer) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl) Test(org.junit.Test)

Example 2 with ForumArtefact

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());
}
Also used : ForumArtefact(org.olat.modules.fo.portfolio.ForumArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Test(org.junit.Test)

Example 3 with ForumArtefact

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());
    }
}
Also used : ForumArtefact(org.olat.modules.fo.portfolio.ForumArtefact) VFSContainer(org.olat.core.util.vfs.VFSContainer) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl) Test(org.junit.Test)

Example 4 with ForumArtefact

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());
}
Also used : ForumArtefact(org.olat.modules.fo.portfolio.ForumArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Test(org.junit.Test)

Example 5 with ForumArtefact

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);
}
Also used : ForumArtefact(org.olat.modules.fo.portfolio.ForumArtefact) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 ForumArtefact (org.olat.modules.fo.portfolio.ForumArtefact)6 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)6 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)2