use of org.olat.modules.lecture.Reason in project openolat by klemens.
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));
}
use of org.olat.modules.lecture.Reason in project openolat by klemens.
the class ReasonDAOTest method deleteReasons.
@Test
public void deleteReasons() {
// create a reason
String title = "Forgotten reason";
String description = "Find a list";
Reason reason = reasonDao.createReason(title, description);
dbInstance.commitAndCloseSession();
// check it exists
List<Reason> reasons = reasonDao.getReasons();
Assert.assertTrue(reasons.contains(reason));
// delete the reason
boolean deleted = reasonDao.delete(reason);
Assert.assertTrue(deleted);
// check it exists
List<Reason> reloadedDasons = reasonDao.getReasons();
Assert.assertFalse(reloadedDasons.contains(reason));
}
use of org.olat.modules.lecture.Reason in project openolat by klemens.
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);
}
use of org.olat.modules.lecture.Reason in project openolat by klemens.
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());
}
use of org.olat.modules.lecture.Reason in project openolat by klemens.
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;
}
Aggregations