use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class SilenceDetectionWorkflowOperationHandlerTest method testStartOperation.
@Test
public void testStartOperation() throws WorkflowOperationException, SilenceDetectionFailedException, NotFoundException, ServiceRegistryException, MediaPackageException, SmilException, MalformedURLException, JAXBException, SAXException, IOException {
Smil smil = smilService.fromXml(new File(smilURI)).getSmil();
Job job = EasyMock.createNiceMock(Job.class);
EasyMock.expect(job.getPayload()).andReturn(smil.toXML()).anyTimes();
EasyMock.expect(job.getStatus()).andReturn(Job.Status.FINISHED);
EasyMock.expect(silenceDetectionServiceMock.detect((Track) EasyMock.anyObject(), (Track[]) EasyMock.anyObject())).andReturn(job);
EasyMock.expect(workspaceMock.put((String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (InputStream) EasyMock.anyObject())).andReturn(smilURI);
ServiceRegistry serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class);
silenceDetectionOperationHandler.setServiceRegistry(serviceRegistry);
EasyMock.expect(serviceRegistry.getJob(EasyMock.anyLong())).andReturn(job);
EasyMock.replay(job, serviceRegistry, silenceDetectionServiceMock, workspaceMock);
WorkflowInstanceImpl workflowInstance = getWorkflowInstance(mp, getDefaultConfiguration());
WorkflowOperationResult result = silenceDetectionOperationHandler.start(workflowInstance, null);
Assert.assertNotNull("SilenceDetectionWorkflowOperationHandler workflow operation returns null " + "but should be an instantiated WorkflowOperationResult", result);
EasyMock.verify(silenceDetectionServiceMock, workspaceMock);
WorkflowOperationInstance worflowOperationInstance = workflowInstance.getCurrentOperation();
String smilFlavorSubtypeProperty = worflowOperationInstance.getConfiguration("smil-flavor-subtype");
// test media package contains new smil catalog
MediaPackageElementFlavor smilPartialFlavor = new MediaPackageElementFlavor("*", smilFlavorSubtypeProperty);
Catalog[] smilCatalogs = mp.getCatalogs(smilPartialFlavor);
Assert.assertTrue("Media package should contain a smil catalog", smilCatalogs != null && smilCatalogs.length > 0);
}
use of org.opencastproject.workflow.api.WorkflowOperationResult 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.WorkflowOperationResult 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.WorkflowOperationResult 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.WorkflowOperationResult 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);
}
Aggregations