use of com.entwinemedia.fn.Unit in project opencast by opencast.
the class AssetManagerWithSecurityTest method testGetAsset.
/* ------------------------------------------------------------------------------------------------------------------ */
/**
* Media package is created under the admin of the default organization.
*/
@Test
@Parameters
public void testGetAsset(final AccessControlList acl, User user, boolean assertAccess) throws Exception {
// create a snapshot
final Snapshot snapshot = createSnapshot(acl);
// get an asset of the snapshot
runWith(user, assertAccess, new P1Lazy<Unit>() {
@Override
public Unit get1() {
assertTrue(am.getAsset(snapshot.getVersion(), snapshot.getMediaPackage().getIdentifier().toString(), snapshot.getMediaPackage().getElements()[0].getIdentifier()).isSome());
return Unit.unit;
}
});
}
use of com.entwinemedia.fn.Unit in project opencast by opencast.
the class AssetManagerWithSecurityTest method testSetAvailabilityAndSetProperty.
/* ------------------------------------------------------------------------------------------------------------------ */
/**
* Media package is created under the admin of the default organization.
*/
@Test
@Parameters
public void testSetAvailabilityAndSetProperty(final AccessControlList acl, User user, boolean assertGrant) throws Exception {
// create a snapshot
final Snapshot snapshot = createSnapshot(acl);
runWith(user, assertGrant, new P1Lazy<Unit>() {
@Override
public Unit get1() {
// set availability
am.setAvailability(snapshot.getVersion(), snapshot.getMediaPackage().getIdentifier().toString(), Availability.OFFLINE);
// set a property
assertTrue(am.setProperty(Property.mk(PropertyId.mk(snapshot.getMediaPackage().getIdentifier().toString(), "namespace", "property-name"), Value.mk("value"))));
return Unit.unit;
}
});
}
use of com.entwinemedia.fn.Unit in project opencast by opencast.
the class AssetManagerWithSecurityTest method testQuery.
/* ------------------------------------------------------------------------------------------------------------------ */
@Test
@Parameters
public void testQuery(AccessControlList acl, User writeUser, User queryUser, final boolean assertReadAccess, final boolean assertWriteAccess) throws Exception {
// create a snapshot -> should always work (set assertAccess to true)
final Snapshot snapshot = createSnapshot(acl, writeUser, true);
// Set assertAccess to true since querying does not yield a security exception.
// Restricted records are simply filtered out.
runWith(queryUser, true, new P1Lazy<Unit>() {
@Override
public Unit get1() {
// if read access is granted the result contains one record
assertEquals("Snapshot should be retrieved: " + assertReadAccess, assertReadAccess, q.select(q.snapshot()).run().getSize() == 1);
return Unit.unit;
}
});
runWith(queryUser, true, new P1Lazy<Unit>() {
@Override
public Unit get1() {
// if write access is granted one snapshot should be deleted
assertEquals("Snapshots should be deleted: " + assertWriteAccess, assertWriteAccess, q.delete(OWNER, q.snapshot()).run() == 1);
return Unit.unit;
}
});
}
use of com.entwinemedia.fn.Unit in project opencast by opencast.
the class DublinCoreCatalogTest method testLoadAndSave.
@Test
public void testLoadAndSave() throws Exception {
final DublinCoreCatalog dc = read("/dublincore-extended.xml");
final File out = testFolder.newFile("dublincore.xml");
IoSupport.withResource(new FileOutputStream(out), new FnX<FileOutputStream, Unit>() {
@Override
public Unit applyX(FileOutputStream out) throws Exception {
dc.toXml(out, false);
return Unit.unit;
}
});
final DublinCoreCatalog reloaded = DublinCoreXmlFormat.read(out);
assertEquals("The reloaded catalog should have the same amount of properties than the original one.", dc.getValues().size(), reloaded.getValues().size());
}
Aggregations