use of org.olat.modules.portfolio.model.BinderImpl in project OpenOLAT by OpenOLAT.
the class PageDAOTest method getPages_section.
@Test
public void getPages_section() {
BinderImpl binder = binderDao.createAndPersist("Binder p2", "A binder with 2 page", null, null);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
dbInstance.commitAndCloseSession();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
Page page1 = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, reloadedSection, null);
Page page2 = pageDao.createAndPersist("Page 2", "A page with content.", null, null, true, reloadedSection, null);
Page page3 = pageDao.createAndPersist("Page 3", "A page with the demonstration of Hawking about black hole'evaporation.", null, null, true, reloadedSection, null);
dbInstance.commitAndCloseSession();
// reload
List<Page> sectionPages = pageDao.getPages(reloadedSection);
Assert.assertNotNull(sectionPages);
Assert.assertEquals(3, sectionPages.size());
Assert.assertTrue(sectionPages.contains(page1));
Assert.assertTrue(sectionPages.contains(page2));
Assert.assertTrue(sectionPages.contains(page3));
}
use of org.olat.modules.portfolio.model.BinderImpl in project OpenOLAT by OpenOLAT.
the class PageDAOTest method createBinderWithSectionAndPage.
@Test
public void createBinderWithSectionAndPage() {
BinderImpl binder = binderDao.createAndPersist("Binder p1", "A binder with a page", null, null);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
dbInstance.commitAndCloseSession();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
Page page = pageDao.createAndPersist("New page", "A brand new page.", null, null, true, reloadedSection, null);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(page);
Assert.assertNotNull(page.getKey());
Assert.assertNotNull(page.getCreationDate());
Assert.assertNotNull(page.getLastModified());
Assert.assertEquals("New page", page.getTitle());
Assert.assertEquals("A brand new page.", page.getSummary());
}
use of org.olat.modules.portfolio.model.BinderImpl in project OpenOLAT by OpenOLAT.
the class PageDAOTest method createBinderWithSectionAndPages.
@Test
public void createBinderWithSectionAndPages() {
BinderImpl binder = binderDao.createAndPersist("Binder p1", "A binder with a page", null, null);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
dbInstance.commitAndCloseSession();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
for (int i = 0; i < 5; i++) {
pageDao.createAndPersist("New page " + i, "A brand new page.", null, null, true, reloadedSection, null);
}
dbInstance.commitAndCloseSession();
List<Page> pages = pageDao.getPages(binder, null);
Assert.assertNotNull(pages);
Assert.assertEquals(5, pages.size());
}
use of org.olat.modules.portfolio.model.BinderImpl in project OpenOLAT by OpenOLAT.
the class PageDAOTest method createBinderWithSectionAndPageAndPart.
@Test
public void createBinderWithSectionAndPageAndPart() {
BinderImpl binder = binderDao.createAndPersist("Binder p1", "A binder with a page", null, null);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
dbInstance.commitAndCloseSession();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
Page page = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, reloadedSection, null);
dbInstance.commitAndCloseSession();
HTMLPart htmlPart = new HTMLPart();
PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
pageDao.persistPart(reloadedBody, htmlPart);
dbInstance.commitAndCloseSession();
// reload
Page reloadedPage = pageDao.loadByKey(page.getKey());
Assert.assertNotNull(reloadedPage);
List<PagePart> parts = reloadedPage.getBody().getParts();
Assert.assertNotNull(parts);
Assert.assertEquals(1, parts.size());
Assert.assertEquals(htmlPart, parts.get(0));
// reload only pages
List<PagePart> onlyParts = pageDao.getParts(page.getBody());
Assert.assertNotNull(onlyParts);
Assert.assertEquals(1, onlyParts.size());
Assert.assertEquals(htmlPart, onlyParts.get(0));
}
use of org.olat.modules.portfolio.model.BinderImpl in project OpenOLAT by OpenOLAT.
the class PageUserInfosDAOTest method createPageUserInfos.
@Test
public void createPageUserInfos() {
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("pui-1");
BinderImpl binder = binderDao.createAndPersist("Binder pui1", "A binder with a page for infos", null, null);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
Page page = pageDao.createAndPersist("New page", "A brand new page.", null, null, true, section, null);
dbInstance.commitAndCloseSession();
PageUserInformations infos = pageUserInfosDao.create(PageUserStatus.incoming, page, coach);
Assert.assertNotNull(infos);
Assert.assertEquals(coach, infos.getIdentity());
Assert.assertEquals(page, infos.getPage());
Assert.assertEquals(PageUserStatus.incoming, infos.getStatus());
Assert.assertFalse(infos.isMark());
dbInstance.commit();
}
Aggregations