Search in sources :

Example 46 with AResult

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

the class SchedulerServiceImplTest method removeScheduledRecordingsBeforeBufferInputOneEvent.

@Test
public void removeScheduledRecordingsBeforeBufferInputOneEvent() throws Exception {
    Date start = new Date(System.currentTimeMillis() - 160000);
    Date end = new Date(System.currentTimeMillis() - 60000);
    String captureDeviceID = "demo";
    MediaPackage mp = generateEvent(Opt.<String>none());
    DublinCoreCatalog event = generateEvent(captureDeviceID, start, end);
    addDublinCore(Opt.<String>none(), mp, event);
    Map<String, String> caProperties = generateCaptureAgentMetadata("demo");
    // Store event
    schedSvc.addEvent(start, end, captureDeviceID, Collections.<String>emptySet(), mp, wfProperties, caProperties, Opt.<Boolean>none(), Opt.<String>none(), SchedulerService.ORIGIN);
    schedSvc.removeScheduledRecordingsBeforeBuffer(0);
    try {
        schedSvc.getMediaPackage(mp.getIdentifier().compact());
        Assert.fail();
    } catch (NotFoundException e) {
        Assert.assertNotNull(e);
    }
    AQueryBuilder query = assetManager.createQuery();
    AResult result = query.select(query.snapshot()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact())).and(query.version().isLatest())).run();
    Opt<ARecord> record = result.getRecords().head();
    assertFalse(record.isSome());
}
Also used : ARecord(org.opencastproject.assetmanager.api.query.ARecord) MediaPackage(org.opencastproject.mediapackage.MediaPackage) NotFoundException(org.opencastproject.util.NotFoundException) AQueryBuilder(org.opencastproject.assetmanager.api.query.AQueryBuilder) RichAResult(org.opencastproject.assetmanager.api.query.RichAResult) AResult(org.opencastproject.assetmanager.api.query.AResult) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) Date(java.util.Date) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) Test(org.junit.Test)

Aggregations

AResult (org.opencastproject.assetmanager.api.query.AResult)46 AQueryBuilder (org.opencastproject.assetmanager.api.query.AQueryBuilder)37 ARecord (org.opencastproject.assetmanager.api.query.ARecord)29 NotFoundException (org.opencastproject.util.NotFoundException)27 SchedulerTransactionLockException (org.opencastproject.scheduler.api.SchedulerTransactionLockException)21 MediaPackage (org.opencastproject.mediapackage.MediaPackage)20 SchedulerConflictException (org.opencastproject.scheduler.api.SchedulerConflictException)20 SchedulerException (org.opencastproject.scheduler.api.SchedulerException)20 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)20 IOException (java.io.IOException)19 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)19 ValidationException (net.fortuna.ical4j.model.ValidationException)18 Test (org.junit.Test)18 SeriesException (org.opencastproject.series.api.SeriesException)18 ServiceException (org.osgi.framework.ServiceException)18 ConfigurationException (org.osgi.service.cm.ConfigurationException)18 Date (java.util.Date)16 RichAResult (org.opencastproject.assetmanager.api.query.RichAResult)14 DublinCoreCatalog (org.opencastproject.metadata.dublincore.DublinCoreCatalog)11 Log.getHumanReadableTimeString (org.opencastproject.util.Log.getHumanReadableTimeString)10