use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.
the class VideoEditorWorkflowOperationHandlerTest method testEditorOperationInteractiveSkip.
@Test
public void testEditorOperationInteractiveSkip() throws WorkflowOperationException {
WorkflowInstanceImpl workflowInstance = getWorkflowInstance(mp, getDefaultConfiguration(false));
WorkflowOperationResult result = videoEditorWorkflowOperationHandler.start(workflowInstance, null);
Assert.assertNotNull("VideoEditor workflow operation returns null but should be an instantiated WorkflowOperationResult", result);
// mediapackage should contain new derived track with flavor given by "target-flavor-subtype" configuration
WorkflowOperationInstance worflowOperationInstance = workflowInstance.getCurrentOperation();
String targetFlavorSubtypeProperty = worflowOperationInstance.getConfiguration("target-flavor-subtype");
String skippedFlavorsProperty = worflowOperationInstance.getConfiguration("skipped-flavors");
TrackSelector trackSelector = new TrackSelector();
trackSelector.addFlavor(skippedFlavorsProperty);
Collection<Track> skippedTracks = trackSelector.select(result.getMediaPackage(), false);
Assert.assertTrue("Mediapackage does not contain any tracks matching flavor " + skippedFlavorsProperty, skippedTracks != null && !skippedTracks.isEmpty());
for (Track skippedTrack : skippedTracks) {
MediaPackageElementFlavor derivedTrackFlavor = MediaPackageElementFlavor.flavor(skippedTrack.getFlavor().getType(), targetFlavorSubtypeProperty);
MediaPackageElement[] derivedElements = result.getMediaPackage().getDerived(skippedTrack, derivedTrackFlavor);
Assert.assertTrue("Media package should contain track with flavor " + derivedTrackFlavor.toString(), derivedElements != null && derivedElements.length > 0);
}
}
use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.
the class VideoEditorWorkflowOperationHandlerTest method testEditorOperationSkip.
@Test
public void testEditorOperationSkip() throws WorkflowOperationException {
WorkflowInstanceImpl workflowInstance = getWorkflowInstance(mp, getDefaultConfiguration(true));
WorkflowOperationResult result = videoEditorWorkflowOperationHandler.skip(workflowInstance, null);
Assert.assertNotNull("VideoEditor workflow operation returns null but should be an instantiated WorkflowOperationResult", result);
// mediapackage should contain new derived track with flavor given by "target-flavor-subtype" configuration
WorkflowOperationInstance worflowOperationInstance = workflowInstance.getCurrentOperation();
String targetFlavorSubtypeProperty = worflowOperationInstance.getConfiguration("target-flavor-subtype");
String skippedFlavorsProperty = worflowOperationInstance.getConfiguration("skipped-flavors");
TrackSelector trackSelector = new TrackSelector();
trackSelector.addFlavor(skippedFlavorsProperty);
Collection<Track> skippedTracks = trackSelector.select(result.getMediaPackage(), false);
Assert.assertTrue("Mediapackage does not contain any tracks matching flavor " + skippedFlavorsProperty, skippedTracks != null && !skippedTracks.isEmpty());
for (Track skippedTrack : skippedTracks) {
MediaPackageElementFlavor derivedTrackFlavor = MediaPackageElementFlavor.flavor(skippedTrack.getFlavor().getType(), targetFlavorSubtypeProperty);
MediaPackageElement[] derivedElements = result.getMediaPackage().getDerived(skippedTrack, derivedTrackFlavor);
Assert.assertTrue("Media package should contain track with flavor " + derivedTrackFlavor.toString(), derivedElements != null && derivedElements.length > 0);
}
}
use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.
the class VideoEditorWorkflowOperationHandlerTest method testEditorOperationSkipWithModifiedSkippedFlavorsAndTargetFlavorProperty.
@Test
@Ignore
public void testEditorOperationSkipWithModifiedSkippedFlavorsAndTargetFlavorProperty() throws WorkflowOperationException {
Map<String, String> configuration = getDefaultConfiguration(true);
configuration.put("skipped-flavors", "*/preview");
configuration.put("target-flavor-subtype", "edited");
WorkflowInstanceImpl workflowInstance = getWorkflowInstance(mp, configuration);
WorkflowOperationResult result = videoEditorWorkflowOperationHandler.skip(workflowInstance, null);
Assert.assertNotNull("VideoEditor workflow operation returns null but should be an instantiated WorkflowOperationResult", result);
// mediapackage should contain new derived track with flavor given by "target-flavor-subtype" configuration
WorkflowOperationInstance worflowOperationInstance = workflowInstance.getCurrentOperation();
String targetFlavorSubtypeProperty = worflowOperationInstance.getConfiguration("target-flavor-subtype");
String skippedFlavorsProperty = worflowOperationInstance.getConfiguration("skipped-flavors");
TrackSelector trackSelector = new TrackSelector();
trackSelector.addFlavor(skippedFlavorsProperty);
Collection<Track> skippedTracks = trackSelector.select(result.getMediaPackage(), false);
Assert.assertTrue("Mediapackage does not contain any tracks matching flavor " + skippedFlavorsProperty, skippedTracks != null && !skippedTracks.isEmpty());
for (Track skippedTrack : skippedTracks) {
MediaPackageElementFlavor derivedTrackFlavor = MediaPackageElementFlavor.flavor(skippedTrack.getFlavor().getType(), targetFlavorSubtypeProperty);
MediaPackageElement[] derivedElements = result.getMediaPackage().getDerived(skippedTrack, derivedTrackFlavor);
Assert.assertTrue("Media package should contain track with flavor " + derivedTrackFlavor.toString(), derivedElements != null && derivedElements.length > 0);
Assert.assertTrue("Mediapackage schould contain a derived track with flavor subtype " + targetFlavorSubtypeProperty, derivedElements[0].getFlavor().getSubtype().equals(targetFlavorSubtypeProperty));
}
}
use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.
the class VideoEditorWorkflowOperationHandlerTest method testEditorOperationStart.
@Test
public void testEditorOperationStart() throws WorkflowOperationException, IOException {
// uri for new preview track smil file
EasyMock.expect(workspaceMock.put((String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (InputStream) EasyMock.anyObject())).andReturn(URI.create("http://localhost:8080/foo/presenter.smil"));
// uri for new episode smil file
String episodeSmilUri = "http://localhost:8080/foo/episode.smil";
EasyMock.expect(workspaceMock.put((String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (InputStream) EasyMock.anyObject())).andReturn(URI.create(episodeSmilUri));
EasyMock.replay(workspaceMock);
WorkflowInstanceImpl workflowInstance = getWorkflowInstance(mp, getDefaultConfiguration(true));
WorkflowOperationResult result = videoEditorWorkflowOperationHandler.start(workflowInstance, null);
Assert.assertNotNull("VideoEditor workflow operation returns null but should be an instantiated WorkflowOperationResult", result);
EasyMock.verify(workspaceMock);
WorkflowOperationInstance worflowOperationInstance = workflowInstance.getCurrentOperation();
String smillFlavorsProperty = worflowOperationInstance.getConfiguration("smil-flavors");
String previewFlavorsProperty = worflowOperationInstance.getConfiguration("preview-flavors");
MediaPackageElementFlavor smilFlavor = MediaPackageElementFlavor.parseFlavor(smillFlavorsProperty);
MediaPackageElementFlavor previewFlavor = MediaPackageElementFlavor.parseFlavor(previewFlavorsProperty);
// each preview track (e.g. presenter/preview) should have an own smil catalog in media package
Catalog[] previewSmilCatalogs = result.getMediaPackage().getCatalogs(new MediaPackageElementFlavor("presenter", "smil"));
Assert.assertTrue(previewSmilCatalogs != null && previewSmilCatalogs.length > 0);
for (Track track : result.getMediaPackage().getTracks()) {
if (track.getFlavor().matches(previewFlavor)) {
boolean smilCatalogFound = false;
MediaPackageElementFlavor trackSmilFlavor = new MediaPackageElementFlavor(track.getFlavor().getType(), smilFlavor.getSubtype());
for (Catalog previewSmilCatalog : previewSmilCatalogs) {
if (previewSmilCatalog.getFlavor().matches(trackSmilFlavor)) {
smilCatalogFound = true;
break;
}
}
Assert.assertTrue("Mediapackage doesn't contain a smil catalog with flavor " + trackSmilFlavor.toString(), smilCatalogFound);
}
}
// an "target-smil-flavor catalog" schould be in media package
String targetSmilFlavorProperty = worflowOperationInstance.getConfiguration("target-smil-flavor");
Catalog[] episodeSmilCatalogs = result.getMediaPackage().getCatalogs(MediaPackageElementFlavor.parseFlavor(targetSmilFlavorProperty));
Assert.assertTrue("Mediapackage should contain catalog with flavor " + targetSmilFlavorProperty, episodeSmilCatalogs != null && episodeSmilCatalogs.length > 0);
Assert.assertTrue("Target smil catalog URI does not match", episodeSmilCatalogs[0].getURI().compareTo(URI.create(episodeSmilUri)) == 0);
}
use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.
the class WorkflowRestService method startWorkflow.
private WorkflowInstanceImpl startWorkflow(WorkflowDefinition workflowDefinition, MediaPackageImpl mp, String parentWorkflowId, LocalHashMap localMap) {
Map<String, String> properties = new HashMap<String, String>();
if (localMap != null)
properties = localMap.getMap();
Long parentIdAsLong = null;
if (StringUtils.isNotEmpty(parentWorkflowId)) {
try {
parentIdAsLong = Long.parseLong(parentWorkflowId);
} catch (NumberFormatException e) {
throw new WebApplicationException(e, Status.BAD_REQUEST);
}
}
try {
return (WorkflowInstanceImpl) service.start(workflowDefinition, mp, parentIdAsLong, properties);
} catch (WorkflowException e) {
throw new WebApplicationException(e);
} catch (NotFoundException e) {
throw new WebApplicationException(e);
}
}
Aggregations