Search in sources :

Example 11 with QLicense

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

the class QLicenseDAOTest method testCreate.

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

Example 12 with QLicense

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

the class QLicenseDAO method createDefaultLicenses.

protected void createDefaultLicenses() {
    List<QLicense> licenses = getLicenses();
    Set<String> licenseKeys = new HashSet<String>();
    for (QLicense license : licenses) {
        licenseKeys.add(license.getLicenseKey());
    }
    for (String defaultLicenseKey : defaultLicenses) {
        if (!licenseKeys.contains(defaultLicenseKey)) {
            create(defaultLicenseKey, null, false);
        }
    }
    dbInstance.commitAndCloseSession();
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) HashSet(java.util.HashSet)

Example 13 with QLicense

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

the class QLicenseDAOTest method testCreate.

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

Example 14 with QLicense

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

the class QLicenseDAOTest method testCreateAndGet_byLicenseKey.

@Test
public void testCreateAndGet_byLicenseKey() {
    String licenseKey = "apache-license-" + UUID.randomUUID().toString();
    QLicense license = qpoolLicenseDao.create(licenseKey, null, true);
    dbInstance.commit();
    // load it
    QLicense reloadedLicense = qpoolLicenseDao.loadByLicenseKey(licenseKey);
    // 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 15 with QLicense

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

the class OLATUpgrade_12_4_0 method saveLicense.

private void saveLicense(QuestionItemImpl item) {
    QLicense qlicense = item.getLicense();
    String name = mapLicenseTypeName(qlicense.getLicenseKey());
    LicenseType licenseType = licenseService.loadLicenseTypeByName(name);
    ResourceLicense license = licenseService.loadOrCreateLicense(item);
    license.setLicenseType(licenseType);
    license.setFreetext(qlicense.getLicenseText());
    license.setLicensor(item.getCreator());
    licenseService.update(license);
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) LicenseType(org.olat.core.commons.services.license.LicenseType) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

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