Search in sources :

Example 11 with Reason

use of org.olat.modules.lecture.Reason in project OpenOLAT by OpenOLAT.

the class ReasonDAOTest method isReasonInUse.

@Test
public void isReasonInUse() {
    // create a reason
    String title = "3. reason";
    String description = "Use it";
    Reason reason = reasonDao.createReason(title, description);
    dbInstance.commitAndCloseSession();
    // add to a lecture block
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
    lectureBlock.setStartDate(new Date());
    lectureBlock.setEndDate(new Date());
    lectureBlock.setTitle("Hello lecturers");
    lectureBlock.setReasonEffectiveEnd(reason);
    lectureBlock = lectureBlockDao.update(lectureBlock);
    dbInstance.commitAndCloseSession();
    // check
    boolean inUse = reasonDao.isReasonInUse(reason);
    Assert.assertTrue(inUse);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntry(org.olat.repository.RepositoryEntry) Reason(org.olat.modules.lecture.Reason) Date(java.util.Date) Test(org.junit.Test)

Example 12 with Reason

use of org.olat.modules.lecture.Reason in project OpenOLAT by OpenOLAT.

the class ReasonDAOTest method getReasons.

@Test
public void getReasons() {
    String title = "2. reason";
    String description = "Find a list";
    Reason reason = reasonDao.createReason(title, description);
    dbInstance.commitAndCloseSession();
    List<Reason> reasons = reasonDao.getReasons();
    Assert.assertNotNull(reasons);
    Assert.assertFalse(reasons.isEmpty());
    Assert.assertTrue(reasons.contains(reason));
}
Also used : Reason(org.olat.modules.lecture.Reason) Test(org.junit.Test)

Example 13 with Reason

use of org.olat.modules.lecture.Reason in project OpenOLAT by OpenOLAT.

the class ReasonDAOTest method createReason.

@Test
public void createReason() {
    String title = "1. reason";
    String description = "Because";
    Reason reason = reasonDao.createReason(title, description);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(reason);
    Assert.assertNotNull(reason.getKey());
    Assert.assertNotNull(reason.getCreationDate());
    Assert.assertNotNull(reason.getLastModified());
}
Also used : Reason(org.olat.modules.lecture.Reason) Test(org.junit.Test)

Example 14 with Reason

use of org.olat.modules.lecture.Reason in project OpenOLAT by OpenOLAT.

the class ReasonDAOTest method isReasonInUse_notInUse.

@Test
public void isReasonInUse_notInUse() {
    // create a reason
    String title = "4. reason";
    String description = "Nobody use me";
    Reason reason = reasonDao.createReason(title, description);
    dbInstance.commitAndCloseSession();
    // check
    boolean inUse = reasonDao.isReasonInUse(reason);
    Assert.assertFalse(inUse);
}
Also used : Reason(org.olat.modules.lecture.Reason) Test(org.junit.Test)

Example 15 with Reason

use of org.olat.modules.lecture.Reason in project OpenOLAT by OpenOLAT.

the class ReasonDAO method delete.

public boolean delete(Reason reason) {
    Reason reloadReference = dbInstance.getCurrentEntityManager().getReference(ReasonImpl.class, reason.getKey());
    dbInstance.getCurrentEntityManager().remove(reloadReference);
    return true;
}
Also used : Reason(org.olat.modules.lecture.Reason)

Aggregations

Reason (org.olat.modules.lecture.Reason)28 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)6 Date (java.util.Date)4 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 LectureBlock (org.olat.modules.lecture.LectureBlock)4 Calendar (java.util.Calendar)2 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)2 Identity (org.olat.core.id.Identity)2 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)2 LectureBlockWithTeachers (org.olat.modules.lecture.model.LectureBlockWithTeachers)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2