use of org.olat.modules.qpool.model.QItemType in project openolat by klemens.
the class QItemTypeDAOTest method testDelete_deletable.
@Test
public void testDelete_deletable() {
String typeStr = "cute-" + UUID.randomUUID().toString();
QItemType type = qpoolItemTypeDao.create(typeStr, true);
dbInstance.commitAndCloseSession();
// delete it
boolean deleted = qpoolItemTypeDao.delete(type);
dbInstance.commitAndCloseSession();
Assert.assertTrue(deleted);
// check that the type is really, really deleted
QItemType reloadedType = qpoolItemTypeDao.loadById(type.getKey());
Assert.assertNull(reloadedType);
List<QItemType> allTypes = qpoolItemTypeDao.getItemTypes();
Assert.assertFalse(allTypes.contains(type));
}
use of org.olat.modules.qpool.model.QItemType in project openolat by klemens.
the class QItemTypeDAOTest method testCreateAndGet.
@Test
public void testCreateAndGet() {
String typeStr = "veryInteressantType-" + UUID.randomUUID().toString();
QItemType type = qpoolItemTypeDao.create(typeStr, true);
dbInstance.commit();
// load it
QItemType reloadedType = qpoolItemTypeDao.loadById(type.getKey());
// check the values
Assert.assertNotNull(reloadedType);
Assert.assertEquals(type.getKey(), reloadedType.getKey());
Assert.assertNotNull(reloadedType.getCreationDate());
Assert.assertEquals(typeStr.toLowerCase(), reloadedType.getType());
Assert.assertTrue(reloadedType.isDeletable());
}
use of org.olat.modules.qpool.model.QItemType in project openolat by klemens.
the class QItemTypeDAOTest method testDelete_notDeletable.
@Test
public void testDelete_notDeletable() {
String typeStr = "titanium-" + UUID.randomUUID().toString();
QItemType type = qpoolItemTypeDao.create(typeStr, false);
dbInstance.commitAndCloseSession();
// delete it
boolean deleted = qpoolItemTypeDao.delete(type);
dbInstance.commitAndCloseSession();
Assert.assertFalse(deleted);
// check that the type is really, really deleted
QItemType reloadedType = qpoolItemTypeDao.loadById(type.getKey());
Assert.assertNotNull(reloadedType);
List<QItemType> allTypes = qpoolItemTypeDao.getItemTypes();
Assert.assertTrue(allTypes.contains(type));
}
use of org.olat.modules.qpool.model.QItemType in project openolat by klemens.
the class QItemTypeDAOTest method testCreate.
@Test
public void testCreate() {
String typeStr = "interessantType-" + UUID.randomUUID().toString();
QItemType type = qpoolItemTypeDao.create(typeStr, true);
dbInstance.commit();
// check
Assert.assertNotNull(type);
Assert.assertNotNull(type.getKey());
Assert.assertNotNull(type.getCreationDate());
Assert.assertNotNull(type.getType());
// lower case always
Assert.assertEquals(typeStr.toLowerCase(), type.getType());
Assert.assertTrue(type.isDeletable());
}
use of org.olat.modules.qpool.model.QItemType in project openolat by klemens.
the class QuestionDAOTest method getItems_all.
@Test
public void getItems_all() {
// create an author with 2 items
QItemType fibType = qItemTypeDao.loadByType(QuestionType.FIB.name());
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("QOwn-all-" + UUID.randomUUID().toString());
QuestionItem item = questionDao.createAndPersist(id, "NGC all", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, fibType);
dbInstance.commitAndCloseSession();
// retrieve all items
List<QuestionItemFull> items = questionDao.getAllItems(0, -1);
Assert.assertNotNull(items);
Assert.assertTrue(items.size() >= 1);
Assert.assertTrue(items.contains(item));
}
Aggregations