Search in sources :

Example 1 with AnimateService

use of org.opencastproject.animate.api.AnimateService in project opencast by opencast.

the class AnimateWorkflowOperationHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    handler = new AnimateWorkflowOperationHandler() {

        @Override
        protected JobBarrier.Result waitForStatus(Job... jobs) throws IllegalStateException, IllegalArgumentException {
            JobBarrier.Result result = EasyMock.createNiceMock(JobBarrier.Result.class);
            EasyMock.expect(result.isSuccess()).andReturn(true).anyTimes();
            EasyMock.replay(result);
            return result;
        }
    };
    file = new File(getClass().getResource("/dc-episode.xml").toURI());
    MediaPackage mediaPackage = new MediaPackageBuilderImpl().createNew();
    mediaPackage.setIdentifier(new IdImpl("123-456"));
    InputStream in = new FileInputStream(file);
    Catalog catalog = DublinCores.read(in);
    catalog.setFlavor(MediaPackageElements.EPISODE);
    // catalog.setURI(getClass().getResource("/dc-episode.xml").toURI());
    mediaPackage.add(catalog);
    instance = EasyMock.createNiceMock(WorkflowOperationInstanceImpl.class);
    EasyMock.expect(instance.getConfiguration("target-flavor")).andReturn("a/b").anyTimes();
    EasyMock.expect(instance.getConfiguration("target-tags")).andReturn("a,b,c").anyTimes();
    workflow = EasyMock.createMock(WorkflowInstanceImpl.class);
    EasyMock.expect(workflow.getMediaPackage()).andReturn(mediaPackage).anyTimes();
    EasyMock.expect(workflow.getCurrentOperation()).andReturn(instance).anyTimes();
    Job job = new JobImpl(0);
    job.setPayload(file.getAbsolutePath());
    AnimateService animateService = EasyMock.createMock(AnimateService.class);
    EasyMock.expect(animateService.animate(anyObject(), anyObject(), anyObject())).andReturn(job);
    Workspace workspace = EasyMock.createMock(Workspace.class);
    EasyMock.expect(workspace.put(anyString(), anyString(), anyString(), anyObject())).andReturn(file.toURI()).anyTimes();
    EasyMock.expect(workspace.read(anyObject())).andAnswer(() -> getClass().getResourceAsStream("/dc-episode.xml")).anyTimes();
    workspace.cleanup(anyObject(Id.class));
    EasyMock.expectLastCall();
    workspace.delete(anyObject(URI.class));
    EasyMock.expectLastCall();
    job = new JobImpl(1);
    job.setPayload(MediaPackageElementParser.getAsXml(new TrackImpl()));
    MediaInspectionService mediaInspectionService = EasyMock.createMock(MediaInspectionService.class);
    EasyMock.expect(mediaInspectionService.enrich(anyObject(), anyBoolean())).andReturn(job).once();
    EasyMock.replay(animateService, workspace, workflow, mediaInspectionService);
    handler.setAnimateService(animateService);
    handler.setMediaInspectionService(mediaInspectionService);
    handler.setWorkspace(workspace);
}
Also used : JobImpl(org.opencastproject.job.api.JobImpl) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) TrackImpl(org.opencastproject.mediapackage.track.TrackImpl) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) MediaInspectionService(org.opencastproject.inspection.api.MediaInspectionService) URI(java.net.URI) IdImpl(org.opencastproject.mediapackage.identifier.IdImpl) FileInputStream(java.io.FileInputStream) Catalog(org.opencastproject.mediapackage.Catalog) WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) MediaPackageBuilderImpl(org.opencastproject.mediapackage.MediaPackageBuilderImpl) AnimateService(org.opencastproject.animate.api.AnimateService) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Id(org.opencastproject.mediapackage.identifier.Id) Job(org.opencastproject.job.api.Job) File(java.io.File) Workspace(org.opencastproject.workspace.api.Workspace) Before(org.junit.Before)

Aggregations

File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 Before (org.junit.Before)1 AnimateService (org.opencastproject.animate.api.AnimateService)1 MediaInspectionService (org.opencastproject.inspection.api.MediaInspectionService)1 Job (org.opencastproject.job.api.Job)1 JobImpl (org.opencastproject.job.api.JobImpl)1 Catalog (org.opencastproject.mediapackage.Catalog)1 MediaPackage (org.opencastproject.mediapackage.MediaPackage)1 MediaPackageBuilderImpl (org.opencastproject.mediapackage.MediaPackageBuilderImpl)1 Id (org.opencastproject.mediapackage.identifier.Id)1 IdImpl (org.opencastproject.mediapackage.identifier.IdImpl)1 TrackImpl (org.opencastproject.mediapackage.track.TrackImpl)1 WorkflowInstanceImpl (org.opencastproject.workflow.api.WorkflowInstanceImpl)1 WorkflowOperationInstanceImpl (org.opencastproject.workflow.api.WorkflowOperationInstanceImpl)1 Workspace (org.opencastproject.workspace.api.Workspace)1