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);
}
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());
}
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());
}
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);
}
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;
}
Aggregations