Search in sources :

Example 1 with EPStructureElementArtefact

use of org.olat.portfolio.model.artefacts.EPStructureElementArtefact in project openolat by klemens.

the class EPArtefactManagerTest method testCreateStructureElementArtefact.

@Test
public void testCreateStructureElementArtefact() {
    AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(ident1, "ep-structure-element");
    if (artefact != null) {
        // handler is disabled or another error occurred while
        // trying to create the artefact
        assertNotNull(artefact);
        assertTrue(artefact instanceof EPStructureElementArtefact);
        EPStructureElementArtefact elementArtefact = (EPStructureElementArtefact) artefact;
        PortfolioStructure el = epFrontendManager.createAndPersistPortfolioStructureElement(null, "structure-el-for-artefact", "structure-element-for-artefact");
        elementArtefact.setStructureElement((EPStructureElement) el);
        dbInstance.commitAndCloseSession();
        assertNotNull(artefact.getKey());
        // reload the artefact
        AbstractArtefact persistedArtefact = epFrontendManager.loadArtefactByKey(artefact.getKey());
        assertNotNull(persistedArtefact);
        assertTrue(persistedArtefact instanceof EPStructureElementArtefact);
        EPStructureElementArtefact persistedElementArtefact = (EPStructureElementArtefact) persistedArtefact;
        assertNotNull(persistedElementArtefact.getStructureElement());
        assertEquals(el.getKey(), persistedElementArtefact.getStructureElement().getKey());
    }
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPStructureElementArtefact(org.olat.portfolio.model.artefacts.EPStructureElementArtefact) Test(org.junit.Test)

Example 2 with EPStructureElementArtefact

use of org.olat.portfolio.model.artefacts.EPStructureElementArtefact in project OpenOLAT by OpenOLAT.

the class EPArtefactManagerTest method testCreateStructureElementArtefact.

@Test
public void testCreateStructureElementArtefact() {
    AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(ident1, "ep-structure-element");
    if (artefact != null) {
        // handler is disabled or another error occurred while
        // trying to create the artefact
        assertNotNull(artefact);
        assertTrue(artefact instanceof EPStructureElementArtefact);
        EPStructureElementArtefact elementArtefact = (EPStructureElementArtefact) artefact;
        PortfolioStructure el = epFrontendManager.createAndPersistPortfolioStructureElement(null, "structure-el-for-artefact", "structure-element-for-artefact");
        elementArtefact.setStructureElement((EPStructureElement) el);
        dbInstance.commitAndCloseSession();
        assertNotNull(artefact.getKey());
        // reload the artefact
        AbstractArtefact persistedArtefact = epFrontendManager.loadArtefactByKey(artefact.getKey());
        assertNotNull(persistedArtefact);
        assertTrue(persistedArtefact instanceof EPStructureElementArtefact);
        EPStructureElementArtefact persistedElementArtefact = (EPStructureElementArtefact) persistedArtefact;
        assertNotNull(persistedElementArtefact.getStructureElement());
        assertEquals(el.getKey(), persistedElementArtefact.getStructureElement().getKey());
    }
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPStructureElementArtefact(org.olat.portfolio.model.artefacts.EPStructureElementArtefact) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)2 EPStructureElementArtefact (org.olat.portfolio.model.artefacts.EPStructureElementArtefact)2 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)2