Search in sources :

Example 21 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.

the class LicenseTypeActivationDAOTest method shouldDeleteActivation.

@Test
public void shouldDeleteActivation() {
    String name = "name";
    LicenseType licenseType = licenseTypeDao.create(name);
    licenseTypeDao.save(licenseType);
    licenseTypeActivationDao.createAndPersist(LICENSE_HANDLER, licenseType);
    dbInstance.commitAndCloseSession();
    licenseTypeActivationDao.delete(LICENSE_HANDLER, licenseType);
    dbInstance.commitAndCloseSession();
    boolean isActive = licenseTypeActivationDao.isActive(LICENSE_HANDLER, licenseType);
    assertThat(isActive).isFalse();
}
Also used : LicenseType(org.olat.core.commons.services.license.LicenseType) Test(org.junit.Test)

Example 22 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.

the class LicenseTypeActivationDAOTest method shouldNotCreateActivationIfItIsAlreadyActive.

@Test
public void shouldNotCreateActivationIfItIsAlreadyActive() {
    String name = "name";
    LicenseType licenseType = licenseTypeDao.create(name);
    licenseTypeDao.save(licenseType);
    licenseTypeActivationDao.createAndPersist(LICENSE_HANDLER, licenseType);
    dbInstance.commitAndCloseSession();
    licenseTypeActivationDao.createAndPersist(LICENSE_HANDLER, licenseType);
    dbInstance.commitAndCloseSession();
    boolean isActive = licenseTypeActivationDao.isActive(LICENSE_HANDLER, licenseType);
    assertThat(isActive).isTrue();
}
Also used : LicenseType(org.olat.core.commons.services.license.LicenseType) Test(org.junit.Test)

Example 23 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.

the class LicenseTypeDAOTest method shouldLoadNoLicenseType.

@Test
public void shouldLoadNoLicenseType() {
    LicenseType noLicenseType = licenseTypeDao.loadNoLicenseType();
    assertThat(noLicenseType).isNotNull();
    assertThat(noLicenseType.getName()).isEqualTo(LicenseTypeDAO.NO_LICENSE_NAME);
}
Also used : LicenseType(org.olat.core.commons.services.license.LicenseType) Test(org.junit.Test)

Example 24 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.

the class LicenseTypeDAOTest method shouldLoadLicenseTypeByKey.

@Test
public void shouldLoadLicenseTypeByKey() {
    LicenseType licenseType = licenseTypeDao.create(UUID.randomUUID().toString());
    licenseType = licenseTypeDao.save(licenseType);
    LicenseType otherLicenseType = licenseTypeDao.create(UUID.randomUUID().toString());
    licenseTypeDao.save(otherLicenseType);
    dbInstance.commitAndCloseSession();
    LicenseType loadedLicenseType = licenseTypeDao.loadLicenseTypeByKey(licenseType.getKey());
    assertThat(loadedLicenseType).isEqualTo(licenseType);
}
Also used : LicenseType(org.olat.core.commons.services.license.LicenseType) Test(org.junit.Test)

Example 25 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.

the class LicenseTypeDAOTest method shouldCreateWithHighestSortOrder.

@Test
public void shouldCreateWithHighestSortOrder() {
    LicenseType licenseType = licenseTypeDao.create("name");
    int sortOrder = 22;
    licenseType.setSortOrder(sortOrder);
    licenseTypeDao.save(licenseType);
    dbInstance.commitAndCloseSession();
    LicenseType licenseType2 = licenseTypeDao.create("other");
    LicenseType licenseType3 = licenseTypeDao.create("other2");
    licenseType2 = licenseTypeDao.save(licenseType2);
    licenseType3 = licenseTypeDao.save(licenseType3);
    dbInstance.commitAndCloseSession();
    assertThat(licenseType2.getSortOrder()).isEqualTo(sortOrder + 1);
    assertThat(licenseType3.getSortOrder()).isEqualTo(sortOrder + 2);
}
Also used : LicenseType(org.olat.core.commons.services.license.LicenseType) Test(org.junit.Test)

Aggregations

LicenseType (org.olat.core.commons.services.license.LicenseType)106 Test (org.junit.Test)40 ResourceLicense (org.olat.core.commons.services.license.ResourceLicense)28 LicenseService (org.olat.core.commons.services.license.LicenseService)14 License (org.olat.core.commons.services.license.License)12 OLATResourceable (org.olat.core.id.OLATResourceable)12 File (java.io.File)6 ArrayList (java.util.ArrayList)4 LicenseHandler (org.olat.core.commons.services.license.LicenseHandler)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 QLicense (org.olat.modules.qpool.model.QLicense)4 Date (java.util.Date)2 Random (java.util.Random)2 IdentityShort (org.olat.basesecurity.IdentityShort)2 LicenseImpl (org.olat.core.commons.services.license.model.LicenseImpl)2 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 Translator (org.olat.core.gui.translator.Translator)2 MultiUserEvent (org.olat.core.util.event.MultiUserEvent)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2