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);
}
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()));
}
}
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());
}
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));
}
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());
}
Aggregations