Search in sources :

Example 91 with QItemType

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));
}
Also used : QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 92 with QItemType

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());
}
Also used : QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 93 with QItemType

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));
}
Also used : QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 94 with QItemType

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());
}
Also used : QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 95 with QItemType

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));
}
Also used : QuestionItemFull(org.olat.modules.qpool.QuestionItemFull) Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Aggregations

QItemType (org.olat.modules.qpool.model.QItemType)118 Test (org.junit.Test)94 QuestionItem (org.olat.modules.qpool.QuestionItem)82 Identity (org.olat.core.id.Identity)58 BusinessGroup (org.olat.group.BusinessGroup)22 QuestionItemView (org.olat.modules.qpool.QuestionItemView)18 Pool (org.olat.modules.qpool.Pool)12 QuestionItem2Pool (org.olat.modules.qpool.QuestionItem2Pool)12 QuestionItemCollection (org.olat.modules.qpool.QuestionItemCollection)12 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)10 URI (java.net.URI)8 ArrayList (java.util.ArrayList)8 HttpResponse (org.apache.http.HttpResponse)8 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)8 QEducationalContext (org.olat.modules.qpool.model.QEducationalContext)8 SearchQuestionItemParams (org.olat.modules.qpool.model.SearchQuestionItemParams)8 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)6 QuestionType (org.olat.modules.qpool.QuestionType)6 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)6 InputStream (java.io.InputStream)4