Search in sources :

Example 1 with QLicense

use of org.olat.modules.qpool.model.QLicense in project OpenOLAT by OpenOLAT.

the class QLicenseDAOTest method testCreateAndGet.

@Test
public void testCreateAndGet() {
    String licenseKey = "apache-license-" + UUID.randomUUID().toString();
    QLicense license = qpoolLicenseDao.create(licenseKey, null, true);
    dbInstance.commit();
    // load it
    QLicense reloadedLicense = qpoolLicenseDao.loadById(license.getKey());
    // check the values
    Assert.assertNotNull(reloadedLicense);
    Assert.assertEquals(license.getKey(), reloadedLicense.getKey());
    Assert.assertNotNull(reloadedLicense.getCreationDate());
    Assert.assertEquals(licenseKey, reloadedLicense.getLicenseKey());
    Assert.assertTrue(reloadedLicense.isDeletable());
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) Test(org.junit.Test)

Example 2 with QLicense

use of org.olat.modules.qpool.model.QLicense in project OpenOLAT by OpenOLAT.

the class QLicenseDAOTest method testDelete_notDeletable.

@Test
public void testDelete_notDeletable() {
    String licenseKey = "lgpl-" + UUID.randomUUID().toString();
    QLicense license = qpoolLicenseDao.create(licenseKey, null, false);
    dbInstance.commitAndCloseSession();
    // delete it
    boolean deleted = qpoolLicenseDao.delete(license);
    dbInstance.commitAndCloseSession();
    Assert.assertFalse(deleted);
    // check that the type is really, really deleted
    QLicense reloadedLicense = qpoolLicenseDao.loadById(license.getKey());
    Assert.assertNotNull(reloadedLicense);
    List<QLicense> allLicenses = qpoolLicenseDao.getLicenses();
    Assert.assertTrue(allLicenses.contains(license));
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) Test(org.junit.Test)

Example 3 with QLicense

use of org.olat.modules.qpool.model.QLicense in project OpenOLAT by OpenOLAT.

the class QLicenseDAOTest method testGetItemLevels.

@Test
public void testGetItemLevels() {
    String licenseKey = "gnu-" + UUID.randomUUID().toString();
    QLicense license = qpoolLicenseDao.create(licenseKey, null, true);
    dbInstance.commit();
    // load it
    List<QLicense> allLicenses = qpoolLicenseDao.getLicenses();
    // check the values
    Assert.assertNotNull(allLicenses);
    Assert.assertTrue(allLicenses.contains(license));
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) Test(org.junit.Test)

Example 4 with QLicense

use of org.olat.modules.qpool.model.QLicense in project OpenOLAT by OpenOLAT.

the class QLicenseDAOTest method testDelete_deletable.

@Test
public void testDelete_deletable() {
    String licenseKey = "gpl-" + UUID.randomUUID().toString();
    QLicense license = qpoolLicenseDao.create(licenseKey, null, true);
    dbInstance.commitAndCloseSession();
    // delete it
    boolean deleted = qpoolLicenseDao.delete(license);
    dbInstance.commitAndCloseSession();
    Assert.assertTrue(deleted);
    // check that the type is really, really deleted
    QLicense reloadedLicense = qpoolLicenseDao.loadById(license.getKey());
    Assert.assertNull(reloadedLicense);
    List<QLicense> licenses = qpoolLicenseDao.getLicenses();
    Assert.assertFalse(licenses.contains(license));
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) Test(org.junit.Test)

Example 5 with QLicense

use of org.olat.modules.qpool.model.QLicense in project OpenOLAT by OpenOLAT.

the class QLicenseDAO method create.

public QLicense create(String licenseKey, String text, boolean deletable) {
    QLicense license = new QLicense();
    license.setCreationDate(new Date());
    license.setLicenseKey(licenseKey);
    license.setLicenseText(text);
    license.setDeletable(deletable);
    dbInstance.getCurrentEntityManager().persist(license);
    return license;
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) Date(java.util.Date)

Aggregations

QLicense (org.olat.modules.qpool.model.QLicense)22 Test (org.junit.Test)12 LicenseType (org.olat.core.commons.services.license.LicenseType)4 ResourceLicense (org.olat.core.commons.services.license.ResourceLicense)4 Date (java.util.Date)2 HashSet (java.util.HashSet)2