Search in sources :

Example 26 with DBCheckbox

use of org.olat.course.nodes.cl.model.DBCheckbox in project OpenOLAT by OpenOLAT.

the class CheckboxManagerTest method loadCheckBox_withcheckboxId.

@Test
public void loadCheckBox_withcheckboxId() {
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-7", 2351l);
    String resSubPath = UUID.randomUUID().toString();
    String checkboxId = UUID.randomUUID().toString();
    DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, ores, resSubPath);
    dbInstance.commit();
    // load it
    DBCheckbox loadedBox = checkboxManager.loadCheckbox(ores, resSubPath, checkboxId);
    Assert.assertNotNull(loadedBox);
    Assert.assertEquals(checkbox, loadedBox);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 27 with DBCheckbox

use of org.olat.course.nodes.cl.model.DBCheckbox in project OpenOLAT by OpenOLAT.

the class CheckboxManagerTest method syncCheckBox.

@Test
public void syncCheckBox() {
    // build a list of checkbox to sync
    CheckboxList list = new CheckboxList();
    Checkbox checkbox1 = new Checkbox();
    checkbox1.setCheckboxId(UUID.randomUUID().toString());
    checkbox1.setTitle("Sync me");
    list.add(checkbox1);
    Checkbox checkbox2 = new Checkbox();
    checkbox2.setCheckboxId(UUID.randomUUID().toString());
    checkbox2.setTitle("Sync me too");
    list.add(checkbox2);
    // sync them to the database
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-4", 2348l);
    String resSubPath = UUID.randomUUID().toString();
    checkboxManager.syncCheckbox(list, ores, resSubPath);
    dbInstance.commitAndCloseSession();
    // load them
    List<DBCheckbox> dbCheckboxList = checkboxManager.loadCheckbox(ores, resSubPath);
    Assert.assertNotNull(dbCheckboxList);
    Assert.assertEquals(2, dbCheckboxList.size());
    for (DBCheckbox dbCheckbox : dbCheckboxList) {
        Assert.assertNotNull(dbCheckbox);
        Assert.assertNotNull(dbCheckbox.getKey());
        Assert.assertNotNull(dbCheckbox.getCheckboxId());
        Assert.assertTrue(dbCheckbox.getCheckboxId().equals(checkbox1.getCheckboxId()) || dbCheckbox.getCheckboxId().equals(checkbox2.getCheckboxId()));
    }
}
Also used : CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) OLATResourceable(org.olat.core.id.OLATResourceable) Checkbox(org.olat.course.nodes.cl.model.Checkbox) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 28 with DBCheckbox

use of org.olat.course.nodes.cl.model.DBCheckbox in project OpenOLAT by OpenOLAT.

the class CheckboxManagerTest method removeCheckBox.

@Test
public void removeCheckBox() {
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-3", 2347l);
    String resSubPath = UUID.randomUUID().toString();
    String checkboxId = UUID.randomUUID().toString();
    DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, ores, resSubPath);
    dbInstance.commit();
    Assert.assertNotNull(checkbox);
    // load it
    List<DBCheckbox> checkboxList = checkboxManager.loadCheckbox(ores, resSubPath);
    Assert.assertNotNull(checkboxList);
    Assert.assertEquals(1, checkboxList.size());
    dbInstance.commitAndCloseSession();
    // remove
    checkboxManager.removeCheckbox(checkboxList.get(0));
    dbInstance.commitAndCloseSession();
    // reload
    List<DBCheckbox> deletedCheckboxList = checkboxManager.loadCheckbox(ores, resSubPath);
    Assert.assertNotNull(checkboxList);
    Assert.assertEquals(0, deletedCheckboxList.size());
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 29 with DBCheckbox

use of org.olat.course.nodes.cl.model.DBCheckbox in project OpenOLAT by OpenOLAT.

the class CheckboxManagerTest method loadChecks_byOres.

@Test
public void loadChecks_byOres() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("check-3");
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-8", 2352l);
    String resSubPath = UUID.randomUUID().toString();
    String checkboxId = UUID.randomUUID().toString();
    DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, ores, resSubPath);
    // create a check
    DBCheck check = checkboxManager.createCheck(checkbox, id, null, Boolean.TRUE);
    dbInstance.commitAndCloseSession();
    // load the check
    List<DBCheck> loadedChecks = checkboxManager.loadCheck(id, ores, resSubPath);
    Assert.assertNotNull(loadedChecks);
    Assert.assertEquals(1, loadedChecks.size());
    Assert.assertEquals(check, loadedChecks.get(0));
}
Also used : DBCheck(org.olat.course.nodes.cl.model.DBCheck) OLATResourceable(org.olat.core.id.OLATResourceable) Identity(org.olat.core.id.Identity) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 30 with DBCheckbox

use of org.olat.course.nodes.cl.model.DBCheckbox in project OpenOLAT by OpenOLAT.

the class CheckboxManagerTest method loadCheckBox.

@Test
public void loadCheckBox() {
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-2", 2346l);
    String resSubPath = UUID.randomUUID().toString();
    String checkboxId = UUID.randomUUID().toString();
    DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, ores, resSubPath);
    dbInstance.commit();
    // load it
    List<DBCheckbox> checkboxList = checkboxManager.loadCheckbox(ores, resSubPath);
    Assert.assertNotNull(checkboxList);
    Assert.assertEquals(1, checkboxList.size());
    DBCheckbox dbCheckbox = checkboxList.get(0);
    Assert.assertEquals(checkbox, dbCheckbox);
    // paranoia check
    Assert.assertNotNull(dbCheckbox.getCreationDate());
    Assert.assertEquals(checkboxId, dbCheckbox.getCheckboxId());
    Assert.assertEquals(resSubPath, dbCheckbox.getResSubPath());
    Assert.assertEquals("checkbox-2", dbCheckbox.getResName());
    Assert.assertEquals(new Long(2346l), dbCheckbox.getResId());
    Assert.assertEquals(resSubPath, dbCheckbox.getResSubPath());
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Aggregations

DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)46 Test (org.junit.Test)34 OLATResourceable (org.olat.core.id.OLATResourceable)28 Identity (org.olat.core.id.Identity)26 DBCheck (org.olat.course.nodes.cl.model.DBCheck)22 AssessmentData (org.olat.course.nodes.cl.model.AssessmentData)8 Checkbox (org.olat.course.nodes.cl.model.Checkbox)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 BusinessGroup (org.olat.group.BusinessGroup)4 Date (java.util.Date)2 HashSet (java.util.HashSet)2 EntityManager (javax.persistence.EntityManager)2 IdentityImpl (org.olat.basesecurity.IdentityImpl)2 AssessmentBatch (org.olat.course.nodes.cl.model.AssessmentBatch)2 CheckboxList (org.olat.course.nodes.cl.model.CheckboxList)2