use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.
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);
}
use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.
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);
}
use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.
the class ResourceLicenseDAOTest method shouldLoadLicenseForResources.
@Test
public void shouldLoadLicenseForResources() {
String resName = "res";
LicenseType licenseType = licenseTypeDao.create("name");
licenseType = licenseTypeDao.save(licenseType);
OLATResourceable ores1 = OresHelper.createOLATResourceableInstance(resName, (new Random()).nextLong());
ResourceLicense license1 = licenseDao.createAndPersist(ores1, licenseType);
OLATResourceable ores2 = OresHelper.createOLATResourceableInstance(resName, (new Random()).nextLong());
ResourceLicense license2 = licenseDao.createAndPersist(ores2, licenseType);
OLATResourceable ores3 = OresHelper.createOLATResourceableInstance(resName, (new Random()).nextLong());
ResourceLicense license3 = licenseDao.createAndPersist(ores3, licenseType);
OLATResourceable oresSameName = OresHelper.createOLATResourceableInstance(resName, (new Random()).nextLong());
licenseDao.createAndPersist(oresSameName, licenseType);
OLATResourceable oresSameId = OresHelper.createOLATResourceableInstance("other", ores1.getResourceableId());
licenseDao.createAndPersist(oresSameId, licenseType);
dbInstance.commitAndCloseSession();
List<ResourceLicense> loadedLicenses = licenseDao.loadLicenses(Arrays.asList(ores1, ores2, ores3));
assertThat(loadedLicenses).containsExactly(license1, license2, license3);
}
use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.
the class ResourceLicenseDAOTest method shoulDeleteLicenseOfResource.
@Test
public void shoulDeleteLicenseOfResource() {
OLATResourceable ores = JunitTestHelper.createRandomResource();
LicenseType licenseType = licenseTypeDao.create("name");
licenseType = licenseTypeDao.save(licenseType);
licenseDao.createAndPersist(ores, licenseType);
dbInstance.commitAndCloseSession();
ResourceLicense loadedLicense = licenseDao.loadByResource(ores);
assertThat(loadedLicense).isNotNull();
licenseDao.delete(ores);
dbInstance.commitAndCloseSession();
loadedLicense = licenseDao.loadByResource(ores);
assertThat(loadedLicense).isNull();
}
use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.
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();
}
Aggregations