use of org.opencastproject.mediapackage.MediaPackage in project opencast by opencast.
the class AbstractAssetManagerSelectTest method testSelectByArchivedDate.
@Test
public void testSelectByArchivedDate() throws Exception {
final Date backThen = DateTime.now().minusSeconds(5).withMillisOfSecond(0).toDate();
final MediaPackage mp1 = mkMediaPackage(mkCatalog());
am.takeSnapshot(OWNER, mp1);
final MediaPackage mp2 = mkMediaPackage(mkCatalog());
am.takeSnapshot(OWNER, mp2);
final Date now = DateTime.now().plusSeconds(1).withMillisOfSecond(0).toDate();
assertEquals("Two records should be found", 2, q.select(q.snapshot()).where(q.archived().le(now)).run().getSize());
assertEquals("No record should be found", 0, q.select(q.snapshot()).where(q.archived().gt(now)).run().getSize());
assertEquals("Two records should be found", 2, q.select(q.snapshot()).where(q.archived().ge(backThen)).run().getSize());
assertEquals("No record should be found", 0, q.select(q.snapshot()).where(q.archived().lt(backThen)).run().getSize());
}
use of org.opencastproject.mediapackage.MediaPackage in project opencast by opencast.
the class AbstractAssetManagerSelectTest method testSelectMultiplePropertyNamespaces.
@Test
public void testSelectMultiplePropertyNamespaces() throws Exception {
final MediaPackage mp1 = mkMediaPackage(mkCatalog());
final String mp1Id = mp1.getIdentifier().toString();
am.takeSnapshot(OWNER, mp1);
am.setProperty(p.approved.mk(mp1Id, true));
am.setProperty(p.count.mk(mp1Id, 10L));
am.setProperty(p.start.mk(mp1Id, new Date()));
//
am.setProperty(Property.mk(PropertyId.mk(mp1Id, "org.opencastproject.scheduler", "start"), Value.mk(new Date())));
am.setProperty(Property.mk(PropertyId.mk(mp1Id, "org.opencastproject.scheduler", "end"), Value.mk(new Date())));
//
{
final RichAResult r = enrich(q.select(p.allProperties(), q.propertiesOf("org.opencastproject.scheduler")).run());
assertEquals("One record should be found", 1, r.getSize());
assertEquals("All five properties should be found", 5, r.countProperties());
}
{
final RichAResult r = enrich(q.select(q.propertiesOf(p.namespace())).run());
assertEquals("One record should be found", 1, r.getSize());
assertEquals("No snapshot has been selected", 0, r.countSnapshots());
assertEquals("Three properties should be found", 3, r.countProperties());
}
{
final RichAResult r = enrich(q.select(q.propertiesOf("org.opencastproject.scheduler")).where(q.mediaPackageId(mp1Id)).run());
assertEquals(2, r.countProperties());
}
{
final RichAResult r = enrich(q.select(q.snapshot()).where(p.hasPropertiesOfNamespace()).run());
assertEquals(1, r.getSize());
}
{
final RichAResult r = enrich(q.select(p.allProperties(), q.propertiesOf("org.opencastproject.scheduler")).run());
assertEquals(1, r.getSize());
assertEquals(5, r.countProperties());
}
}
use of org.opencastproject.mediapackage.MediaPackage in project opencast by opencast.
the class AbstractAssetManagerSelectTest method testSelectMultipleProperties.
@Test
public void testSelectMultipleProperties() throws Exception {
final MediaPackage mp1 = mkMediaPackage(mkCatalog());
am.takeSnapshot(OWNER, mp1);
am.setProperty(p.approved.mk(mp1.getIdentifier().toString(), true));
am.setProperty(p.count.mk(mp1.getIdentifier().toString(), 10L));
am.setProperty(p.start.mk(mp1.getIdentifier().toString(), new Date()));
assertEquals("Querying all properties, three should be found", 3, sizeOf(q.select(q.properties()).run().getRecords().bind(getProperties)));
assertEquals("Querying 'approved' and 'count', both should be found", 2, sizeOf(q.select(p.approved.target(), p.count.target()).where(q.mediaPackageId(mp1.getIdentifier().toString())).run().getRecords().bind(getProperties)));
assertEquals("Querying 'approved' and 'count' in a different style, both should be found again", 2, sizeOf(q.select(q.properties(p.approved.name(), p.count.name())).where(q.mediaPackageId(mp1.getIdentifier().toString())).run().getRecords().bind(getProperties)));
logger.info("Add another media package with some properties");
final MediaPackage mp2 = mkMediaPackage(mkCatalog());
am.takeSnapshot(OWNER, mp2);
am.setProperty(p.approved.mk(mp2.getIdentifier().toString(), true));
am.setProperty(p.start.mk(mp2.getIdentifier().toString(), new Date()));
assertEquals("Querying all properties, five should be found", 5, sizeOf(q.select(q.properties()).run().getRecords().bind(getProperties)));
assertEquals("Querying target and count of the first media package, both should be found", 2, sizeOf(q.select(p.approved.target(), p.count.target()).where(q.mediaPackageId(mp1.getIdentifier().toString())).run().getRecords().bind(getProperties)));
assertEquals("Querying target and count of all media packages, 3 properties should be found", 3, sizeOf(q.select(q.properties(p.approved.name(), p.count.name())).run().getRecords().bind(getProperties)));
}
use of org.opencastproject.mediapackage.MediaPackage in project opencast by opencast.
the class AbstractAssetManagerSelectTest method testSelectBySeries.
@Test
public void testSelectBySeries() throws Exception {
final MediaPackage mp = mkMediaPackage();
logger.info("The series ID field of the media package links it to a series. Attached DublinCore catalogs are not relevant.");
mp.setSeries("series-1");
am.takeSnapshot(OWNER, mp);
assertEquals(1, q.select(q.snapshot()).where(q.seriesId().eq("series-1")).run().getSize());
assertEquals(0, q.select(q.snapshot()).where(q.seriesId().eq("series-2")).run().getSize());
}
use of org.opencastproject.mediapackage.MediaPackage in project opencast by opencast.
the class AbstractAssetManagerSelectTest method testComparisons.
@Test
public void testComparisons() throws Exception {
final MediaPackage mp = mkMediaPackage(mkCatalog());
final String mpId = mp.getIdentifier().toString();
am.takeSnapshot(OWNER, mp);
// set the milliseconds to 0 since MySQL (or the driver) rounds milliseconds to the next or previous
// second which may cause subsequent tests (.le(now)) to fail.
final Date now = DateTime.now().withMillisOfSecond(0).toDate();
logger.info("now=" + now);
// set up a property for each property type
am.setProperty(p.start.mk(mpId, now));
am.setProperty(p.agent.mk(mpId, "agent"));
am.setProperty(p.approved.mk(mpId, true));
am.setProperty(p.count.mk(mpId, 10L));
{
assertEquals(1, q.select(q.snapshot()).where(p.count.le(10L)).run().getSize());
assertEquals(1, q.select(q.snapshot()).where(p.count.ge(10L)).run().getSize());
assertEquals(1, q.select(q.snapshot()).where(p.count.eq(10L)).run().getSize());
assertEquals(0, q.select(q.snapshot()).where(p.count.lt(10L)).run().getSize());
assertEquals(0, q.select(q.snapshot()).where(p.count.gt(10L)).run().getSize());
assertEquals(1, q.select(q.snapshot()).where(p.count.lt(11L)).run().getSize());
assertEquals(1, q.select(q.snapshot()).where(p.count.gt(9L)).run().getSize());
}
{
assertEquals(1, q.select(q.snapshot()).where(p.start.le(now)).run().getSize());
assertEquals(1, q.select(q.snapshot()).where(p.start.ge(now)).run().getSize());
assertEquals(1, q.select(q.snapshot()).where(p.start.eq(now)).run().getSize());
assertEquals(0, q.select(q.snapshot()).where(p.start.lt(now)).run().getSize());
assertEquals(0, q.select(q.snapshot()).where(p.start.gt(now)).run().getSize());
assertEquals(1, q.select(q.snapshot()).where(p.start.lt(new Date(now.getTime() + 120000L))).run().getSize());
assertEquals(1, q.select(q.snapshot()).where(p.start.gt(new Date(now.getTime() - 120000L))).run().getSize());
}
}
Aggregations