Search in sources :

Example 21 with WorkflowInstanceImpl

use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.

the class WorkflowInstanceTest method testMediaPackageDeserialization.

@Test
public void testMediaPackageDeserialization() throws Exception {
    WorkflowInstanceImpl workflow = new WorkflowInstanceImpl();
    String xml = "<mediapackage xmlns=\"http://mediapackage.opencastproject.org\" start=\"2007-12-05T13:40:00\" duration=\"1004400000\"><media><track id=\"track-1\" type=\"presenter/source\"><mimetype>audio/mp3</mimetype><url>http://localhost:8080/workflow/samples/audio.mp3</url><checksum type=\"md5\">950f9fa49caa8f1c5bbc36892f6fd062</checksum><duration>10472</duration><audio><channels>2</channels><bitdepth>0</bitdepth><bitrate>128004.0</bitrate><samplingrate>44100</samplingrate></audio></track><track id=\"track-2\" type=\"presenter/source\"><mimetype>video/quicktime</mimetype><url>http://localhost:8080/workflow/samples/camera.mpg</url><checksum type=\"md5\">43b7d843b02c4a429b2f547a4f230d31</checksum><duration>14546</duration><video><device type=\"UFG03\" version=\"30112007\" vendor=\"Unigraf\" /><encoder type=\"H.264\" version=\"7.4\" vendor=\"Apple Inc\" /><resolution>640x480</resolution><scanType type=\"progressive\" /><bitrate>540520</bitrate><frameRate>2</frameRate></video></track></media><metadata><catalog id=\"catalog-1\" type=\"dublincore/episode\"><mimetype>text/xml</mimetype><url>http://localhost:8080/workflow/samples/dc-1.xml</url><checksum type=\"md5\">20e466615251074e127a1627fd0dae3e</checksum></catalog></metadata></mediapackage>";
    MediaPackage src = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().loadFromXml(xml);
    workflow.setMediaPackage(src);
    Assert.assertEquals(2, workflow.getMediaPackage().getTracks().length);
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Test(org.junit.Test)

Example 22 with WorkflowInstanceImpl

use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.

the class WorkflowInstanceTest method testFlavorMarshalling.

@Test
public void testFlavorMarshalling() throws Exception {
    URI uri = new URI("http://testing");
    Track track = TrackImpl.fromURI(uri);
    track.setFlavor(MediaPackageElements.PRESENTATION_SOURCE);
    MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
    mp.add(track);
    WorkflowInstance workflow = new WorkflowInstanceImpl();
    workflow.setMediaPackage(mp);
    // Marshall the workflow to xml
    String xml = WorkflowParser.toXml(workflow);
    // Get it back from xml
    WorkflowInstance instance2 = WorkflowParser.parseWorkflowInstance(xml);
    Assert.assertEquals(workflow.getMediaPackage().getTracks()[0].getFlavor(), instance2.getMediaPackage().getTracks()[0].getFlavor());
    String namespaceXml = "<workflow xmlns=\"http://workflow.opencastproject.org\" xmlns:mp=\"http://mediapackage.opencastproject.org\"><parent/><mp:mediapackage><mp:media><mp:track type=\"presentation/source\" id=\"track-1\"><mp:url>http://testing</mp:url></mp:track></mp:media></mp:mediapackage></workflow>";
    WorkflowInstance instance3 = WorkflowParser.parseWorkflowInstance(namespaceXml);
    Assert.assertEquals(workflow.getMediaPackage().getTracks()[0].getFlavor(), instance3.getMediaPackage().getTracks()[0].getFlavor());
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) MediaPackage(org.opencastproject.mediapackage.MediaPackage) WorkflowInstance(org.opencastproject.workflow.api.WorkflowInstance) URI(java.net.URI) Track(org.opencastproject.mediapackage.Track) Test(org.junit.Test)

Example 23 with WorkflowInstanceImpl

use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.

the class WorkflowInstanceTest method testWorkflowWithoutOperations.

@Test
public void testWorkflowWithoutOperations() throws Exception {
    WorkflowInstanceImpl workflow = new WorkflowInstanceImpl();
    MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
    workflow.setMediaPackage(mp);
    Assert.assertEquals(mp.getIdentifier(), workflow.getMediaPackage().getIdentifier());
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Test(org.junit.Test)

Example 24 with WorkflowInstanceImpl

use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.

the class WorkflowRestEndpointTest method setUp.

@Before
public void setUp() throws Exception {
    // Create a workflow for the service to return
    workflow = new WorkflowInstanceImpl();
    workflow.setTitle("a workflow instance");
    workflow.setId(1);
    // Mock up the behavior of the workflow service
    WorkflowService service = EasyMock.createNiceMock(WorkflowService.class);
    EasyMock.expect(service.listAvailableWorkflowDefinitions()).andReturn(new ArrayList<WorkflowDefinition>());
    EasyMock.expect(service.getWorkflowById(EasyMock.anyLong())).andThrow(new NotFoundException()).times(2).andReturn(workflow);
    EasyMock.replay(service);
    // Set up the rest endpoint
    restService = new WorkflowRestService();
    restService.setService(service);
    restService.activate(null);
}
Also used : WorkflowRestService(org.opencastproject.workflow.endpoint.WorkflowRestService) WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) WorkflowService(org.opencastproject.workflow.api.WorkflowService) WorkflowDefinition(org.opencastproject.workflow.api.WorkflowDefinition) NotFoundException(org.opencastproject.util.NotFoundException) Before(org.junit.Before)

Example 25 with WorkflowInstanceImpl

use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.

the class WorkflowServiceImplTest method setupWorkflowInstanceImpl.

private WorkflowInstanceImpl setupWorkflowInstanceImpl(long id, String operation, WorkflowState state, Date startDate) throws ConfigurationException, MediaPackageException, NotFoundException, ServiceRegistryException {
    Job job = new JobImpl(id);
    job = serviceRegistry.updateJob(job);
    MediaPackage mediapackage = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
    mediapackage.setDate(startDate);
    mediapackage.setDuration(7200L);
    WorkflowOperationInstanceImpl workflowOperation = new WorkflowOperationInstanceImpl(operation, OperationState.PAUSED);
    workflowOperation.setId(id);
    List<WorkflowOperationInstance> workflowOperationInstanceList = new LinkedList<WorkflowOperationInstance>();
    workflowOperationInstanceList.add(workflowOperation);
    WorkflowInstanceImpl workflowInstanceImpl = new WorkflowInstanceImpl();
    workflowInstanceImpl.setMediaPackage(mediapackage);
    workflowInstanceImpl.setState(state);
    workflowInstanceImpl.setId(id);
    workflowInstanceImpl.setOperations(workflowOperationInstanceList);
    return workflowInstanceImpl;
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) JobImpl(org.opencastproject.job.api.JobImpl) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) MediaPackage(org.opencastproject.mediapackage.MediaPackage) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) Job(org.opencastproject.job.api.Job) LinkedList(java.util.LinkedList)

Aggregations

WorkflowInstanceImpl (org.opencastproject.workflow.api.WorkflowInstanceImpl)57 WorkflowOperationInstance (org.opencastproject.workflow.api.WorkflowOperationInstance)37 ArrayList (java.util.ArrayList)34 WorkflowOperationInstanceImpl (org.opencastproject.workflow.api.WorkflowOperationInstanceImpl)31 Test (org.junit.Test)27 WorkflowOperationResult (org.opencastproject.workflow.api.WorkflowOperationResult)17 MediaPackage (org.opencastproject.mediapackage.MediaPackage)12 Job (org.opencastproject.job.api.Job)9 Track (org.opencastproject.mediapackage.Track)9 URI (java.net.URI)8 Before (org.junit.Before)8 HashMap (java.util.HashMap)7 NotFoundException (org.opencastproject.util.NotFoundException)7 WorkflowDefinitionImpl (org.opencastproject.workflow.api.WorkflowDefinitionImpl)7 MediaPackageBuilder (org.opencastproject.mediapackage.MediaPackageBuilder)6 WorkflowInstance (org.opencastproject.workflow.api.WorkflowInstance)6 WorkflowOperationException (org.opencastproject.workflow.api.WorkflowOperationException)6 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)5 ServiceRegistry (org.opencastproject.serviceregistry.api.ServiceRegistry)5 File (java.io.File)4