Search in sources :

Example 11 with RichAResult

use of org.opencastproject.assetmanager.api.query.RichAResult in project opencast by opencast.

the class AbstractAssetManagerSelectTest method testSelectAllPropertiesOfNamespace.

@Test
public void testSelectAllPropertiesOfNamespace() throws Exception {
    final MediaPackage mp = mkMediaPackage(mkCatalog());
    am.takeSnapshot(OWNER, mp);
    am.setProperty(Property.mk(PropertyId.mk(mp.getIdentifier().toString(), "namespace-1", "prop-1"), Value.mk(true)));
    am.setProperty(Property.mk(PropertyId.mk(mp.getIdentifier().toString(), "namespace-2", "prop-2"), Value.mk("value-2")));
    {
        final RichAResult r = enrich(q.select(q.propertiesOf("namespace-1")).run());
        assertEquals("One record should be returned", 1, r.getSize());
        assertEquals("No snapshots should be returned", 0, r.countSnapshots());
        assertEquals("One property should be returned", 1, r.countProperties());
        assertEquals("Property of namespace-1 should be returned", PropertyId.mk(mp.getIdentifier().toString(), "namespace-1", "prop-1"), r.getProperties().head2().getId());
    }
    {
        final RichAResult r = enrich(q.select(q.propertiesOf("namespace-1")).where(q.hasPropertiesOf("namespace-2")).run());
        assertEquals("One record should be returned", 1, r.getSize());
        assertEquals("No snapshots should be returned", 0, r.countSnapshots());
        assertEquals("One property should be returned", 1, r.countProperties());
        assertEquals("Property of namespace-1 should be returned", PropertyId.mk(mp.getIdentifier().toString(), "namespace-1", "prop-1"), r.getProperties().head2().getId());
    }
}
Also used : MediaPackage(org.opencastproject.mediapackage.MediaPackage) RichAResult(org.opencastproject.assetmanager.api.query.RichAResult) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 RichAResult (org.opencastproject.assetmanager.api.query.RichAResult)11 MediaPackage (org.opencastproject.mediapackage.MediaPackage)5 Date (java.util.Date)3 AQueryBuilder (org.opencastproject.assetmanager.api.query.AQueryBuilder)2 FnX (com.entwinemedia.fn.FnX)1 P2 (com.entwinemedia.fn.P2)1 Parameters (junitparams.Parameters)1 Ignore (org.junit.Ignore)1 Snapshot (org.opencastproject.assetmanager.api.Snapshot)1 Predicate (org.opencastproject.assetmanager.api.query.Predicate)1 DublinCoreCatalog (org.opencastproject.metadata.dublincore.DublinCoreCatalog)1 NotFoundException (org.opencastproject.util.NotFoundException)1