use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class LicenseTypeDAOTest method shouldLoadLicenseTypeByName.
@Test
public void shouldLoadLicenseTypeByName() {
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.loadLicenseTypeByName(licenseType.getName());
assertThat(loadedLicenseType).isEqualTo(licenseType);
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class LicenseTypeDAOTest method shouldLoadActivatedLicenseTypes.
@Test
public void shouldLoadActivatedLicenseTypes() {
LicenseType licenseType1 = licenseTypeDao.create(UUID.randomUUID().toString());
licenseType1 = licenseTypeDao.save(licenseType1);
LicenseType licenseType2 = licenseTypeDao.create(UUID.randomUUID().toString());
licenseType2 = licenseTypeDao.save(licenseType2);
LicenseType licenseType3 = licenseTypeDao.create(UUID.randomUUID().toString());
licenseType3 = licenseTypeDao.save(licenseType3);
licenseTypeActivationDao.createAndPersist(LICENSE_HANDLER, licenseType1);
licenseTypeActivationDao.createAndPersist(LICENSE_HANDLER, licenseType2);
licenseTypeActivationDao.delete(LICENSE_HANDLER, licenseType2);
licenseTypeActivationDao.createAndPersist(LICENSE_HANDLER, licenseType2);
licenseTypeActivationDao.createAndPersist(LICENSE_HANDLER, licenseType3);
licenseTypeActivationDao.createAndPersist(OTHER_LICENSE_HANDLER, licenseType3);
dbInstance.commitAndCloseSession();
List<LicenseType> activatedLicenseType = licenseTypeDao.loadActiveLicenseTypes(LICENSE_HANDLER);
assertThat(activatedLicenseType).hasSize(3).contains(licenseType1, licenseType2, licenseType3);
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class ResourceLicenseDAOTest method shouldUpdateLicense.
@Test
public void shouldUpdateLicense() {
OLATResourceable ores = JunitTestHelper.createRandomResource();
LicenseType licenseType = licenseTypeDao.create("name");
licenseType = licenseTypeDao.save(licenseType);
ResourceLicense license = licenseDao.createAndPersist(ores, licenseType);
dbInstance.commitAndCloseSession();
String freetext = "freetext";
license.setFreetext(freetext);
String licensor = "licensor";
license.setLicensor(licensor);
license = licenseDao.save(license);
assertThat(license.getFreetext()).isEqualTo(freetext);
assertThat(license.getLicensor()).isEqualTo(licensor);
assertThat(license.getLicenseType()).isEqualTo(licenseType);
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class ResourceLicenseDAOTest method shouldCreateAndPersistRawLicense.
@Test
public void shouldCreateAndPersistRawLicense() {
OLATResourceable oresTarget = JunitTestHelper.createRandomResource();
OLATResourceable oresSource = JunitTestHelper.createRandomResource();
LicenseType licenseType = licenseTypeDao.create("name");
licenseType = licenseTypeDao.save(licenseType);
String licensor = "licensor";
String freetext = "freetext";
ResourceLicense sourceLicense = licenseDao.createAndPersist(oresSource, licenseType, licensor);
sourceLicense.setFreetext(freetext);
sourceLicense = licenseDao.save(sourceLicense);
dbInstance.commitAndCloseSession();
ResourceLicense targetLicense = licenseDao.createAndPersist(oresTarget, sourceLicense);
assertThat(targetLicense.getResName()).isEqualTo(oresTarget.getResourceableTypeName());
assertThat(targetLicense.getResId()).isEqualTo(oresTarget.getResourceableId());
assertThat(targetLicense.getLicenseType()).isEqualTo(sourceLicense.getLicenseType());
assertThat(targetLicense.getLicensor()).isEqualTo(sourceLicense.getLicensor());
assertThat(targetLicense.getFreetext()).isEqualTo(sourceLicense.getFreetext());
assertThat(targetLicense.getCreationDate()).isNotNull();
assertThat(targetLicense.getLastModified()).isNotNull();
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class ResourceLicenseDAOTest method shouldLoadLicenseForResource.
@Test
public void shouldLoadLicenseForResource() {
OLATResourceable ores = JunitTestHelper.createRandomResource();
LicenseType licenseType = licenseTypeDao.create("name");
licenseType = licenseTypeDao.save(licenseType);
License license = licenseDao.createAndPersist(ores, licenseType);
dbInstance.commitAndCloseSession();
ResourceLicense loadedLicense = licenseDao.loadByResource(ores);
assertThat(loadedLicense).isEqualTo(license);
}
Aggregations