Search in sources :

Example 6 with WorkflowOperationResult

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

the class SeriesWorkflowOperationHandlerTest method testNoSeries.

@Test
public void testNoSeries() throws Exception {
    WorkflowInstanceImpl instance = new WorkflowInstanceImpl();
    List<WorkflowOperationInstance> ops = new ArrayList<WorkflowOperationInstance>();
    WorkflowOperationInstanceImpl operation = new WorkflowOperationInstanceImpl("test", OperationState.INSTANTIATED);
    ops.add(operation);
    instance.setOperations(ops);
    instance.setMediaPackage(mp);
    operation.setConfiguration(SeriesWorkflowOperationHandler.ATTACH_PROPERTY, "*");
    operation.setConfiguration(SeriesWorkflowOperationHandler.APPLY_ACL_PROPERTY, "true");
    WorkflowOperationResult result = operationHandler.start(instance, null);
    Assert.assertEquals(Action.SKIP, result.getAction());
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) ArrayList(java.util.ArrayList) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 7 with WorkflowOperationResult

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

the class TagWorkflowOperationHandlerTest method testAllTagsFlavors.

@Test
public void testAllTagsFlavors() throws Exception {
    WorkflowInstanceImpl instance = new WorkflowInstanceImpl();
    List<WorkflowOperationInstance> ops = new ArrayList<WorkflowOperationInstance>();
    WorkflowOperationInstanceImpl operation = new WorkflowOperationInstanceImpl("test", OperationState.INSTANTIATED);
    ops.add(operation);
    instance.setOperations(ops);
    instance.setMediaPackage(mp);
    operation.setConfiguration(TagWorkflowOperationHandler.SOURCE_FLAVORS_PROPERTY, "presenter/source");
    operation.setConfiguration(TagWorkflowOperationHandler.TARGET_FLAVOR_PROPERTY, "presenter/test");
    operation.setConfiguration(TagWorkflowOperationHandler.TARGET_TAGS_PROPERTY, "tag1,tag2");
    operation.setConfiguration(TagWorkflowOperationHandler.COPY_PROPERTY, "false");
    WorkflowOperationResult result = operationHandler.start(instance, null);
    MediaPackage resultingMediapackage = result.getMediaPackage();
    Track track = resultingMediapackage.getTrack("track-2");
    Assert.assertEquals("presenter/test", track.getFlavor().toString());
    Assert.assertEquals("tag1", track.getTags()[0]);
    Assert.assertEquals("tag2", track.getTags()[1]);
    instance = new WorkflowInstanceImpl();
    ops = new ArrayList<WorkflowOperationInstance>();
    operation = new WorkflowOperationInstanceImpl("test", OperationState.INSTANTIATED);
    ops.add(operation);
    instance.setOperations(ops);
    instance.setMediaPackage(resultingMediapackage);
    operation.setConfiguration(TagWorkflowOperationHandler.SOURCE_TAGS_PROPERTY, "tag1");
    operation.setConfiguration(TagWorkflowOperationHandler.TARGET_FLAVOR_PROPERTY, "presenter/source");
    operation.setConfiguration(TagWorkflowOperationHandler.TARGET_TAGS_PROPERTY, "-tag1,+tag3");
    operation.setConfiguration(TagWorkflowOperationHandler.COPY_PROPERTY, "false");
    result = operationHandler.start(instance, null);
    resultingMediapackage = result.getMediaPackage();
    track = resultingMediapackage.getTrack("track-2");
    Assert.assertEquals("presenter/source", track.getFlavor().toString());
    Assert.assertEquals("tag2", track.getTags()[0]);
    Assert.assertEquals("tag3", track.getTags()[1]);
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) ArrayList(java.util.ArrayList) MediaPackage(org.opencastproject.mediapackage.MediaPackage) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Track(org.opencastproject.mediapackage.Track) Test(org.junit.Test)

Example 8 with WorkflowOperationResult

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

the class ConfigureByDublinCoreTermWOHTest method testNoMatchConfiguredDCTerm.

@Test
public void testNoMatchConfiguredDCTerm() throws Exception {
    // No Match or Default Value
    // without dcterm or default the match should always fail
    operation.setConfiguration(ConfigureByDublinCoreTermWOH.DCCATALOG_PROPERTY, "episode");
    operation.setConfiguration(ConfigureByDublinCoreTermWOH.DCTERM_PROPERTY, "source");
    operation.setConfiguration(ConfigureByDublinCoreTermWOH.COPY_PROPERTY, "false");
    WorkflowOperationResult result = operationHandler.start(instance, null);
    Map<String, String> properties = result.getProperties();
    Assert.assertTrue(properties == null);
}
Also used : WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 9 with WorkflowOperationResult

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

the class ConfigureByDublinCoreTermWOHTest method testMatchPresentDCTermOverwriteProperty.

@Test
public void testMatchPresentDCTermOverwriteProperty() throws Exception {
    operation.setConfiguration(ConfigureByDublinCoreTermWOH.DCCATALOG_PROPERTY, "episode");
    operation.setConfiguration(ConfigureByDublinCoreTermWOH.DCTERM_PROPERTY, "publisher");
    operation.setConfiguration(ConfigureByDublinCoreTermWOH.MATCH_VALUE_PROPERTY, "University of Opencast");
    operation.setConfiguration(ConfigureByDublinCoreTermWOH.COPY_PROPERTY, "false");
    operation.setConfiguration("oldConfigProperty", "bar");
    WorkflowOperationResult result = operationHandler.start(instance, null);
    Map<String, String> properties = result.getProperties();
    Assert.assertTrue(properties.containsKey("oldConfigProperty"));
    Assert.assertEquals("bar", properties.get("oldConfigProperty"));
}
Also used : WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 10 with WorkflowOperationResult

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

the class DefaultsWorkflowOperationHandlerTest method testDontOverwriteExisting.

@Test
public void testDontOverwriteExisting() throws Exception {
    // Workflow configuration
    Map<String, String> workflowConfiguration = new HashMap<String, String>();
    workflowConfiguration.put(OPT_KEY, "initial");
    // Operation configuration
    Map<String, String> operationConfiguration = new HashMap<String, String>();
    operationConfiguration.put(OPT_KEY, DEFAULT_VALUE);
    // Run the operation handler
    WorkflowOperationResult workflowOperationResult = getWorkflowOperationResult(mp, workflowConfiguration, operationConfiguration);
    String configurationValue = workflowOperationResult.getProperties().get(OPT_KEY);
    // Make sure the default value has been applied
    Assert.assertNotEquals(DEFAULT_VALUE, configurationValue);
}
Also used : HashMap(java.util.HashMap) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Aggregations

WorkflowOperationResult (org.opencastproject.workflow.api.WorkflowOperationResult)101 Test (org.junit.Test)85 HashMap (java.util.HashMap)46 MediaPackage (org.opencastproject.mediapackage.MediaPackage)35 Track (org.opencastproject.mediapackage.Track)34 WorkflowOperationInstance (org.opencastproject.workflow.api.WorkflowOperationInstance)28 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)26 ArrayList (java.util.ArrayList)19 WorkflowOperationException (org.opencastproject.workflow.api.WorkflowOperationException)19 WorkflowInstanceImpl (org.opencastproject.workflow.api.WorkflowInstanceImpl)17 Job (org.opencastproject.job.api.Job)13 TrackImpl (org.opencastproject.mediapackage.track.TrackImpl)11 WorkflowInstance (org.opencastproject.workflow.api.WorkflowInstance)11 WorkflowOperationInstanceImpl (org.opencastproject.workflow.api.WorkflowOperationInstanceImpl)11 Catalog (org.opencastproject.mediapackage.Catalog)10 TrackSelector (org.opencastproject.mediapackage.selector.TrackSelector)9 URI (java.net.URI)7 File (java.io.File)6 Attachment (org.opencastproject.mediapackage.Attachment)6 MediaPackageElement (org.opencastproject.mediapackage.MediaPackageElement)6