use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.
the class LicenseTypeDAOTest method shouldPersistLicenseType.
@Test
public void shouldPersistLicenseType() {
String name = "name";
String text = "url";
String cssClass = "cssClass";
int sortOrder = 88;
LicenseType licenseType = licenseTypeDao.create(name);
licenseType.setText(text);
licenseType.setCssClass(cssClass);
licenseType.setSortOrder(sortOrder);
// create
licenseType = licenseTypeDao.save(licenseType);
dbInstance.commitAndCloseSession();
assertThat(licenseType).isNotNull();
assertThat(licenseType.getName()).isEqualTo(name);
assertThat(licenseType.isPredefined()).isFalse();
assertThat(licenseType.getText()).isEqualTo(text);
assertThat(licenseType.getCssClass()).isEqualTo(cssClass);
assertThat(licenseType.getSortOrder()).isEqualTo(sortOrder);
assertThat(licenseType.getCreationDate()).isNotNull();
assertThat(licenseType.getLastModified()).isNotNull();
// update
licenseType = licenseTypeDao.save(licenseType);
dbInstance.commitAndCloseSession();
assertThat(licenseType).isNotNull();
assertThat(licenseType.getName()).isEqualTo(name);
assertThat(licenseType.isPredefined()).isFalse();
assertThat(licenseType.getText()).isEqualTo(text);
assertThat(licenseType.getCssClass()).isEqualTo(cssClass);
assertThat(licenseType.getSortOrder()).isEqualTo(sortOrder);
assertThat(licenseType.getCreationDate()).isNotNull();
assertThat(licenseType.getLastModified()).isNotNull();
assertThat(licenseType.getLastModified()).isNotEqualTo(licenseType.getCreationDate());
}
use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.
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 klemens.
the class LicenseTypeDAOTest method shouldCheckIfExists.
@Test
public void shouldCheckIfExists() {
String name = UUID.randomUUID().toString();
boolean exists = licenseTypeDao.exists(name);
assertThat(exists).isFalse();
LicenseType licenseType1 = licenseTypeDao.create(name);
licenseType1 = licenseTypeDao.save(licenseType1);
dbInstance.commitAndCloseSession();
exists = licenseTypeDao.exists(name);
assertThat(exists).isTrue();
}
use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.
the class ResourceLicenseDAOTest method shouldCreateAndPersistLicense.
@Test
public void shouldCreateAndPersistLicense() {
OLATResourceable ores = JunitTestHelper.createRandomResource();
LicenseType licenseType = licenseTypeDao.create("name");
licenseType = licenseTypeDao.save(licenseType);
String licensor = "licensor";
ResourceLicense license = licenseDao.createAndPersist(ores, licenseType, licensor);
dbInstance.commitAndCloseSession();
assertThat(license.getResName()).isEqualTo(ores.getResourceableTypeName());
assertThat(license.getResId()).isEqualTo(ores.getResourceableId());
assertThat(license.getLicenseType()).isEqualTo(licenseType);
assertThat(license.getLicensor()).isEqualTo(licensor);
assertThat(license.getCreationDate()).isNotNull();
assertThat(license.getLastModified()).isNotNull();
}
use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.
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);
}
Aggregations